core-js 3.41.0 → 3.42.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/internals/a-weak-key.js +12 -0
- package/internals/async-from-sync-iterator.js +15 -4
- package/internals/iterator-helper-without-closing-on-early-error.js +23 -0
- package/internals/iterator-indexed.js +2 -1
- package/internals/set-method-accept-set-like.js +3 -1
- package/internals/shared-store.js +2 -2
- package/modules/es.iterator.drop.js +14 -2
- package/modules/es.iterator.every.js +14 -2
- package/modules/es.iterator.filter.js +13 -2
- package/modules/es.iterator.find.js +14 -2
- package/modules/es.iterator.flat-map.js +12 -2
- package/modules/es.iterator.for-each.js +14 -2
- package/modules/es.iterator.map.js +32 -3
- package/modules/es.iterator.reduce.js +23 -3
- package/modules/es.iterator.some.js +14 -2
- package/modules/es.iterator.take.js +13 -2
- package/modules/es.map.group-by.js +1 -0
- package/modules/es.object.group-by.js +1 -0
- package/modules/es.string.match-all.js +2 -2
- package/modules/es.string.match.js +2 -2
- package/modules/es.string.replace-all.js +2 -2
- package/modules/es.string.replace.js +2 -2
- package/modules/es.string.search.js +2 -2
- package/modules/es.string.split.js +2 -2
- package/modules/esnext.async-iterator.drop.js +1 -2
- package/modules/esnext.async-iterator.every.js +1 -1
- package/modules/esnext.async-iterator.filter.js +1 -2
- package/modules/esnext.async-iterator.find.js +1 -1
- package/modules/esnext.async-iterator.flat-map.js +1 -2
- package/modules/esnext.async-iterator.for-each.js +1 -1
- package/modules/esnext.async-iterator.from.js +1 -2
- package/modules/esnext.async-iterator.map.js +1 -2
- package/modules/esnext.async-iterator.reduce.js +1 -1
- package/modules/esnext.async-iterator.some.js +1 -1
- package/modules/esnext.async-iterator.take.js +1 -2
- package/modules/esnext.async-iterator.to-array.js +1 -1
- package/modules/esnext.iterator.to-async.js +1 -2
- package/modules/esnext.json.is-raw-json.js +1 -1
- package/modules/esnext.json.raw-json.js +2 -2
- package/modules/esnext.uint8-array.set-from-base64.js +10 -1
- package/modules/esnext.weak-map.get-or-insert-computed.js +2 -1
- package/package.json +1 -1
- package/stage/2.7.js +1 -0
- package/stage/2.js +0 -1
- package/internals/iterator-map.js +0 -24
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var WeakMapHelpers = require('../internals/weak-map-helpers');
|
|
3
|
+
|
|
4
|
+
var weakmap = new WeakMapHelpers.WeakMap();
|
|
5
|
+
var set = WeakMapHelpers.set;
|
|
6
|
+
var remove = WeakMapHelpers.remove;
|
|
7
|
+
|
|
8
|
+
module.exports = function (key) {
|
|
9
|
+
set(weakmap, key, 1);
|
|
10
|
+
remove(weakmap, key);
|
|
11
|
+
return key;
|
|
12
|
+
};
|
|
@@ -5,6 +5,7 @@ var create = require('../internals/object-create');
|
|
|
5
5
|
var getMethod = require('../internals/get-method');
|
|
6
6
|
var defineBuiltIns = require('../internals/define-built-ins');
|
|
7
7
|
var InternalStateModule = require('../internals/internal-state');
|
|
8
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
8
9
|
var getBuiltIn = require('../internals/get-built-in');
|
|
9
10
|
var AsyncIteratorPrototype = require('../internals/async-iterator-prototype');
|
|
10
11
|
var createIterResultObject = require('../internals/create-iter-result-object');
|
|
@@ -15,11 +16,21 @@ var ASYNC_FROM_SYNC_ITERATOR = 'AsyncFromSyncIterator';
|
|
|
15
16
|
var setInternalState = InternalStateModule.set;
|
|
16
17
|
var getInternalState = InternalStateModule.getterFor(ASYNC_FROM_SYNC_ITERATOR);
|
|
17
18
|
|
|
18
|
-
var asyncFromSyncIteratorContinuation = function (result, resolve, reject) {
|
|
19
|
+
var asyncFromSyncIteratorContinuation = function (result, resolve, reject, syncIterator, closeOnRejection) {
|
|
19
20
|
var done = result.done;
|
|
20
21
|
Promise.resolve(result.value).then(function (value) {
|
|
21
22
|
resolve(createIterResultObject(value, done));
|
|
22
|
-
},
|
|
23
|
+
}, function (error) {
|
|
24
|
+
if (!done && closeOnRejection) {
|
|
25
|
+
try {
|
|
26
|
+
iteratorClose(syncIterator, 'throw', error);
|
|
27
|
+
} catch (error2) {
|
|
28
|
+
error = error2;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
reject(error);
|
|
33
|
+
});
|
|
23
34
|
};
|
|
24
35
|
|
|
25
36
|
var AsyncFromSyncIterator = function AsyncIterator(iteratorRecord) {
|
|
@@ -32,7 +43,7 @@ AsyncFromSyncIterator.prototype = defineBuiltIns(create(AsyncIteratorPrototype),
|
|
|
32
43
|
var state = getInternalState(this);
|
|
33
44
|
return new Promise(function (resolve, reject) {
|
|
34
45
|
var result = anObject(call(state.next, state.iterator));
|
|
35
|
-
asyncFromSyncIteratorContinuation(result, resolve, reject);
|
|
46
|
+
asyncFromSyncIteratorContinuation(result, resolve, reject, state.iterator, true);
|
|
36
47
|
});
|
|
37
48
|
},
|
|
38
49
|
'return': function () {
|
|
@@ -41,7 +52,7 @@ AsyncFromSyncIterator.prototype = defineBuiltIns(create(AsyncIteratorPrototype),
|
|
|
41
52
|
var $return = getMethod(iterator, 'return');
|
|
42
53
|
if ($return === undefined) return resolve(createIterResultObject(undefined, true));
|
|
43
54
|
var result = anObject(call($return, iterator));
|
|
44
|
-
asyncFromSyncIteratorContinuation(result, resolve, reject);
|
|
55
|
+
asyncFromSyncIteratorContinuation(result, resolve, reject, iterator);
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
58
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var globalThis = require('../internals/global-this');
|
|
3
|
+
|
|
4
|
+
// https://github.com/tc39/ecma262/pull/3467
|
|
5
|
+
module.exports = function (METHOD_NAME, ExpectedError) {
|
|
6
|
+
var Iterator = globalThis.Iterator;
|
|
7
|
+
var IteratorPrototype = Iterator && Iterator.prototype;
|
|
8
|
+
var method = IteratorPrototype && IteratorPrototype[METHOD_NAME];
|
|
9
|
+
|
|
10
|
+
var CLOSED = false;
|
|
11
|
+
|
|
12
|
+
if (method) try {
|
|
13
|
+
method.call({
|
|
14
|
+
next: function () { return { done: true }; },
|
|
15
|
+
'return': function () { CLOSED = true; }
|
|
16
|
+
}, -1);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
// https://bugs.webkit.org/show_bug.cgi?id=291195
|
|
19
|
+
if (!(error instanceof ExpectedError)) CLOSED = false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!CLOSED) return method;
|
|
23
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
require('../modules/es.iterator.map');
|
|
2
3
|
var call = require('../internals/function-call');
|
|
3
|
-
var map = require('../internals/
|
|
4
|
+
var map = require('../internals/iterators-core').IteratorPrototype.map;
|
|
4
5
|
|
|
5
6
|
var callback = function (value, counter) {
|
|
6
7
|
return [counter, value];
|
|
@@ -34,8 +34,10 @@ module.exports = function (name, callback) {
|
|
|
34
34
|
try {
|
|
35
35
|
new Set()[name](createSetLike(0));
|
|
36
36
|
try {
|
|
37
|
-
// late spec change, early WebKit ~ Safari 17
|
|
37
|
+
// late spec change, early WebKit ~ Safari 17 implementation does not pass it
|
|
38
38
|
// https://github.com/tc39/proposal-set-methods/pull/88
|
|
39
|
+
// also covered engines with
|
|
40
|
+
// https://bugs.webkit.org/show_bug.cgi?id=272679
|
|
39
41
|
new Set()[name](createSetLike(-1));
|
|
40
42
|
return false;
|
|
41
43
|
} catch (error2) {
|
|
@@ -7,9 +7,9 @@ var SHARED = '__core-js_shared__';
|
|
|
7
7
|
var store = module.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
|
|
8
8
|
|
|
9
9
|
(store.versions || (store.versions = [])).push({
|
|
10
|
-
version: '3.
|
|
10
|
+
version: '3.42.0',
|
|
11
11
|
mode: IS_PURE ? 'pure' : 'global',
|
|
12
12
|
copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)',
|
|
13
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.
|
|
13
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.42.0/LICENSE',
|
|
14
14
|
source: 'https://github.com/zloirock/core-js'
|
|
15
15
|
});
|
|
@@ -5,9 +5,13 @@ var anObject = require('../internals/an-object');
|
|
|
5
5
|
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
6
6
|
var notANaN = require('../internals/not-a-nan');
|
|
7
7
|
var toPositiveInteger = require('../internals/to-positive-integer');
|
|
8
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
8
9
|
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
|
10
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
9
11
|
var IS_PURE = require('../internals/is-pure');
|
|
10
12
|
|
|
13
|
+
var dropWithoutClosingOnEarlyError = !IS_PURE && iteratorHelperWithoutClosingOnEarlyError('drop', RangeError);
|
|
14
|
+
|
|
11
15
|
var IteratorProxy = createIteratorProxy(function () {
|
|
12
16
|
var iterator = this.iterator;
|
|
13
17
|
var next = this.next;
|
|
@@ -25,10 +29,18 @@ var IteratorProxy = createIteratorProxy(function () {
|
|
|
25
29
|
|
|
26
30
|
// `Iterator.prototype.drop` method
|
|
27
31
|
// https://tc39.es/ecma262/#sec-iterator.prototype.drop
|
|
28
|
-
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
|
|
32
|
+
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE || dropWithoutClosingOnEarlyError }, {
|
|
29
33
|
drop: function drop(limit) {
|
|
30
34
|
anObject(this);
|
|
31
|
-
var remaining
|
|
35
|
+
var remaining;
|
|
36
|
+
try {
|
|
37
|
+
remaining = toPositiveInteger(notANaN(+limit));
|
|
38
|
+
} catch (error) {
|
|
39
|
+
iteratorClose(this, 'throw', error);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (dropWithoutClosingOnEarlyError) return call(dropWithoutClosingOnEarlyError, this, remaining);
|
|
43
|
+
|
|
32
44
|
return new IteratorProxy(getIteratorDirect(this), {
|
|
33
45
|
remaining: remaining
|
|
34
46
|
});
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
|
+
var call = require('../internals/function-call');
|
|
3
4
|
var iterate = require('../internals/iterate');
|
|
4
5
|
var aCallable = require('../internals/a-callable');
|
|
5
6
|
var anObject = require('../internals/an-object');
|
|
6
7
|
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
8
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
9
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
10
|
+
|
|
11
|
+
var everyWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('every', TypeError);
|
|
7
12
|
|
|
8
13
|
// `Iterator.prototype.every` method
|
|
9
14
|
// https://tc39.es/ecma262/#sec-iterator.prototype.every
|
|
10
|
-
$({ target: 'Iterator', proto: true, real: true }, {
|
|
15
|
+
$({ target: 'Iterator', proto: true, real: true, forced: everyWithoutClosingOnEarlyError }, {
|
|
11
16
|
every: function every(predicate) {
|
|
12
17
|
anObject(this);
|
|
13
|
-
|
|
18
|
+
try {
|
|
19
|
+
aCallable(predicate);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
iteratorClose(this, 'throw', error);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (everyWithoutClosingOnEarlyError) return call(everyWithoutClosingOnEarlyError, this, predicate);
|
|
25
|
+
|
|
14
26
|
var record = getIteratorDirect(this);
|
|
15
27
|
var counter = 0;
|
|
16
28
|
return !iterate(record, function (value, stop) {
|
|
@@ -7,6 +7,10 @@ var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
|
7
7
|
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
|
8
8
|
var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
|
|
9
9
|
var IS_PURE = require('../internals/is-pure');
|
|
10
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
11
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
12
|
+
|
|
13
|
+
var filterWithoutClosingOnEarlyError = !IS_PURE && iteratorHelperWithoutClosingOnEarlyError('filter', TypeError);
|
|
10
14
|
|
|
11
15
|
var IteratorProxy = createIteratorProxy(function () {
|
|
12
16
|
var iterator = this.iterator;
|
|
@@ -24,10 +28,17 @@ var IteratorProxy = createIteratorProxy(function () {
|
|
|
24
28
|
|
|
25
29
|
// `Iterator.prototype.filter` method
|
|
26
30
|
// https://tc39.es/ecma262/#sec-iterator.prototype.filter
|
|
27
|
-
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
|
|
31
|
+
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE || filterWithoutClosingOnEarlyError }, {
|
|
28
32
|
filter: function filter(predicate) {
|
|
29
33
|
anObject(this);
|
|
30
|
-
|
|
34
|
+
try {
|
|
35
|
+
aCallable(predicate);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
iteratorClose(this, 'throw', error);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (filterWithoutClosingOnEarlyError) return call(filterWithoutClosingOnEarlyError, this, predicate);
|
|
41
|
+
|
|
31
42
|
return new IteratorProxy(getIteratorDirect(this), {
|
|
32
43
|
predicate: predicate
|
|
33
44
|
});
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
|
+
var call = require('../internals/function-call');
|
|
3
4
|
var iterate = require('../internals/iterate');
|
|
4
5
|
var aCallable = require('../internals/a-callable');
|
|
5
6
|
var anObject = require('../internals/an-object');
|
|
6
7
|
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
8
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
9
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
10
|
+
|
|
11
|
+
var findWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('find', TypeError);
|
|
7
12
|
|
|
8
13
|
// `Iterator.prototype.find` method
|
|
9
14
|
// https://tc39.es/ecma262/#sec-iterator.prototype.find
|
|
10
|
-
$({ target: 'Iterator', proto: true, real: true }, {
|
|
15
|
+
$({ target: 'Iterator', proto: true, real: true, forced: findWithoutClosingOnEarlyError }, {
|
|
11
16
|
find: function find(predicate) {
|
|
12
17
|
anObject(this);
|
|
13
|
-
|
|
18
|
+
try {
|
|
19
|
+
aCallable(predicate);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
iteratorClose(this, 'throw', error);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (findWithoutClosingOnEarlyError) return call(findWithoutClosingOnEarlyError, this, predicate);
|
|
25
|
+
|
|
14
26
|
var record = getIteratorDirect(this);
|
|
15
27
|
var counter = 0;
|
|
16
28
|
return iterate(record, function (value, stop) {
|
|
@@ -8,6 +8,9 @@ var getIteratorFlattenable = require('../internals/get-iterator-flattenable');
|
|
|
8
8
|
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
|
9
9
|
var iteratorClose = require('../internals/iterator-close');
|
|
10
10
|
var IS_PURE = require('../internals/is-pure');
|
|
11
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
12
|
+
|
|
13
|
+
var flatMapWithoutClosingOnEarlyError = !IS_PURE && iteratorHelperWithoutClosingOnEarlyError('flatMap', TypeError);
|
|
11
14
|
|
|
12
15
|
var IteratorProxy = createIteratorProxy(function () {
|
|
13
16
|
var iterator = this.iterator;
|
|
@@ -33,10 +36,17 @@ var IteratorProxy = createIteratorProxy(function () {
|
|
|
33
36
|
|
|
34
37
|
// `Iterator.prototype.flatMap` method
|
|
35
38
|
// https://tc39.es/ecma262/#sec-iterator.prototype.flatmap
|
|
36
|
-
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
|
|
39
|
+
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE || flatMapWithoutClosingOnEarlyError }, {
|
|
37
40
|
flatMap: function flatMap(mapper) {
|
|
38
41
|
anObject(this);
|
|
39
|
-
|
|
42
|
+
try {
|
|
43
|
+
aCallable(mapper);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
iteratorClose(this, 'throw', error);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (flatMapWithoutClosingOnEarlyError) return call(flatMapWithoutClosingOnEarlyError, this, mapper);
|
|
49
|
+
|
|
40
50
|
return new IteratorProxy(getIteratorDirect(this), {
|
|
41
51
|
mapper: mapper,
|
|
42
52
|
inner: null
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
|
+
var call = require('../internals/function-call');
|
|
3
4
|
var iterate = require('../internals/iterate');
|
|
4
5
|
var aCallable = require('../internals/a-callable');
|
|
5
6
|
var anObject = require('../internals/an-object');
|
|
6
7
|
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
8
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
9
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
10
|
+
|
|
11
|
+
var forEachWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('forEach', TypeError);
|
|
7
12
|
|
|
8
13
|
// `Iterator.prototype.forEach` method
|
|
9
14
|
// https://tc39.es/ecma262/#sec-iterator.prototype.foreach
|
|
10
|
-
$({ target: 'Iterator', proto: true, real: true }, {
|
|
15
|
+
$({ target: 'Iterator', proto: true, real: true, forced: forEachWithoutClosingOnEarlyError }, {
|
|
11
16
|
forEach: function forEach(fn) {
|
|
12
17
|
anObject(this);
|
|
13
|
-
|
|
18
|
+
try {
|
|
19
|
+
aCallable(fn);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
iteratorClose(this, 'throw', error);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (forEachWithoutClosingOnEarlyError) return call(forEachWithoutClosingOnEarlyError, this, fn);
|
|
25
|
+
|
|
14
26
|
var record = getIteratorDirect(this);
|
|
15
27
|
var counter = 0;
|
|
16
28
|
iterate(record, function (value) {
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
|
-
var
|
|
3
|
+
var call = require('../internals/function-call');
|
|
4
|
+
var aCallable = require('../internals/a-callable');
|
|
5
|
+
var anObject = require('../internals/an-object');
|
|
6
|
+
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
7
|
+
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
|
8
|
+
var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
|
|
9
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
10
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
4
11
|
var IS_PURE = require('../internals/is-pure');
|
|
5
12
|
|
|
13
|
+
var mapWithoutClosingOnEarlyError = !IS_PURE && iteratorHelperWithoutClosingOnEarlyError('map', TypeError);
|
|
14
|
+
|
|
15
|
+
var IteratorProxy = createIteratorProxy(function () {
|
|
16
|
+
var iterator = this.iterator;
|
|
17
|
+
var result = anObject(call(this.next, iterator));
|
|
18
|
+
var done = this.done = !!result.done;
|
|
19
|
+
if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true);
|
|
20
|
+
});
|
|
21
|
+
|
|
6
22
|
// `Iterator.prototype.map` method
|
|
7
23
|
// https://tc39.es/ecma262/#sec-iterator.prototype.map
|
|
8
|
-
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
|
|
9
|
-
map: map
|
|
24
|
+
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE || mapWithoutClosingOnEarlyError }, {
|
|
25
|
+
map: function map(mapper) {
|
|
26
|
+
anObject(this);
|
|
27
|
+
try {
|
|
28
|
+
aCallable(mapper);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
iteratorClose(this, 'throw', error);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (mapWithoutClosingOnEarlyError) return call(mapWithoutClosingOnEarlyError, this, mapper);
|
|
34
|
+
|
|
35
|
+
return new IteratorProxy(getIteratorDirect(this), {
|
|
36
|
+
mapper: mapper
|
|
37
|
+
});
|
|
38
|
+
}
|
|
10
39
|
});
|
|
@@ -4,18 +4,38 @@ var iterate = require('../internals/iterate');
|
|
|
4
4
|
var aCallable = require('../internals/a-callable');
|
|
5
5
|
var anObject = require('../internals/an-object');
|
|
6
6
|
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
7
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
8
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
9
|
+
var apply = require('../internals/function-apply');
|
|
10
|
+
var fails = require('../internals/fails');
|
|
7
11
|
|
|
8
12
|
var $TypeError = TypeError;
|
|
9
13
|
|
|
14
|
+
// https://bugs.webkit.org/show_bug.cgi?id=291651
|
|
15
|
+
var FAILS_ON_INITIAL_UNDEFINED = fails(function () {
|
|
16
|
+
// eslint-disable-next-line es/no-iterator-prototype-reduce, es/no-array-prototype-keys, array-callback-return -- required for testing
|
|
17
|
+
[].keys().reduce(function () { /* empty */ }, undefined);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var reduceWithoutClosingOnEarlyError = !FAILS_ON_INITIAL_UNDEFINED && iteratorHelperWithoutClosingOnEarlyError('reduce', $TypeError);
|
|
21
|
+
|
|
10
22
|
// `Iterator.prototype.reduce` method
|
|
11
23
|
// https://tc39.es/ecma262/#sec-iterator.prototype.reduce
|
|
12
|
-
$({ target: 'Iterator', proto: true, real: true }, {
|
|
24
|
+
$({ target: 'Iterator', proto: true, real: true, forced: FAILS_ON_INITIAL_UNDEFINED || reduceWithoutClosingOnEarlyError }, {
|
|
13
25
|
reduce: function reduce(reducer /* , initialValue */) {
|
|
14
26
|
anObject(this);
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
try {
|
|
28
|
+
aCallable(reducer);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
iteratorClose(this, 'throw', error);
|
|
31
|
+
}
|
|
32
|
+
|
|
17
33
|
var noInitial = arguments.length < 2;
|
|
18
34
|
var accumulator = noInitial ? undefined : arguments[1];
|
|
35
|
+
if (reduceWithoutClosingOnEarlyError) {
|
|
36
|
+
return apply(reduceWithoutClosingOnEarlyError, this, noInitial ? [reducer] : [reducer, accumulator]);
|
|
37
|
+
}
|
|
38
|
+
var record = getIteratorDirect(this);
|
|
19
39
|
var counter = 0;
|
|
20
40
|
iterate(record, function (value) {
|
|
21
41
|
if (noInitial) {
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
|
+
var call = require('../internals/function-call');
|
|
3
4
|
var iterate = require('../internals/iterate');
|
|
4
5
|
var aCallable = require('../internals/a-callable');
|
|
5
6
|
var anObject = require('../internals/an-object');
|
|
6
7
|
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
8
|
+
var iteratorClose = require('../internals/iterator-close');
|
|
9
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
10
|
+
|
|
11
|
+
var someWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('some', TypeError);
|
|
7
12
|
|
|
8
13
|
// `Iterator.prototype.some` method
|
|
9
14
|
// https://tc39.es/ecma262/#sec-iterator.prototype.some
|
|
10
|
-
$({ target: 'Iterator', proto: true, real: true }, {
|
|
15
|
+
$({ target: 'Iterator', proto: true, real: true, forced: someWithoutClosingOnEarlyError }, {
|
|
11
16
|
some: function some(predicate) {
|
|
12
17
|
anObject(this);
|
|
13
|
-
|
|
18
|
+
try {
|
|
19
|
+
aCallable(predicate);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
iteratorClose(this, 'throw', error);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (someWithoutClosingOnEarlyError) return call(someWithoutClosingOnEarlyError, this, predicate);
|
|
25
|
+
|
|
14
26
|
var record = getIteratorDirect(this);
|
|
15
27
|
var counter = 0;
|
|
16
28
|
return iterate(record, function (value, stop) {
|
|
@@ -7,8 +7,11 @@ var notANaN = require('../internals/not-a-nan');
|
|
|
7
7
|
var toPositiveInteger = require('../internals/to-positive-integer');
|
|
8
8
|
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
|
9
9
|
var iteratorClose = require('../internals/iterator-close');
|
|
10
|
+
var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error');
|
|
10
11
|
var IS_PURE = require('../internals/is-pure');
|
|
11
12
|
|
|
13
|
+
var takeWithoutClosingOnEarlyError = !IS_PURE && iteratorHelperWithoutClosingOnEarlyError('take', RangeError);
|
|
14
|
+
|
|
12
15
|
var IteratorProxy = createIteratorProxy(function () {
|
|
13
16
|
var iterator = this.iterator;
|
|
14
17
|
if (!this.remaining--) {
|
|
@@ -22,10 +25,18 @@ var IteratorProxy = createIteratorProxy(function () {
|
|
|
22
25
|
|
|
23
26
|
// `Iterator.prototype.take` method
|
|
24
27
|
// https://tc39.es/ecma262/#sec-iterator.prototype.take
|
|
25
|
-
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
|
|
28
|
+
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE || takeWithoutClosingOnEarlyError }, {
|
|
26
29
|
take: function take(limit) {
|
|
27
30
|
anObject(this);
|
|
28
|
-
var remaining
|
|
31
|
+
var remaining;
|
|
32
|
+
try {
|
|
33
|
+
remaining = toPositiveInteger(notANaN(+limit));
|
|
34
|
+
} catch (error) {
|
|
35
|
+
iteratorClose(this, 'throw', error);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (takeWithoutClosingOnEarlyError) return call(takeWithoutClosingOnEarlyError, this, remaining);
|
|
39
|
+
|
|
29
40
|
return new IteratorProxy(getIteratorDirect(this), {
|
|
30
41
|
remaining: remaining
|
|
31
42
|
});
|
|
@@ -14,6 +14,7 @@ var get = MapHelpers.get;
|
|
|
14
14
|
var set = MapHelpers.set;
|
|
15
15
|
var push = uncurryThis([].push);
|
|
16
16
|
|
|
17
|
+
// https://bugs.webkit.org/show_bug.cgi?id=271524
|
|
17
18
|
var DOES_NOT_WORK_WITH_PRIMITIVES = IS_PURE || fails(function () {
|
|
18
19
|
return Map.groupBy('ab', function (it) {
|
|
19
20
|
return it;
|
|
@@ -13,6 +13,7 @@ var nativeGroupBy = Object.groupBy;
|
|
|
13
13
|
var create = getBuiltIn('Object', 'create');
|
|
14
14
|
var push = uncurryThis([].push);
|
|
15
15
|
|
|
16
|
+
// https://bugs.webkit.org/show_bug.cgi?id=271524
|
|
16
17
|
var DOES_NOT_WORK_WITH_PRIMITIVES = !nativeGroupBy || fails(function () {
|
|
17
18
|
return nativeGroupBy('ab', function (it) {
|
|
18
19
|
return it;
|
|
@@ -9,7 +9,7 @@ var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
|
9
9
|
var toLength = require('../internals/to-length');
|
|
10
10
|
var toString = require('../internals/to-string');
|
|
11
11
|
var anObject = require('../internals/an-object');
|
|
12
|
-
var
|
|
12
|
+
var isObject = require('../internals/is-object');
|
|
13
13
|
var classof = require('../internals/classof-raw');
|
|
14
14
|
var isRegExp = require('../internals/is-regexp');
|
|
15
15
|
var getRegExpFlags = require('../internals/regexp-get-flags');
|
|
@@ -83,7 +83,7 @@ $({ target: 'String', proto: true, forced: WORKS_WITH_NON_GLOBAL_REGEX }, {
|
|
|
83
83
|
matchAll: function matchAll(regexp) {
|
|
84
84
|
var O = requireObjectCoercible(this);
|
|
85
85
|
var flags, S, matcher, rx;
|
|
86
|
-
if (
|
|
86
|
+
if (isObject(regexp)) {
|
|
87
87
|
if (isRegExp(regexp)) {
|
|
88
88
|
flags = toString(requireObjectCoercible(getRegExpFlags(regexp)));
|
|
89
89
|
if (!~stringIndexOf(flags, 'g')) throw new $TypeError('`.matchAll` does not allow non-global regexes');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var call = require('../internals/function-call');
|
|
3
3
|
var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
|
|
4
4
|
var anObject = require('../internals/an-object');
|
|
5
|
-
var
|
|
5
|
+
var isObject = require('../internals/is-object');
|
|
6
6
|
var toLength = require('../internals/to-length');
|
|
7
7
|
var toString = require('../internals/to-string');
|
|
8
8
|
var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
@@ -17,7 +17,7 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
|
|
|
17
17
|
// https://tc39.es/ecma262/#sec-string.prototype.match
|
|
18
18
|
function match(regexp) {
|
|
19
19
|
var O = requireObjectCoercible(this);
|
|
20
|
-
var matcher =
|
|
20
|
+
var matcher = isObject(regexp) ? getMethod(regexp, MATCH) : undefined;
|
|
21
21
|
return matcher ? call(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString(O));
|
|
22
22
|
},
|
|
23
23
|
// `RegExp.prototype[@@match]` method
|
|
@@ -4,7 +4,7 @@ var call = require('../internals/function-call');
|
|
|
4
4
|
var uncurryThis = require('../internals/function-uncurry-this');
|
|
5
5
|
var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
6
6
|
var isCallable = require('../internals/is-callable');
|
|
7
|
-
var
|
|
7
|
+
var isObject = require('../internals/is-object');
|
|
8
8
|
var isRegExp = require('../internals/is-regexp');
|
|
9
9
|
var toString = require('../internals/to-string');
|
|
10
10
|
var getMethod = require('../internals/get-method');
|
|
@@ -28,7 +28,7 @@ $({ target: 'String', proto: true }, {
|
|
|
28
28
|
var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, position, replacement;
|
|
29
29
|
var endOfLastMatch = 0;
|
|
30
30
|
var result = '';
|
|
31
|
-
if (
|
|
31
|
+
if (isObject(searchValue)) {
|
|
32
32
|
IS_REG_EXP = isRegExp(searchValue);
|
|
33
33
|
if (IS_REG_EXP) {
|
|
34
34
|
flags = toString(requireObjectCoercible(getRegExpFlags(searchValue)));
|
|
@@ -6,7 +6,7 @@ var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-
|
|
|
6
6
|
var fails = require('../internals/fails');
|
|
7
7
|
var anObject = require('../internals/an-object');
|
|
8
8
|
var isCallable = require('../internals/is-callable');
|
|
9
|
-
var
|
|
9
|
+
var isObject = require('../internals/is-object');
|
|
10
10
|
var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
|
|
11
11
|
var toLength = require('../internals/to-length');
|
|
12
12
|
var toString = require('../internals/to-string');
|
|
@@ -64,7 +64,7 @@ fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNa
|
|
|
64
64
|
// https://tc39.es/ecma262/#sec-string.prototype.replace
|
|
65
65
|
function replace(searchValue, replaceValue) {
|
|
66
66
|
var O = requireObjectCoercible(this);
|
|
67
|
-
var replacer =
|
|
67
|
+
var replacer = isObject(searchValue) ? getMethod(searchValue, REPLACE) : undefined;
|
|
68
68
|
return replacer
|
|
69
69
|
? call(replacer, searchValue, O, replaceValue)
|
|
70
70
|
: call(nativeReplace, toString(O), searchValue, replaceValue);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var call = require('../internals/function-call');
|
|
3
3
|
var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
|
|
4
4
|
var anObject = require('../internals/an-object');
|
|
5
|
-
var
|
|
5
|
+
var isObject = require('../internals/is-object');
|
|
6
6
|
var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
7
7
|
var sameValue = require('../internals/same-value');
|
|
8
8
|
var toString = require('../internals/to-string');
|
|
@@ -16,7 +16,7 @@ fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCal
|
|
|
16
16
|
// https://tc39.es/ecma262/#sec-string.prototype.search
|
|
17
17
|
function search(regexp) {
|
|
18
18
|
var O = requireObjectCoercible(this);
|
|
19
|
-
var searcher =
|
|
19
|
+
var searcher = isObject(regexp) ? getMethod(regexp, SEARCH) : undefined;
|
|
20
20
|
return searcher ? call(searcher, regexp, O) : new RegExp(regexp)[SEARCH](toString(O));
|
|
21
21
|
},
|
|
22
22
|
// `RegExp.prototype[@@search]` method
|
|
@@ -3,7 +3,7 @@ var call = require('../internals/function-call');
|
|
|
3
3
|
var uncurryThis = require('../internals/function-uncurry-this');
|
|
4
4
|
var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
|
|
5
5
|
var anObject = require('../internals/an-object');
|
|
6
|
-
var
|
|
6
|
+
var isObject = require('../internals/is-object');
|
|
7
7
|
var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
8
8
|
var speciesConstructor = require('../internals/species-constructor');
|
|
9
9
|
var advanceStringIndex = require('../internals/advance-string-index');
|
|
@@ -51,7 +51,7 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
|
|
|
51
51
|
// https://tc39.es/ecma262/#sec-string.prototype.split
|
|
52
52
|
function split(separator, limit) {
|
|
53
53
|
var O = requireObjectCoercible(this);
|
|
54
|
-
var splitter =
|
|
54
|
+
var splitter = isObject(separator) ? getMethod(separator, SPLIT) : undefined;
|
|
55
55
|
return splitter
|
|
56
56
|
? call(splitter, separator, O, limit)
|
|
57
57
|
: call(internalSplit, toString(O), separator, limit);
|
|
@@ -7,7 +7,6 @@ var notANaN = require('../internals/not-a-nan');
|
|
|
7
7
|
var toPositiveInteger = require('../internals/to-positive-integer');
|
|
8
8
|
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
|
|
9
9
|
var createIterResultObject = require('../internals/create-iter-result-object');
|
|
10
|
-
var IS_PURE = require('../internals/is-pure');
|
|
11
10
|
|
|
12
11
|
var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
13
12
|
var state = this;
|
|
@@ -40,7 +39,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
|
40
39
|
|
|
41
40
|
// `AsyncIterator.prototype.drop` method
|
|
42
41
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
43
|
-
$({ target: 'AsyncIterator', proto: true, real: true, forced:
|
|
42
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
44
43
|
drop: function drop(limit) {
|
|
45
44
|
anObject(this);
|
|
46
45
|
var remaining = toPositiveInteger(notANaN(+limit));
|
|
@@ -4,7 +4,7 @@ var $every = require('../internals/async-iterator-iteration').every;
|
|
|
4
4
|
|
|
5
5
|
// `AsyncIterator.prototype.every` method
|
|
6
6
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
7
|
-
$({ target: 'AsyncIterator', proto: true, real: true }, {
|
|
7
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
8
8
|
every: function every(predicate) {
|
|
9
9
|
return $every(this, predicate);
|
|
10
10
|
}
|
|
@@ -8,7 +8,6 @@ var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
|
8
8
|
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
|
|
9
9
|
var createIterResultObject = require('../internals/create-iter-result-object');
|
|
10
10
|
var closeAsyncIteration = require('../internals/async-iterator-close');
|
|
11
|
-
var IS_PURE = require('../internals/is-pure');
|
|
12
11
|
|
|
13
12
|
var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
14
13
|
var state = this;
|
|
@@ -56,7 +55,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
|
56
55
|
|
|
57
56
|
// `AsyncIterator.prototype.filter` method
|
|
58
57
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
59
|
-
$({ target: 'AsyncIterator', proto: true, real: true, forced:
|
|
58
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
60
59
|
filter: function filter(predicate) {
|
|
61
60
|
anObject(this);
|
|
62
61
|
aCallable(predicate);
|
|
@@ -4,7 +4,7 @@ var $find = require('../internals/async-iterator-iteration').find;
|
|
|
4
4
|
|
|
5
5
|
// `AsyncIterator.prototype.find` method
|
|
6
6
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
7
|
-
$({ target: 'AsyncIterator', proto: true, real: true }, {
|
|
7
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
8
8
|
find: function find(predicate) {
|
|
9
9
|
return $find(this, predicate);
|
|
10
10
|
}
|
|
@@ -9,7 +9,6 @@ var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy
|
|
|
9
9
|
var createIterResultObject = require('../internals/create-iter-result-object');
|
|
10
10
|
var getAsyncIteratorFlattenable = require('../internals/get-async-iterator-flattenable');
|
|
11
11
|
var closeAsyncIteration = require('../internals/async-iterator-close');
|
|
12
|
-
var IS_PURE = require('../internals/is-pure');
|
|
13
12
|
|
|
14
13
|
var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
15
14
|
var state = this;
|
|
@@ -76,7 +75,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
|
76
75
|
|
|
77
76
|
// `AsyncIterator.prototype.flatMap` method
|
|
78
77
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
79
|
-
$({ target: 'AsyncIterator', proto: true, real: true, forced:
|
|
78
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
80
79
|
flatMap: function flatMap(mapper) {
|
|
81
80
|
anObject(this);
|
|
82
81
|
aCallable(mapper);
|
|
@@ -4,7 +4,7 @@ var $forEach = require('../internals/async-iterator-iteration').forEach;
|
|
|
4
4
|
|
|
5
5
|
// `AsyncIterator.prototype.forEach` method
|
|
6
6
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
7
|
-
$({ target: 'AsyncIterator', proto: true, real: true }, {
|
|
7
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
8
8
|
forEach: function forEach(fn) {
|
|
9
9
|
return $forEach(this, fn);
|
|
10
10
|
}
|
|
@@ -5,11 +5,10 @@ var isPrototypeOf = require('../internals/object-is-prototype-of');
|
|
|
5
5
|
var getAsyncIteratorFlattenable = require('../internals/get-async-iterator-flattenable');
|
|
6
6
|
var AsyncIteratorPrototype = require('../internals/async-iterator-prototype');
|
|
7
7
|
var WrapAsyncIterator = require('../internals/async-iterator-wrap');
|
|
8
|
-
var IS_PURE = require('../internals/is-pure');
|
|
9
8
|
|
|
10
9
|
// `AsyncIterator.from` method
|
|
11
10
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
12
|
-
$({ target: 'AsyncIterator', stat: true, forced:
|
|
11
|
+
$({ target: 'AsyncIterator', stat: true, forced: true }, {
|
|
13
12
|
from: function from(O) {
|
|
14
13
|
var iteratorRecord = getAsyncIteratorFlattenable(typeof O == 'string' ? toObject(O) : O);
|
|
15
14
|
return isPrototypeOf(AsyncIteratorPrototype, iteratorRecord.iterator)
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
3
|
var map = require('../internals/async-iterator-map');
|
|
4
|
-
var IS_PURE = require('../internals/is-pure');
|
|
5
4
|
|
|
6
5
|
// `AsyncIterator.prototype.map` method
|
|
7
6
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
8
|
-
$({ target: 'AsyncIterator', proto: true, real: true, forced:
|
|
7
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
9
8
|
map: map
|
|
10
9
|
});
|
|
11
10
|
|
|
@@ -13,7 +13,7 @@ var $TypeError = TypeError;
|
|
|
13
13
|
|
|
14
14
|
// `AsyncIterator.prototype.reduce` method
|
|
15
15
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
16
|
-
$({ target: 'AsyncIterator', proto: true, real: true }, {
|
|
16
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
17
17
|
reduce: function reduce(reducer /* , initialValue */) {
|
|
18
18
|
anObject(this);
|
|
19
19
|
aCallable(reducer);
|
|
@@ -4,7 +4,7 @@ var $some = require('../internals/async-iterator-iteration').some;
|
|
|
4
4
|
|
|
5
5
|
// `AsyncIterator.prototype.some` method
|
|
6
6
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
7
|
-
$({ target: 'AsyncIterator', proto: true, real: true }, {
|
|
7
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
8
8
|
some: function some(predicate) {
|
|
9
9
|
return $some(this, predicate);
|
|
10
10
|
}
|
|
@@ -7,7 +7,6 @@ var notANaN = require('../internals/not-a-nan');
|
|
|
7
7
|
var toPositiveInteger = require('../internals/to-positive-integer');
|
|
8
8
|
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
|
|
9
9
|
var createIterResultObject = require('../internals/create-iter-result-object');
|
|
10
|
-
var IS_PURE = require('../internals/is-pure');
|
|
11
10
|
|
|
12
11
|
var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
13
12
|
var state = this;
|
|
@@ -37,7 +36,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
|
37
36
|
|
|
38
37
|
// `AsyncIterator.prototype.take` method
|
|
39
38
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
40
|
-
$({ target: 'AsyncIterator', proto: true, real: true, forced:
|
|
39
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
41
40
|
take: function take(limit) {
|
|
42
41
|
anObject(this);
|
|
43
42
|
var remaining = toPositiveInteger(notANaN(+limit));
|
|
@@ -4,7 +4,7 @@ var $toArray = require('../internals/async-iterator-iteration').toArray;
|
|
|
4
4
|
|
|
5
5
|
// `AsyncIterator.prototype.toArray` method
|
|
6
6
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
7
|
-
$({ target: 'AsyncIterator', proto: true, real: true }, {
|
|
7
|
+
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, {
|
|
8
8
|
toArray: function toArray() {
|
|
9
9
|
return $toArray(this, undefined, []);
|
|
10
10
|
}
|
|
@@ -4,11 +4,10 @@ var anObject = require('../internals/an-object');
|
|
|
4
4
|
var AsyncFromSyncIterator = require('../internals/async-from-sync-iterator');
|
|
5
5
|
var WrapAsyncIterator = require('../internals/async-iterator-wrap');
|
|
6
6
|
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
7
|
-
var IS_PURE = require('../internals/is-pure');
|
|
8
7
|
|
|
9
8
|
// `Iterator.prototype.toAsync` method
|
|
10
9
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
11
|
-
$({ target: 'Iterator', proto: true, real: true, forced:
|
|
10
|
+
$({ target: 'Iterator', proto: true, real: true, forced: true }, {
|
|
12
11
|
toAsync: function toAsync() {
|
|
13
12
|
return new WrapAsyncIterator(getIteratorDirect(new AsyncFromSyncIterator(getIteratorDirect(anObject(this)))));
|
|
14
13
|
}
|
|
@@ -3,7 +3,7 @@ var $ = require('../internals/export');
|
|
|
3
3
|
var NATIVE_RAW_JSON = require('../internals/native-raw-json');
|
|
4
4
|
var isRawJSON = require('../internals/is-raw-json');
|
|
5
5
|
|
|
6
|
-
// `JSON.
|
|
6
|
+
// `JSON.isRawJSON` method
|
|
7
7
|
// https://tc39.es/proposal-json-parse-with-source/#sec-json.israwjson
|
|
8
8
|
// https://github.com/tc39/proposal-json-parse-with-source
|
|
9
9
|
$({ target: 'JSON', stat: true, forced: !NATIVE_RAW_JSON }, {
|
|
@@ -32,8 +32,8 @@ var isWhitespace = function (it) {
|
|
|
32
32
|
return it === ' ' || it === '\t' || it === '\n' || it === '\r';
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
// `JSON.
|
|
36
|
-
// https://tc39.es/proposal-json-parse-with-source/#sec-json.
|
|
35
|
+
// `JSON.rawJSON` method
|
|
36
|
+
// https://tc39.es/proposal-json-parse-with-source/#sec-json.rawjson
|
|
37
37
|
// https://github.com/tc39/proposal-json-parse-with-source
|
|
38
38
|
$({ target: 'JSON', stat: true, forced: !NATIVE_RAW_JSON }, {
|
|
39
39
|
rawJSON: function rawJSON(text) {
|
|
@@ -6,9 +6,18 @@ var anUint8Array = require('../internals/an-uint8-array');
|
|
|
6
6
|
|
|
7
7
|
var Uint8Array = globalThis.Uint8Array;
|
|
8
8
|
|
|
9
|
+
var INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS = !Uint8Array || !Uint8Array.prototype.setFromBase64 || !(function () {
|
|
10
|
+
var target = new Uint8Array([255, 255, 255, 255, 255]);
|
|
11
|
+
try {
|
|
12
|
+
target.setFromBase64('MjYyZg===');
|
|
13
|
+
} catch (error) {
|
|
14
|
+
return target[0] === 50 && target[1] === 54 && target[2] === 50 && target[3] === 255 && target[4] === 255;
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
17
|
+
|
|
9
18
|
// `Uint8Array.prototype.setFromBase64` method
|
|
10
19
|
// https://github.com/tc39/proposal-arraybuffer-base64
|
|
11
|
-
if (Uint8Array) $({ target: 'Uint8Array', proto: true }, {
|
|
20
|
+
if (Uint8Array) $({ target: 'Uint8Array', proto: true, forced: INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS }, {
|
|
12
21
|
setFromBase64: function setFromBase64(string /* , options */) {
|
|
13
22
|
anUint8Array(this);
|
|
14
23
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
3
|
var aCallable = require('../internals/a-callable');
|
|
4
4
|
var aWeakMap = require('../internals/a-weak-map');
|
|
5
|
+
var aWeakKey = require('../internals/a-weak-key');
|
|
5
6
|
var WeakMapHelpers = require('../internals/weak-map-helpers');
|
|
6
7
|
|
|
7
8
|
var get = WeakMapHelpers.get;
|
|
@@ -13,9 +14,9 @@ var set = WeakMapHelpers.set;
|
|
|
13
14
|
$({ target: 'WeakMap', proto: true, real: true, forced: true }, {
|
|
14
15
|
getOrInsertComputed: function getOrInsertComputed(key, callbackfn) {
|
|
15
16
|
aWeakMap(this);
|
|
17
|
+
aWeakKey(key);
|
|
16
18
|
aCallable(callbackfn);
|
|
17
19
|
if (has(this, key)) return get(this, key);
|
|
18
|
-
set(this, key); // key validation
|
|
19
20
|
var value = callbackfn(key);
|
|
20
21
|
set(this, key, value);
|
|
21
22
|
return value;
|
package/package.json
CHANGED
package/stage/2.7.js
CHANGED
package/stage/2.js
CHANGED
|
@@ -5,7 +5,6 @@ require('../proposals/array-is-template-object');
|
|
|
5
5
|
require('../proposals/async-iterator-helpers');
|
|
6
6
|
require('../proposals/extractors');
|
|
7
7
|
require('../proposals/iterator-range');
|
|
8
|
-
require('../proposals/map-upsert-v4');
|
|
9
8
|
require('../proposals/string-dedent');
|
|
10
9
|
require('../proposals/symbol-predicates-v2');
|
|
11
10
|
// TODO: Obsolete versions, remove from `core-js@4`
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var call = require('../internals/function-call');
|
|
3
|
-
var aCallable = require('../internals/a-callable');
|
|
4
|
-
var anObject = require('../internals/an-object');
|
|
5
|
-
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
6
|
-
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
|
7
|
-
var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
|
|
8
|
-
|
|
9
|
-
var IteratorProxy = createIteratorProxy(function () {
|
|
10
|
-
var iterator = this.iterator;
|
|
11
|
-
var result = anObject(call(this.next, iterator));
|
|
12
|
-
var done = this.done = !!result.done;
|
|
13
|
-
if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// `Iterator.prototype.map` method
|
|
17
|
-
// https://github.com/tc39/proposal-iterator-helpers
|
|
18
|
-
module.exports = function map(mapper) {
|
|
19
|
-
anObject(this);
|
|
20
|
-
aCallable(mapper);
|
|
21
|
-
return new IteratorProxy(getIteratorDirect(this), {
|
|
22
|
-
mapper: mapper
|
|
23
|
-
});
|
|
24
|
-
};
|