@shgysk8zer0/polyfills 0.3.13 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +5 -1
- package/abort.js +166 -168
- package/all.min.js +11 -11
- package/all.min.js.map +1 -1
- package/array.js +2 -1
- package/assets/dedent.js +172 -0
- package/node.js +19 -0
- package/node.min.js +6 -0
- package/node.min.js.map +1 -0
- package/package.json +15 -15
- package/rollup.config.js +29 -8
- package/string.js +1 -1
- package/weakMap.js +21 -25
package/weakMap.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
(
|
|
2
|
-
|
|
1
|
+
if (! (WeakMap.prototype.emplace instanceof Function)) {
|
|
2
|
+
WeakMap.prototype.emplace = function emplace(key, { insert, update } = {}) {
|
|
3
|
+
const has = this.has(key);
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
5
|
+
if (has && update instanceof Function) {
|
|
6
|
+
const existing = this.get(key);
|
|
7
|
+
const value = update.call(this, existing, key, this);
|
|
7
8
|
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
const value = update.call(this, existing, key, this);
|
|
11
|
-
|
|
12
|
-
if (value !== existing) {
|
|
13
|
-
this.set(key, existing);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return value;
|
|
17
|
-
} else if (has) {
|
|
18
|
-
return this.get(key);
|
|
19
|
-
} else if (insert instanceof Function) {
|
|
20
|
-
const value = insert.call(this, key, this);
|
|
21
|
-
this.set(key, value);
|
|
22
|
-
return value;
|
|
23
|
-
} else {
|
|
24
|
-
throw new Error('Key is not found and no `insert()` given');
|
|
9
|
+
if (value !== existing) {
|
|
10
|
+
this.set(key, existing);
|
|
25
11
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
12
|
+
|
|
13
|
+
return value;
|
|
14
|
+
} else if (has) {
|
|
15
|
+
return this.get(key);
|
|
16
|
+
} else if (insert instanceof Function) {
|
|
17
|
+
const value = insert.call(this, key, this);
|
|
18
|
+
this.set(key, value);
|
|
19
|
+
return value;
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error('Key is not found and no `insert()` given');
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|