1 | ;
|
2 | /**
|
3 | * @license
|
4 | * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
5 | * This code may only be used under the BSD style license found at
|
6 | * http://polymer.github.io/LICENSE.txt
|
7 | * The complete set of authors may be found at
|
8 | * http://polymer.github.io/AUTHORS.txt
|
9 | * The complete set of contributors may be found at
|
10 | * http://polymer.github.io/CONTRIBUTORS.txt
|
11 | * Code distributed by Google as part of the polymer project is also
|
12 | * subject to an additional IP rights grant found at
|
13 | * http://polymer.github.io/PATENTS.txt
|
14 | */
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | /**
|
17 | * This is a special map which automatically creates
|
18 | * a default value if the key is not found.
|
19 | */
|
20 | class MapWithDefault extends Map {
|
21 | constructor(makeDefault) {
|
22 | super();
|
23 | this.makeDefault = makeDefault;
|
24 | }
|
25 | get(key) {
|
26 | if (!this.has(key)) {
|
27 | super.set(key, this.makeDefault(key));
|
28 | }
|
29 | return super.get(key);
|
30 | }
|
31 | }
|
32 | exports.MapWithDefault = MapWithDefault;
|
33 | //# sourceMappingURL=map.js.map |
\ | No newline at end of file |