core-js 3.6.3 → 3.8.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/README.md +3 -2
- package/es/aggregate-error.js +6 -0
- package/es/array/virtual/filter-out.js +4 -0
- package/es/index.js +33 -29
- package/es/instance/replace-all.js +9 -0
- package/es/object/index.js +2 -1
- package/es/object/to-string.js +3 -2
- package/es/promise/any.js +12 -0
- package/es/promise/index.js +4 -2
- package/es/reflect/index.js +1 -0
- package/es/reflect/to-string-tag.js +3 -0
- package/es/string/index.js +1 -0
- package/es/string/replace-all.js +4 -0
- package/es/string/virtual/index.js +1 -0
- package/es/string/virtual/replace-all.js +4 -0
- package/es/symbol/index.js +2 -1
- package/es/symbol/to-string-tag.js +2 -1
- package/features/aggregate-error.js +4 -4
- package/features/array/at.js +4 -0
- package/features/array/filter-out.js +4 -0
- package/features/array/index.js +4 -0
- package/features/array/unique-by.js +5 -0
- package/features/array/virtual/at.js +4 -0
- package/features/array/virtual/filter-out.js +4 -0
- package/features/array/virtual/index.js +3 -0
- package/features/array/virtual/unique-by.js +5 -0
- package/features/bigint/index.js +4 -0
- package/features/bigint/range.js +4 -0
- package/features/instance/at.js +7 -3
- package/features/instance/filter-out.js +8 -0
- package/features/instance/replace-all.js +2 -8
- package/features/instance/unique-by.js +8 -0
- package/features/map/emplace.js +5 -0
- package/features/map/index.js +2 -0
- package/features/number/index.js +1 -0
- package/features/number/range.js +4 -0
- package/features/promise/any.js +4 -9
- package/features/reflect/to-string-tag.js +3 -0
- package/features/string/index.js +2 -0
- package/features/string/replace-all.js +4 -2
- package/features/string/virtual/index.js +2 -0
- package/features/string/virtual/replace-all.js +4 -2
- package/features/typed-array/at.js +1 -0
- package/features/typed-array/filter-out.js +1 -0
- package/features/typed-array/index.js +2 -0
- package/features/weak-map/emplace.js +5 -0
- package/features/weak-map/index.js +2 -0
- package/internals/array-iteration.js +11 -4
- package/internals/array-last-index-of.js +2 -1
- package/internals/array-method-uses-to-length.js +5 -8
- package/internals/async-iterator-iteration.js +25 -6
- package/internals/call-with-safe-iteration-closing.js +2 -2
- package/internals/collection-from.js +5 -5
- package/internals/collection-strong.js +1 -1
- package/internals/collection-weak.js +1 -1
- package/internals/collection.js +1 -1
- package/internals/correct-is-regexp-logic.js +2 -2
- package/internals/engine-is-node.js +4 -0
- package/internals/global.js +1 -1
- package/internals/internal-state.js +4 -1
- package/internals/iterate.js +26 -11
- package/internals/iterator-close.js +8 -0
- package/internals/map-emplace.js +13 -0
- package/internals/microtask.js +8 -8
- package/internals/range-iterator.js +102 -0
- package/internals/redefine.js +8 -2
- package/internals/shared.js +1 -1
- package/internals/task.js +9 -3
- package/modules/es.aggregate-error.js +31 -0
- package/modules/es.array.reduce-right.js +8 -2
- package/modules/es.array.reduce.js +6 -1
- package/modules/es.object.from-entries.js +1 -1
- package/modules/es.promise.all-settled.js +2 -2
- package/modules/es.promise.any.js +46 -0
- package/modules/es.promise.js +27 -25
- package/modules/es.reflect.set.js +3 -2
- package/modules/es.reflect.to-string-tag.js +9 -0
- package/modules/es.string.replace-all.js +50 -0
- package/modules/esnext.aggregate-error.js +2 -45
- package/modules/esnext.array.at.js +20 -0
- package/modules/esnext.array.filter-out.js +14 -0
- package/modules/esnext.array.unique-by.js +38 -0
- package/modules/esnext.async-iterator.take.js +12 -3
- package/modules/esnext.bigint.range.js +14 -0
- package/modules/esnext.iterator.every.js +3 -3
- package/modules/esnext.iterator.find.js +3 -3
- package/modules/esnext.iterator.flat-map.js +21 -15
- package/modules/esnext.iterator.for-each.js +1 -1
- package/modules/esnext.iterator.reduce.js +1 -1
- package/modules/esnext.iterator.some.js +3 -3
- package/modules/esnext.iterator.take.js +4 -2
- package/modules/esnext.iterator.to-array.js +1 -1
- package/modules/esnext.map.emplace.js +10 -0
- package/modules/esnext.map.every.js +3 -3
- package/modules/esnext.map.filter.js +1 -1
- package/modules/esnext.map.find-key.js +3 -3
- package/modules/esnext.map.find.js +3 -3
- package/modules/esnext.map.includes.js +3 -3
- package/modules/esnext.map.key-of.js +3 -3
- package/modules/esnext.map.map-keys.js +1 -1
- package/modules/esnext.map.map-values.js +1 -1
- package/modules/esnext.map.merge.js +1 -1
- package/modules/esnext.map.reduce.js +1 -1
- package/modules/esnext.map.some.js +3 -3
- package/modules/esnext.map.update-or-insert.js +1 -1
- package/modules/esnext.map.upsert.js +2 -1
- package/modules/esnext.number.range.js +11 -0
- package/modules/esnext.observable.js +3 -3
- package/modules/esnext.promise.any.js +2 -46
- package/modules/esnext.reflect.get-metadata-keys.js +1 -1
- package/modules/esnext.set.every.js +3 -3
- package/modules/esnext.set.filter.js +1 -1
- package/modules/esnext.set.find.js +3 -3
- package/modules/esnext.set.is-disjoint-from.js +3 -3
- package/modules/esnext.set.is-subset-of.js +3 -3
- package/modules/esnext.set.is-superset-of.js +3 -3
- package/modules/esnext.set.join.js +1 -1
- package/modules/esnext.set.map.js +1 -1
- package/modules/esnext.set.reduce.js +1 -1
- package/modules/esnext.set.some.js +3 -3
- package/modules/esnext.set.union.js +1 -1
- package/modules/esnext.string.at-alternative.js +23 -0
- package/modules/esnext.string.at.js +6 -1
- package/modules/esnext.string.replace-all.js +2 -50
- package/modules/esnext.typed-array.at.js +17 -0
- package/modules/esnext.typed-array.filter-out.js +20 -0
- package/modules/esnext.weak-map.emplace.js +10 -0
- package/modules/esnext.weak-map.upsert.js +3 -2
- package/modules/web.queue-microtask.js +2 -3
- package/modules/web.url-search-params.js +1 -1
- package/modules/web.url.js +1 -1
- package/package.json +1 -1
- package/postinstall.js +3 -1
- package/proposals/array-filtering.js +3 -0
- package/proposals/array-unique.js +3 -0
- package/proposals/efficient-64-bit-arithmetic.js +1 -0
- package/proposals/map-upsert.js +4 -0
- package/proposals/number-range.js +3 -0
- package/proposals/object-iteration.js +1 -0
- package/proposals/relative-indexing-method.js +5 -0
- package/stable/aggregate-error.js +6 -0
- package/stable/instance/replace-all.js +3 -0
- package/stable/promise/any.js +3 -0
- package/stable/reflect/to-string-tag.js +3 -0
- package/stable/string/replace-all.js +3 -0
- package/stable/string/virtual/replace-all.js +3 -0
- package/stage/1.js +3 -0
- package/stage/3.js +1 -2
- package/stage/4.js +2 -0
|
@@ -19,6 +19,25 @@ var createMethod = function (TYPE) {
|
|
|
19
19
|
if (!IS_TO_ARRAY) aFunction(fn);
|
|
20
20
|
|
|
21
21
|
return new Promise(function (resolve, reject) {
|
|
22
|
+
var closeIteration = function (method, argument) {
|
|
23
|
+
try {
|
|
24
|
+
var returnMethod = iterator['return'];
|
|
25
|
+
if (returnMethod !== undefined) {
|
|
26
|
+
return Promise.resolve(returnMethod.call(iterator)).then(function () {
|
|
27
|
+
method(argument);
|
|
28
|
+
}, function (error) {
|
|
29
|
+
reject(error);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
} catch (error2) {
|
|
33
|
+
return reject(error2);
|
|
34
|
+
} method(argument);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var onError = function (error) {
|
|
38
|
+
closeIteration(reject, error);
|
|
39
|
+
};
|
|
40
|
+
|
|
22
41
|
var loop = function () {
|
|
23
42
|
try {
|
|
24
43
|
Promise.resolve(anObject(next.call(iterator))).then(function (step) {
|
|
@@ -35,16 +54,16 @@ var createMethod = function (TYPE) {
|
|
|
35
54
|
if (IS_FOR_EACH) {
|
|
36
55
|
loop();
|
|
37
56
|
} else if (IS_EVERY) {
|
|
38
|
-
result ? loop() : resolve
|
|
57
|
+
result ? loop() : closeIteration(resolve, false);
|
|
39
58
|
} else {
|
|
40
|
-
result ? resolve
|
|
59
|
+
result ? closeIteration(resolve, IS_SOME || value) : loop();
|
|
41
60
|
}
|
|
42
|
-
},
|
|
61
|
+
}, onError);
|
|
43
62
|
}
|
|
44
63
|
}
|
|
45
|
-
} catch (
|
|
46
|
-
},
|
|
47
|
-
} catch (
|
|
64
|
+
} catch (error) { onError(error); }
|
|
65
|
+
}, onError);
|
|
66
|
+
} catch (error2) { onError(error2); }
|
|
48
67
|
};
|
|
49
68
|
|
|
50
69
|
loop();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var anObject = require('../internals/an-object');
|
|
2
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
2
3
|
|
|
3
4
|
// call something on iterator step with safe closing on error
|
|
4
5
|
module.exports = function (iterator, fn, value, ENTRIES) {
|
|
@@ -6,8 +7,7 @@ module.exports = function (iterator, fn, value, ENTRIES) {
|
|
|
6
7
|
return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
|
|
7
8
|
// 7.4.6 IteratorClose(iterator, completion)
|
|
8
9
|
} catch (error) {
|
|
9
|
-
|
|
10
|
-
if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
|
|
10
|
+
iteratorClose(iterator);
|
|
11
11
|
throw error;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
@@ -7,20 +7,20 @@ var iterate = require('../internals/iterate');
|
|
|
7
7
|
module.exports = function from(source /* , mapFn, thisArg */) {
|
|
8
8
|
var length = arguments.length;
|
|
9
9
|
var mapFn = length > 1 ? arguments[1] : undefined;
|
|
10
|
-
var mapping,
|
|
10
|
+
var mapping, array, n, boundFunction;
|
|
11
11
|
aFunction(this);
|
|
12
12
|
mapping = mapFn !== undefined;
|
|
13
13
|
if (mapping) aFunction(mapFn);
|
|
14
14
|
if (source == undefined) return new this();
|
|
15
|
-
|
|
15
|
+
array = [];
|
|
16
16
|
if (mapping) {
|
|
17
17
|
n = 0;
|
|
18
18
|
boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined, 2);
|
|
19
19
|
iterate(source, function (nextItem) {
|
|
20
|
-
|
|
20
|
+
array.push(boundFunction(nextItem, n++));
|
|
21
21
|
});
|
|
22
22
|
} else {
|
|
23
|
-
iterate(source,
|
|
23
|
+
iterate(source, array.push, { that: array });
|
|
24
24
|
}
|
|
25
|
-
return new this(
|
|
25
|
+
return new this(array);
|
|
26
26
|
};
|
|
@@ -26,7 +26,7 @@ module.exports = {
|
|
|
26
26
|
size: 0
|
|
27
27
|
});
|
|
28
28
|
if (!DESCRIPTORS) that.size = 0;
|
|
29
|
-
if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);
|
|
29
|
+
if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
|
|
@@ -61,7 +61,7 @@ module.exports = {
|
|
|
61
61
|
id: id++,
|
|
62
62
|
frozen: undefined
|
|
63
63
|
});
|
|
64
|
-
if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);
|
|
64
|
+
if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
|
package/internals/collection.js
CHANGED
|
@@ -69,7 +69,7 @@ module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
|
|
|
69
69
|
Constructor = wrapper(function (dummy, iterable) {
|
|
70
70
|
anInstance(dummy, Constructor, CONSTRUCTOR_NAME);
|
|
71
71
|
var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
|
|
72
|
-
if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);
|
|
72
|
+
if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
|
|
73
73
|
return that;
|
|
74
74
|
});
|
|
75
75
|
Constructor.prototype = NativePrototype;
|
|
@@ -6,10 +6,10 @@ module.exports = function (METHOD_NAME) {
|
|
|
6
6
|
var regexp = /./;
|
|
7
7
|
try {
|
|
8
8
|
'/./'[METHOD_NAME](regexp);
|
|
9
|
-
} catch (
|
|
9
|
+
} catch (error1) {
|
|
10
10
|
try {
|
|
11
11
|
regexp[MATCH] = false;
|
|
12
12
|
return '/./'[METHOD_NAME](regexp);
|
|
13
|
-
} catch (
|
|
13
|
+
} catch (error2) { /* empty */ }
|
|
14
14
|
} return false;
|
|
15
15
|
};
|
package/internals/global.js
CHANGED
|
@@ -3,6 +3,7 @@ var global = require('../internals/global');
|
|
|
3
3
|
var isObject = require('../internals/is-object');
|
|
4
4
|
var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
|
|
5
5
|
var objectHas = require('../internals/has');
|
|
6
|
+
var shared = require('../internals/shared-store');
|
|
6
7
|
var sharedKey = require('../internals/shared-key');
|
|
7
8
|
var hiddenKeys = require('../internals/hidden-keys');
|
|
8
9
|
|
|
@@ -23,11 +24,12 @@ var getterFor = function (TYPE) {
|
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
if (NATIVE_WEAK_MAP) {
|
|
26
|
-
var store = new WeakMap();
|
|
27
|
+
var store = shared.state || (shared.state = new WeakMap());
|
|
27
28
|
var wmget = store.get;
|
|
28
29
|
var wmhas = store.has;
|
|
29
30
|
var wmset = store.set;
|
|
30
31
|
set = function (it, metadata) {
|
|
32
|
+
metadata.facade = it;
|
|
31
33
|
wmset.call(store, it, metadata);
|
|
32
34
|
return metadata;
|
|
33
35
|
};
|
|
@@ -41,6 +43,7 @@ if (NATIVE_WEAK_MAP) {
|
|
|
41
43
|
var STATE = sharedKey('state');
|
|
42
44
|
hiddenKeys[STATE] = true;
|
|
43
45
|
set = function (it, metadata) {
|
|
46
|
+
metadata.facade = it;
|
|
44
47
|
createNonEnumerableProperty(it, STATE, metadata);
|
|
45
48
|
return metadata;
|
|
46
49
|
};
|
package/internals/iterate.js
CHANGED
|
@@ -3,17 +3,33 @@ var isArrayIteratorMethod = require('../internals/is-array-iterator-method');
|
|
|
3
3
|
var toLength = require('../internals/to-length');
|
|
4
4
|
var bind = require('../internals/function-bind-context');
|
|
5
5
|
var getIteratorMethod = require('../internals/get-iterator-method');
|
|
6
|
-
var
|
|
6
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
7
7
|
|
|
8
8
|
var Result = function (stopped, result) {
|
|
9
9
|
this.stopped = stopped;
|
|
10
10
|
this.result = result;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
var
|
|
13
|
+
module.exports = function (iterable, unboundFunction, options) {
|
|
14
|
+
var that = options && options.that;
|
|
15
|
+
var AS_ENTRIES = !!(options && options.AS_ENTRIES);
|
|
16
|
+
var IS_ITERATOR = !!(options && options.IS_ITERATOR);
|
|
17
|
+
var INTERRUPTED = !!(options && options.INTERRUPTED);
|
|
18
|
+
var fn = bind(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);
|
|
15
19
|
var iterator, iterFn, index, length, result, next, step;
|
|
16
20
|
|
|
21
|
+
var stop = function (condition) {
|
|
22
|
+
if (iterator) iteratorClose(iterator);
|
|
23
|
+
return new Result(true, condition);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var callFn = function (value) {
|
|
27
|
+
if (AS_ENTRIES) {
|
|
28
|
+
anObject(value);
|
|
29
|
+
return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
|
|
30
|
+
} return INTERRUPTED ? fn(value, stop) : fn(value);
|
|
31
|
+
};
|
|
32
|
+
|
|
17
33
|
if (IS_ITERATOR) {
|
|
18
34
|
iterator = iterable;
|
|
19
35
|
} else {
|
|
@@ -22,9 +38,7 @@ var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITER
|
|
|
22
38
|
// optimisation for array iterators
|
|
23
39
|
if (isArrayIteratorMethod(iterFn)) {
|
|
24
40
|
for (index = 0, length = toLength(iterable.length); length > index; index++) {
|
|
25
|
-
result =
|
|
26
|
-
? boundFunction(anObject(step = iterable[index])[0], step[1])
|
|
27
|
-
: boundFunction(iterable[index]);
|
|
41
|
+
result = callFn(iterable[index]);
|
|
28
42
|
if (result && result instanceof Result) return result;
|
|
29
43
|
} return new Result(false);
|
|
30
44
|
}
|
|
@@ -33,11 +47,12 @@ var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITER
|
|
|
33
47
|
|
|
34
48
|
next = iterator.next;
|
|
35
49
|
while (!(step = next.call(iterator)).done) {
|
|
36
|
-
|
|
50
|
+
try {
|
|
51
|
+
result = callFn(step.value);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
iteratorClose(iterator);
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
37
56
|
if (typeof result == 'object' && result && result instanceof Result) return result;
|
|
38
57
|
} return new Result(false);
|
|
39
58
|
};
|
|
40
|
-
|
|
41
|
-
iterate.stop = function (result) {
|
|
42
|
-
return new Result(true, result);
|
|
43
|
-
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var anObject = require('../internals/an-object');
|
|
3
|
+
|
|
4
|
+
// `Map.prototype.emplace` method
|
|
5
|
+
// https://github.com/thumbsupep/proposal-upsert
|
|
6
|
+
module.exports = function emplace(key, handler) {
|
|
7
|
+
var map = anObject(this);
|
|
8
|
+
var value = (map.has(key) && 'update' in handler)
|
|
9
|
+
? handler.update(map.get(key), key, map)
|
|
10
|
+
: handler.insert(key, map);
|
|
11
|
+
map.set(key, value);
|
|
12
|
+
return value;
|
|
13
|
+
};
|
package/internals/microtask.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var global = require('../internals/global');
|
|
2
2
|
var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
|
|
3
|
-
var classof = require('../internals/classof-raw');
|
|
4
3
|
var macrotask = require('../internals/task').set;
|
|
5
4
|
var IS_IOS = require('../internals/engine-is-ios');
|
|
5
|
+
var IS_NODE = require('../internals/engine-is-node');
|
|
6
6
|
|
|
7
7
|
var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
|
|
8
|
+
var document = global.document;
|
|
8
9
|
var process = global.process;
|
|
9
10
|
var Promise = global.Promise;
|
|
10
|
-
var IS_NODE = classof(process) == 'process';
|
|
11
11
|
// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
|
|
12
12
|
var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
|
|
13
13
|
var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
|
|
@@ -33,13 +33,8 @@ if (!queueMicrotask) {
|
|
|
33
33
|
if (parent) parent.enter();
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
// Node.js
|
|
37
|
-
if (IS_NODE) {
|
|
38
|
-
notify = function () {
|
|
39
|
-
process.nextTick(flush);
|
|
40
|
-
};
|
|
41
36
|
// browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
|
|
42
|
-
|
|
37
|
+
if (!IS_IOS && !IS_NODE && MutationObserver && document) {
|
|
43
38
|
toggle = true;
|
|
44
39
|
node = document.createTextNode('');
|
|
45
40
|
new MutationObserver(flush).observe(node, { characterData: true });
|
|
@@ -54,6 +49,11 @@ if (!queueMicrotask) {
|
|
|
54
49
|
notify = function () {
|
|
55
50
|
then.call(promise, flush);
|
|
56
51
|
};
|
|
52
|
+
// Node.js without promises
|
|
53
|
+
} else if (IS_NODE) {
|
|
54
|
+
notify = function () {
|
|
55
|
+
process.nextTick(flush);
|
|
56
|
+
};
|
|
57
57
|
// for other environments - macrotask based on:
|
|
58
58
|
// - setImmediate
|
|
59
59
|
// - MessageChannel
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var InternalStateModule = require('../internals/internal-state');
|
|
3
|
+
var createIteratorConstructor = require('../internals/create-iterator-constructor');
|
|
4
|
+
var isObject = require('../internals/is-object');
|
|
5
|
+
var defineProperties = require('../internals/object-define-properties');
|
|
6
|
+
var DESCRIPTORS = require('../internals/descriptors');
|
|
7
|
+
|
|
8
|
+
var INCORRECT_RANGE = 'Incorrect Number.range arguments';
|
|
9
|
+
var RANGE_ITERATOR = 'RangeIterator';
|
|
10
|
+
|
|
11
|
+
var setInternalState = InternalStateModule.set;
|
|
12
|
+
var getInternalState = InternalStateModule.getterFor(RANGE_ITERATOR);
|
|
13
|
+
|
|
14
|
+
var $RangeIterator = createIteratorConstructor(function RangeIterator(start, end, option, type, zero, one) {
|
|
15
|
+
if (typeof start != type || (end !== Infinity && end !== -Infinity && typeof end != type)) {
|
|
16
|
+
throw new TypeError(INCORRECT_RANGE);
|
|
17
|
+
}
|
|
18
|
+
if (start === Infinity || start === -Infinity) {
|
|
19
|
+
throw new RangeError(INCORRECT_RANGE);
|
|
20
|
+
}
|
|
21
|
+
var ifIncrease = end > start;
|
|
22
|
+
var inclusiveEnd = false;
|
|
23
|
+
var step;
|
|
24
|
+
if (option === undefined) {
|
|
25
|
+
step = undefined;
|
|
26
|
+
} else if (isObject(option)) {
|
|
27
|
+
step = option.step;
|
|
28
|
+
inclusiveEnd = !!option.inclusive;
|
|
29
|
+
} else if (typeof option == type) {
|
|
30
|
+
step = option;
|
|
31
|
+
} else {
|
|
32
|
+
throw new TypeError(INCORRECT_RANGE);
|
|
33
|
+
}
|
|
34
|
+
if (step == null) {
|
|
35
|
+
step = ifIncrease ? one : -one;
|
|
36
|
+
}
|
|
37
|
+
if (typeof step != type) {
|
|
38
|
+
throw new TypeError(INCORRECT_RANGE);
|
|
39
|
+
}
|
|
40
|
+
if (step === Infinity || step === -Infinity || (step === zero && start !== end)) {
|
|
41
|
+
throw new RangeError(INCORRECT_RANGE);
|
|
42
|
+
}
|
|
43
|
+
// eslint-disable-next-line no-self-compare
|
|
44
|
+
var hitsEnd = start != start || end != end || step != step || (end > start) !== (step > zero);
|
|
45
|
+
setInternalState(this, {
|
|
46
|
+
type: RANGE_ITERATOR,
|
|
47
|
+
start: start,
|
|
48
|
+
end: end,
|
|
49
|
+
step: step,
|
|
50
|
+
inclusiveEnd: inclusiveEnd,
|
|
51
|
+
hitsEnd: hitsEnd,
|
|
52
|
+
currentCount: zero,
|
|
53
|
+
zero: zero
|
|
54
|
+
});
|
|
55
|
+
if (!DESCRIPTORS) {
|
|
56
|
+
this.start = start;
|
|
57
|
+
this.end = end;
|
|
58
|
+
this.step = step;
|
|
59
|
+
this.inclusive = inclusiveEnd;
|
|
60
|
+
}
|
|
61
|
+
}, RANGE_ITERATOR, function next() {
|
|
62
|
+
var state = getInternalState(this);
|
|
63
|
+
if (state.hitsEnd) return { value: undefined, done: true };
|
|
64
|
+
var start = state.start;
|
|
65
|
+
var end = state.end;
|
|
66
|
+
var step = state.step;
|
|
67
|
+
var currentYieldingValue = start + (step * state.currentCount++);
|
|
68
|
+
if (currentYieldingValue === end) state.hitsEnd = true;
|
|
69
|
+
var inclusiveEnd = state.inclusiveEnd;
|
|
70
|
+
var endCondition;
|
|
71
|
+
if (end > start) {
|
|
72
|
+
endCondition = inclusiveEnd ? currentYieldingValue > end : currentYieldingValue >= end;
|
|
73
|
+
} else {
|
|
74
|
+
endCondition = inclusiveEnd ? end > currentYieldingValue : end >= currentYieldingValue;
|
|
75
|
+
}
|
|
76
|
+
if (endCondition) {
|
|
77
|
+
return { value: undefined, done: state.hitsEnd = true };
|
|
78
|
+
} return { value: currentYieldingValue, done: false };
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
var getter = function (fn) {
|
|
82
|
+
return { get: fn, set: function () { /* empty */ }, configurable: true, enumerable: false };
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (DESCRIPTORS) {
|
|
86
|
+
defineProperties($RangeIterator.prototype, {
|
|
87
|
+
start: getter(function () {
|
|
88
|
+
return getInternalState(this).start;
|
|
89
|
+
}),
|
|
90
|
+
end: getter(function () {
|
|
91
|
+
return getInternalState(this).end;
|
|
92
|
+
}),
|
|
93
|
+
inclusive: getter(function () {
|
|
94
|
+
return getInternalState(this).inclusiveEnd;
|
|
95
|
+
}),
|
|
96
|
+
step: getter(function () {
|
|
97
|
+
return getInternalState(this).step;
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = $RangeIterator;
|
package/internals/redefine.js
CHANGED
|
@@ -13,9 +13,15 @@ var TEMPLATE = String(String).split('String');
|
|
|
13
13
|
var unsafe = options ? !!options.unsafe : false;
|
|
14
14
|
var simple = options ? !!options.enumerable : false;
|
|
15
15
|
var noTargetGet = options ? !!options.noTargetGet : false;
|
|
16
|
+
var state;
|
|
16
17
|
if (typeof value == 'function') {
|
|
17
|
-
if (typeof key == 'string' && !has(value, 'name'))
|
|
18
|
-
|
|
18
|
+
if (typeof key == 'string' && !has(value, 'name')) {
|
|
19
|
+
createNonEnumerableProperty(value, 'name', key);
|
|
20
|
+
}
|
|
21
|
+
state = enforceInternalState(value);
|
|
22
|
+
if (!state.source) {
|
|
23
|
+
state.source = TEMPLATE.join(typeof key == 'string' ? key : '');
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
if (O === global) {
|
|
21
27
|
if (simple) O[key] = value;
|
package/internals/shared.js
CHANGED
|
@@ -4,7 +4,7 @@ var store = require('../internals/shared-store');
|
|
|
4
4
|
(module.exports = function (key, value) {
|
|
5
5
|
return store[key] || (store[key] = value !== undefined ? value : {});
|
|
6
6
|
})('versions', []).push({
|
|
7
|
-
version: '3.
|
|
7
|
+
version: '3.8.0',
|
|
8
8
|
mode: IS_PURE ? 'pure' : 'global',
|
|
9
9
|
copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
|
|
10
10
|
});
|
package/internals/task.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var global = require('../internals/global');
|
|
2
2
|
var fails = require('../internals/fails');
|
|
3
|
-
var classof = require('../internals/classof-raw');
|
|
4
3
|
var bind = require('../internals/function-bind-context');
|
|
5
4
|
var html = require('../internals/html');
|
|
6
5
|
var createElement = require('../internals/document-create-element');
|
|
7
6
|
var IS_IOS = require('../internals/engine-is-ios');
|
|
7
|
+
var IS_NODE = require('../internals/engine-is-node');
|
|
8
8
|
|
|
9
9
|
var location = global.location;
|
|
10
10
|
var set = global.setImmediate;
|
|
@@ -58,7 +58,7 @@ if (!set || !clear) {
|
|
|
58
58
|
delete queue[id];
|
|
59
59
|
};
|
|
60
60
|
// Node.js 0.8-
|
|
61
|
-
if (
|
|
61
|
+
if (IS_NODE) {
|
|
62
62
|
defer = function (id) {
|
|
63
63
|
process.nextTick(runner(id));
|
|
64
64
|
};
|
|
@@ -76,7 +76,13 @@ if (!set || !clear) {
|
|
|
76
76
|
defer = bind(port.postMessage, port, 1);
|
|
77
77
|
// Browsers with postMessage, skip WebWorkers
|
|
78
78
|
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
|
|
79
|
-
} else if (
|
|
79
|
+
} else if (
|
|
80
|
+
global.addEventListener &&
|
|
81
|
+
typeof postMessage == 'function' &&
|
|
82
|
+
!global.importScripts &&
|
|
83
|
+
location && location.protocol !== 'file:' &&
|
|
84
|
+
!fails(post)
|
|
85
|
+
) {
|
|
80
86
|
defer = post;
|
|
81
87
|
global.addEventListener('message', listener, false);
|
|
82
88
|
// IE8-
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var getPrototypeOf = require('../internals/object-get-prototype-of');
|
|
4
|
+
var setPrototypeOf = require('../internals/object-set-prototype-of');
|
|
5
|
+
var create = require('../internals/object-create');
|
|
6
|
+
var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
|
|
7
|
+
var createPropertyDescriptor = require('../internals/create-property-descriptor');
|
|
8
|
+
var iterate = require('../internals/iterate');
|
|
9
|
+
|
|
10
|
+
var $AggregateError = function AggregateError(errors, message) {
|
|
11
|
+
var that = this;
|
|
12
|
+
if (!(that instanceof $AggregateError)) return new $AggregateError(errors, message);
|
|
13
|
+
if (setPrototypeOf) {
|
|
14
|
+
that = setPrototypeOf(new Error(undefined), getPrototypeOf(that));
|
|
15
|
+
}
|
|
16
|
+
if (message !== undefined) createNonEnumerableProperty(that, 'message', String(message));
|
|
17
|
+
var errorsArray = [];
|
|
18
|
+
iterate(errors, errorsArray.push, { that: errorsArray });
|
|
19
|
+
createNonEnumerableProperty(that, 'errors', errorsArray);
|
|
20
|
+
return that;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
$AggregateError.prototype = create(Error.prototype, {
|
|
24
|
+
constructor: createPropertyDescriptor(5, $AggregateError),
|
|
25
|
+
message: createPropertyDescriptor(5, ''),
|
|
26
|
+
name: createPropertyDescriptor(5, 'AggregateError')
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
$({ global: true }, {
|
|
30
|
+
AggregateError: $AggregateError
|
|
31
|
+
});
|
|
@@ -3,13 +3,19 @@ var $ = require('../internals/export');
|
|
|
3
3
|
var $reduceRight = require('../internals/array-reduce').right;
|
|
4
4
|
var arrayMethodIsStrict = require('../internals/array-method-is-strict');
|
|
5
5
|
var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
|
|
6
|
+
var CHROME_VERSION = require('../internals/engine-v8-version');
|
|
7
|
+
var IS_NODE = require('../internals/engine-is-node');
|
|
6
8
|
|
|
7
9
|
var STRICT_METHOD = arrayMethodIsStrict('reduceRight');
|
|
8
|
-
|
|
10
|
+
// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method
|
|
11
|
+
var USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 });
|
|
12
|
+
// Chrome 80-82 has a critical bug
|
|
13
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
|
|
14
|
+
var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
|
|
9
15
|
|
|
10
16
|
// `Array.prototype.reduceRight` method
|
|
11
17
|
// https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
|
|
12
|
-
$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {
|
|
18
|
+
$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH || CHROME_BUG }, {
|
|
13
19
|
reduceRight: function reduceRight(callbackfn /* , initialValue */) {
|
|
14
20
|
return $reduceRight(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
|
|
15
21
|
}
|
|
@@ -3,13 +3,18 @@ var $ = require('../internals/export');
|
|
|
3
3
|
var $reduce = require('../internals/array-reduce').left;
|
|
4
4
|
var arrayMethodIsStrict = require('../internals/array-method-is-strict');
|
|
5
5
|
var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
|
|
6
|
+
var CHROME_VERSION = require('../internals/engine-v8-version');
|
|
7
|
+
var IS_NODE = require('../internals/engine-is-node');
|
|
6
8
|
|
|
7
9
|
var STRICT_METHOD = arrayMethodIsStrict('reduce');
|
|
8
10
|
var USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 });
|
|
11
|
+
// Chrome 80-82 has a critical bug
|
|
12
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
|
|
13
|
+
var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
|
|
9
14
|
|
|
10
15
|
// `Array.prototype.reduce` method
|
|
11
16
|
// https://tc39.github.io/ecma262/#sec-array.prototype.reduce
|
|
12
|
-
$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {
|
|
17
|
+
$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH || CHROME_BUG }, {
|
|
13
18
|
reduce: function reduce(callbackfn /* , initialValue */) {
|
|
14
19
|
return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
|
|
15
20
|
}
|
|
@@ -28,10 +28,10 @@ $({ target: 'Promise', stat: true }, {
|
|
|
28
28
|
alreadyCalled = true;
|
|
29
29
|
values[index] = { status: 'fulfilled', value: value };
|
|
30
30
|
--remaining || resolve(values);
|
|
31
|
-
}, function (
|
|
31
|
+
}, function (error) {
|
|
32
32
|
if (alreadyCalled) return;
|
|
33
33
|
alreadyCalled = true;
|
|
34
|
-
values[index] = { status: 'rejected', reason:
|
|
34
|
+
values[index] = { status: 'rejected', reason: error };
|
|
35
35
|
--remaining || resolve(values);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var aFunction = require('../internals/a-function');
|
|
4
|
+
var getBuiltIn = require('../internals/get-built-in');
|
|
5
|
+
var newPromiseCapabilityModule = require('../internals/new-promise-capability');
|
|
6
|
+
var perform = require('../internals/perform');
|
|
7
|
+
var iterate = require('../internals/iterate');
|
|
8
|
+
|
|
9
|
+
var PROMISE_ANY_ERROR = 'No one promise resolved';
|
|
10
|
+
|
|
11
|
+
// `Promise.any` method
|
|
12
|
+
// https://github.com/tc39/proposal-promise-any
|
|
13
|
+
$({ target: 'Promise', stat: true }, {
|
|
14
|
+
any: function any(iterable) {
|
|
15
|
+
var C = this;
|
|
16
|
+
var capability = newPromiseCapabilityModule.f(C);
|
|
17
|
+
var resolve = capability.resolve;
|
|
18
|
+
var reject = capability.reject;
|
|
19
|
+
var result = perform(function () {
|
|
20
|
+
var promiseResolve = aFunction(C.resolve);
|
|
21
|
+
var errors = [];
|
|
22
|
+
var counter = 0;
|
|
23
|
+
var remaining = 1;
|
|
24
|
+
var alreadyResolved = false;
|
|
25
|
+
iterate(iterable, function (promise) {
|
|
26
|
+
var index = counter++;
|
|
27
|
+
var alreadyRejected = false;
|
|
28
|
+
errors.push(undefined);
|
|
29
|
+
remaining++;
|
|
30
|
+
promiseResolve.call(C, promise).then(function (value) {
|
|
31
|
+
if (alreadyRejected || alreadyResolved) return;
|
|
32
|
+
alreadyResolved = true;
|
|
33
|
+
resolve(value);
|
|
34
|
+
}, function (error) {
|
|
35
|
+
if (alreadyRejected || alreadyResolved) return;
|
|
36
|
+
alreadyRejected = true;
|
|
37
|
+
errors[index] = error;
|
|
38
|
+
--remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
--remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
|
|
42
|
+
});
|
|
43
|
+
if (result.error) reject(result.value);
|
|
44
|
+
return capability.promise;
|
|
45
|
+
}
|
|
46
|
+
});
|