core-js 3.2.1 → 3.3.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.
Files changed (126) hide show
  1. package/configurator.js +7 -0
  2. package/es/global-this.js +3 -0
  3. package/es/index.js +1 -0
  4. package/features/async-iterator/as-indexed-pairs.js +10 -0
  5. package/features/async-iterator/drop.js +10 -0
  6. package/features/async-iterator/every.js +10 -0
  7. package/features/async-iterator/filter.js +10 -0
  8. package/features/async-iterator/find.js +10 -0
  9. package/features/async-iterator/flat-map.js +10 -0
  10. package/features/async-iterator/for-each.js +10 -0
  11. package/features/async-iterator/from.js +10 -0
  12. package/features/async-iterator/index.js +22 -0
  13. package/features/async-iterator/map.js +10 -0
  14. package/features/async-iterator/reduce.js +10 -0
  15. package/features/async-iterator/some.js +10 -0
  16. package/features/async-iterator/take.js +10 -0
  17. package/features/async-iterator/to-array.js +10 -0
  18. package/features/global-this.js +1 -3
  19. package/features/iterator/as-indexed-pairs.js +10 -0
  20. package/features/iterator/drop.js +9 -0
  21. package/features/iterator/every.js +9 -0
  22. package/features/iterator/filter.js +9 -0
  23. package/features/iterator/find.js +9 -0
  24. package/features/iterator/flat-map.js +9 -0
  25. package/features/iterator/for-each.js +9 -0
  26. package/features/iterator/from.js +9 -0
  27. package/features/iterator/index.js +21 -0
  28. package/features/iterator/map.js +9 -0
  29. package/features/iterator/reduce.js +9 -0
  30. package/features/iterator/some.js +9 -0
  31. package/features/iterator/take.js +9 -0
  32. package/features/iterator/to-array.js +9 -0
  33. package/features/map/index.js +2 -0
  34. package/features/map/update-or-insert.js +1 -0
  35. package/features/map/upsert.js +5 -0
  36. package/features/weak-map/index.js +1 -0
  37. package/features/weak-map/upsert.js +5 -0
  38. package/internals/add-to-unscopables.js +2 -2
  39. package/internals/array-buffer-view-core.js +2 -2
  40. package/internals/array-buffer.js +9 -4
  41. package/internals/array-from.js +3 -2
  42. package/internals/async-iterator-iteration.js +61 -0
  43. package/internals/async-iterator-prototype.js +37 -0
  44. package/internals/create-async-iterator-proxy.js +61 -0
  45. package/internals/create-iterator-proxy.js +51 -0
  46. package/internals/{hide.js → create-non-enumerable-property.js} +0 -0
  47. package/internals/define-iterator.js +3 -3
  48. package/internals/export.js +2 -2
  49. package/internals/fix-regexp-well-known-symbol-logic.js +2 -2
  50. package/internals/get-async-iterator-method.js +9 -0
  51. package/internals/global.js +4 -5
  52. package/internals/internal-state.js +2 -2
  53. package/internals/iterate.js +4 -3
  54. package/internals/iterators-core.js +4 -2
  55. package/internals/map-upsert.js +23 -0
  56. package/internals/microtask.js +1 -1
  57. package/internals/native-url.js +13 -4
  58. package/internals/redefine.js +3 -3
  59. package/internals/set-global.js +2 -2
  60. package/internals/shared-store.js +7 -0
  61. package/internals/shared.js +2 -6
  62. package/internals/task.js +3 -1
  63. package/internals/to-offset.js +3 -3
  64. package/internals/to-positive-integer.js +7 -0
  65. package/internals/typed-array-constructor.js +10 -7
  66. package/internals/typed-array-from.js +3 -2
  67. package/modules/es.date.to-primitive.js +4 -2
  68. package/modules/es.global-this.js +8 -0
  69. package/modules/es.promise.js +2 -1
  70. package/modules/es.string.match-all.js +22 -7
  71. package/modules/es.symbol.js +4 -2
  72. package/modules/esnext.aggregate-error.js +28 -4
  73. package/modules/esnext.async-iterator.as-indexed-pairs.js +27 -0
  74. package/modules/esnext.async-iterator.constructor.js +25 -0
  75. package/modules/esnext.async-iterator.drop.js +41 -0
  76. package/modules/esnext.async-iterator.every.js +10 -0
  77. package/modules/esnext.async-iterator.filter.js +42 -0
  78. package/modules/esnext.async-iterator.find.js +10 -0
  79. package/modules/esnext.async-iterator.flat-map.js +67 -0
  80. package/modules/esnext.async-iterator.for-each.js +10 -0
  81. package/modules/esnext.async-iterator.from.js +30 -0
  82. package/modules/esnext.async-iterator.map.js +30 -0
  83. package/modules/esnext.async-iterator.reduce.js +46 -0
  84. package/modules/esnext.async-iterator.some.js +10 -0
  85. package/modules/esnext.async-iterator.take.js +22 -0
  86. package/modules/esnext.async-iterator.to-array.js +10 -0
  87. package/modules/esnext.global-this.js +2 -8
  88. package/modules/esnext.iterator.as-indexed-pairs.js +20 -0
  89. package/modules/esnext.iterator.constructor.js +39 -0
  90. package/modules/esnext.iterator.drop.js +30 -0
  91. package/modules/esnext.iterator.every.js +16 -0
  92. package/modules/esnext.iterator.filter.js +30 -0
  93. package/modules/esnext.iterator.find.js +16 -0
  94. package/modules/esnext.iterator.flat-map.js +45 -0
  95. package/modules/esnext.iterator.for-each.js +11 -0
  96. package/modules/esnext.iterator.from.js +32 -0
  97. package/modules/esnext.iterator.map.js +23 -0
  98. package/modules/esnext.iterator.reduce.js +25 -0
  99. package/modules/esnext.iterator.some.js +16 -0
  100. package/modules/esnext.iterator.take.js +25 -0
  101. package/modules/esnext.iterator.to-array.js +15 -0
  102. package/modules/esnext.map.reduce.js +9 -8
  103. package/modules/esnext.map.update-or-insert.js +5 -12
  104. package/modules/esnext.map.upsert.js +10 -0
  105. package/modules/esnext.math.signbit.js +0 -1
  106. package/modules/esnext.observable.js +2 -2
  107. package/modules/esnext.set.reduce.js +9 -8
  108. package/modules/esnext.string.match-all.js +0 -1
  109. package/modules/esnext.string.replace-all.js +13 -19
  110. package/modules/esnext.symbol.replace-all.js +1 -2
  111. package/modules/esnext.weak-map.upsert.js +10 -0
  112. package/modules/web.dom-collections.for-each.js +2 -2
  113. package/modules/web.dom-collections.iterator.js +6 -4
  114. package/modules/web.url-search-params.js +7 -5
  115. package/package.json +2 -2
  116. package/postinstall.js +49 -0
  117. package/proposals/iterator-helpers.js +20 -0
  118. package/proposals/map-update-or-insert.js +2 -1
  119. package/proposals/map-upsert.js +5 -0
  120. package/stable/global-this.js +1 -3
  121. package/stage/1.js +0 -1
  122. package/stage/2.js +2 -2
  123. package/stage/3.js +2 -1
  124. package/stage/4.js +1 -0
  125. package/LICENSE +0 -19
  126. package/scripts/postinstall.js +0 -24
@@ -1,10 +1,18 @@
1
+ 'use strict';
1
2
  var $ = require('../internals/export');
3
+ var DESCRIPTORS = require('../internals/descriptors');
2
4
  var getPrototypeOf = require('../internals/object-get-prototype-of');
3
5
  var setPrototypeOf = require('../internals/object-set-prototype-of');
4
6
  var create = require('../internals/object-create');
7
+ var defineProperty = require('../internals/object-define-property');
5
8
  var createPropertyDescriptor = require('../internals/create-property-descriptor');
6
9
  var iterate = require('../internals/iterate');
7
- var hide = require('../internals/hide');
10
+ var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
11
+ var anObject = require('../internals/an-object');
12
+ var InternalStateModule = require('../internals/internal-state');
13
+
14
+ var setInternalState = InternalStateModule.set;
15
+ var getInternalAggregateErrorState = InternalStateModule.getterFor('AggregateError');
8
16
 
9
17
  var $AggregateError = function AggregateError(errors, message) {
10
18
  var that = this;
@@ -14,14 +22,30 @@ var $AggregateError = function AggregateError(errors, message) {
14
22
  }
15
23
  var errorsArray = [];
16
24
  iterate(errors, errorsArray.push, errorsArray);
17
- hide(that, 'errors', errorsArray);
18
- if (message !== undefined) hide(that, 'message', String(message));
25
+ if (DESCRIPTORS) setInternalState(that, { errors: errorsArray, type: 'AggregateError' });
26
+ else that.errors = errorsArray;
27
+ if (message !== undefined) createNonEnumerableProperty(that, 'message', String(message));
19
28
  return that;
20
29
  };
21
30
 
22
31
  $AggregateError.prototype = create(Error.prototype, {
23
32
  constructor: createPropertyDescriptor(5, $AggregateError),
24
- name: createPropertyDescriptor(5, 'AggregateError')
33
+ message: createPropertyDescriptor(5, ''),
34
+ name: createPropertyDescriptor(5, 'AggregateError'),
35
+ toString: createPropertyDescriptor(5, function toString() {
36
+ var name = anObject(this).name;
37
+ name = name === undefined ? 'AggregateError' : String(name);
38
+ var message = this.message;
39
+ message = message === undefined ? '' : String(message);
40
+ return name + ': ' + message;
41
+ })
42
+ });
43
+
44
+ if (DESCRIPTORS) defineProperty.f($AggregateError.prototype, 'errors', {
45
+ get: function () {
46
+ return getInternalAggregateErrorState(this).errors;
47
+ },
48
+ configurable: true
25
49
  });
26
50
 
27
51
  $({ global: true }, {
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var anObject = require('../internals/an-object');
5
+ var createAsyncIteratorProxy = require('../internals/create-async-iterator-proxy');
6
+
7
+ var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg, Promise) {
8
+ var state = this;
9
+ var iterator = state.iterator;
10
+
11
+ return Promise.resolve(anObject(state.next.call(iterator, arg))).then(function (step) {
12
+ if (anObject(step).done) {
13
+ state.done = true;
14
+ return { done: true, value: undefined };
15
+ }
16
+ return { done: false, value: [state.index++, step.value] };
17
+ });
18
+ });
19
+
20
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
21
+ asIndexedPairs: function asIndexedPairs() {
22
+ return new AsyncIteratorProxy({
23
+ iterator: anObject(this),
24
+ index: 0
25
+ });
26
+ }
27
+ });
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var anInstance = require('../internals/an-instance');
5
+ var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
6
+ var has = require('../internals/has');
7
+ var wellKnownSymbol = require('../internals/well-known-symbol');
8
+ var AsyncIteratorPrototype = require('../internals/async-iterator-prototype');
9
+ var IS_PURE = require('../internals/is-pure');
10
+
11
+ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
12
+
13
+ var AsyncIteratorConstructor = function AsyncIterator() {
14
+ anInstance(this, AsyncIteratorConstructor);
15
+ };
16
+
17
+ AsyncIteratorConstructor.prototype = AsyncIteratorPrototype;
18
+
19
+ if (!has(AsyncIteratorPrototype, TO_STRING_TAG)) {
20
+ createNonEnumerableProperty(AsyncIteratorPrototype, TO_STRING_TAG, 'AsyncIterator');
21
+ }
22
+
23
+ $({ global: true, forced: IS_PURE }, {
24
+ AsyncIterator: AsyncIteratorConstructor
25
+ });
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var anObject = require('../internals/an-object');
5
+ var toPositiveInteger = require('../internals/to-positive-integer');
6
+ var createAsyncIteratorProxy = require('../internals/create-async-iterator-proxy');
7
+
8
+ var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg, Promise) {
9
+ var state = this;
10
+
11
+ return new Promise(function (resolve, reject) {
12
+ var loop = function () {
13
+ try {
14
+ Promise.resolve(
15
+ anObject(state.next.call(state.iterator, state.remaining ? undefined : arg))
16
+ ).then(function (step) {
17
+ try {
18
+ if (anObject(step).done) {
19
+ state.done = true;
20
+ resolve({ done: true, value: undefined });
21
+ } else if (state.remaining) {
22
+ state.remaining--;
23
+ loop();
24
+ } else resolve({ done: false, value: step.value });
25
+ } catch (err) { reject(err); }
26
+ }, reject);
27
+ } catch (error) { reject(error); }
28
+ };
29
+
30
+ loop();
31
+ });
32
+ });
33
+
34
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
35
+ drop: function drop(limit) {
36
+ return new AsyncIteratorProxy({
37
+ iterator: anObject(this),
38
+ remaining: toPositiveInteger(limit)
39
+ });
40
+ }
41
+ });
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var $every = require('../internals/async-iterator-iteration').every;
5
+
6
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
7
+ every: function every(fn) {
8
+ return $every(this, fn);
9
+ }
10
+ });
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var aFunction = require('../internals/a-function');
5
+ var anObject = require('../internals/an-object');
6
+ var createAsyncIteratorProxy = require('../internals/create-async-iterator-proxy');
7
+
8
+ var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg, Promise) {
9
+ var state = this;
10
+ var filterer = state.filterer;
11
+
12
+ return new Promise(function (resolve, reject) {
13
+ var loop = function () {
14
+ try {
15
+ Promise.resolve(anObject(state.next.call(state.iterator, arg))).then(function (step) {
16
+ try {
17
+ if (anObject(step).done) {
18
+ state.done = true;
19
+ resolve({ done: true, value: undefined });
20
+ } else {
21
+ var value = step.value;
22
+ Promise.resolve(filterer(value)).then(function (selected) {
23
+ selected ? resolve({ done: false, value: value }) : loop();
24
+ }, reject);
25
+ }
26
+ } catch (err) { reject(err); }
27
+ }, reject);
28
+ } catch (error) { reject(error); }
29
+ };
30
+
31
+ loop();
32
+ });
33
+ });
34
+
35
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
36
+ filter: function filter(filterer) {
37
+ return new AsyncIteratorProxy({
38
+ iterator: anObject(this),
39
+ filterer: aFunction(filterer)
40
+ });
41
+ }
42
+ });
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var $find = require('../internals/async-iterator-iteration').find;
5
+
6
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
7
+ find: function find(fn) {
8
+ return $find(this, fn);
9
+ }
10
+ });
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var aFunction = require('../internals/a-function');
5
+ var anObject = require('../internals/an-object');
6
+ var isObject = require('../internals/is-object');
7
+ var createAsyncIteratorProxy = require('../internals/create-async-iterator-proxy');
8
+ var getAsyncIteratorMethod = require('../internals/get-async-iterator-method');
9
+
10
+ var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg, Promise) {
11
+ var state = this;
12
+ var mapper = state.mapper;
13
+ var innerIterator, iteratorMethod;
14
+
15
+ return new Promise(function (resolve, reject) {
16
+ var outerLoop = function () {
17
+ try {
18
+ Promise.resolve(anObject(state.next.call(state.iterator, arg))).then(function (step) {
19
+ try {
20
+ if (anObject(step).done) {
21
+ state.done = true;
22
+ resolve({ done: true, value: undefined });
23
+ } else {
24
+ Promise.resolve(mapper(step.value)).then(function (mapped) {
25
+ try {
26
+ if (isObject(mapped) && (iteratorMethod = getAsyncIteratorMethod(mapped)) !== undefined) {
27
+ state.innerIterator = innerIterator = iteratorMethod.call(mapped);
28
+ state.innerNext = aFunction(innerIterator.next);
29
+ return innerLoop();
30
+ } resolve({ done: false, value: mapped });
31
+ } catch (error2) { reject(error2); }
32
+ }, reject);
33
+ }
34
+ } catch (error1) { reject(error1); }
35
+ }, reject);
36
+ } catch (error) { reject(error); }
37
+ };
38
+
39
+ var innerLoop = function () {
40
+ if (innerIterator = state.innerIterator) {
41
+ try {
42
+ Promise.resolve(anObject(state.innerNext.call(innerIterator))).then(function (result) {
43
+ try {
44
+ if (anObject(result).done) {
45
+ state.innerIterator = state.innerNext = null;
46
+ outerLoop();
47
+ } else resolve({ done: false, value: result.value });
48
+ } catch (error1) { reject(error1); }
49
+ }, reject);
50
+ } catch (error) { reject(error); }
51
+ } else outerLoop();
52
+ };
53
+
54
+ innerLoop();
55
+ });
56
+ });
57
+
58
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
59
+ flatMap: function flatMap(mapper) {
60
+ return new AsyncIteratorProxy({
61
+ iterator: anObject(this),
62
+ mapper: aFunction(mapper),
63
+ innerIterator: null,
64
+ innerNext: null
65
+ });
66
+ }
67
+ });
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var $forEach = require('../internals/async-iterator-iteration').forEach;
5
+
6
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
7
+ forEach: function forEach(fn) {
8
+ return $forEach(this, fn);
9
+ }
10
+ });
@@ -0,0 +1,30 @@
1
+ // https://github.com/tc39/proposal-iterator-helpers
2
+ var $ = require('../internals/export');
3
+ var path = require('../internals/path');
4
+ var aFunction = require('../internals/a-function');
5
+ var anObject = require('../internals/an-object');
6
+ var toObject = require('../internals/to-object');
7
+ var createAsyncIteratorProxy = require('../internals/create-async-iterator-proxy');
8
+ var getAsyncIteratorMethod = require('../internals/get-async-iterator-method');
9
+
10
+ var AsyncIterator = path.AsyncIterator;
11
+
12
+ var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg) {
13
+ return anObject(this.next.call(this.iterator, arg));
14
+ }, true);
15
+
16
+ $({ target: 'AsyncIterator', stat: true }, {
17
+ from: function from(O) {
18
+ var object = toObject(O);
19
+ var usingIterator = getAsyncIteratorMethod(object);
20
+ var iterator;
21
+ if (usingIterator != null) {
22
+ iterator = aFunction(usingIterator).call(object);
23
+ if (iterator instanceof AsyncIterator) return iterator;
24
+ } else {
25
+ iterator = object;
26
+ } return new AsyncIteratorProxy({
27
+ iterator: iterator
28
+ });
29
+ }
30
+ });
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var aFunction = require('../internals/a-function');
5
+ var anObject = require('../internals/an-object');
6
+ var createAsyncIteratorProxy = require('../internals/create-async-iterator-proxy');
7
+
8
+ var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg, Promise) {
9
+ var state = this;
10
+ var mapper = state.mapper;
11
+
12
+ return Promise.resolve(anObject(state.next.call(state.iterator, arg))).then(function (step) {
13
+ if (anObject(step).done) {
14
+ state.done = true;
15
+ return { done: true, value: undefined };
16
+ }
17
+ return Promise.resolve(mapper(step.value)).then(function (value) {
18
+ return { done: false, value: value };
19
+ });
20
+ });
21
+ });
22
+
23
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
24
+ map: function map(mapper) {
25
+ return new AsyncIteratorProxy({
26
+ iterator: anObject(this),
27
+ mapper: aFunction(mapper)
28
+ });
29
+ }
30
+ });
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var aFunction = require('../internals/a-function');
5
+ var anObject = require('../internals/an-object');
6
+ var getBuiltIn = require('../internals/get-built-in');
7
+
8
+ var Promise = getBuiltIn('Promise');
9
+
10
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
11
+ reduce: function reduce(reducer /* , initialValue */) {
12
+ var iterator = anObject(this);
13
+ var next = aFunction(iterator.next);
14
+ var noInitial = arguments.length < 2;
15
+ var accumulator = noInitial ? undefined : arguments[1];
16
+ aFunction(reducer);
17
+
18
+ return new Promise(function (resolve, reject) {
19
+ var loop = function () {
20
+ try {
21
+ Promise.resolve(anObject(next.call(iterator))).then(function (step) {
22
+ try {
23
+ if (anObject(step).done) {
24
+ noInitial ? reject(TypeError('Reduce of empty iterator with no initial value')) : resolve(accumulator);
25
+ } else {
26
+ var value = step.value;
27
+ if (noInitial) {
28
+ noInitial = false;
29
+ accumulator = value;
30
+ loop();
31
+ } else {
32
+ Promise.resolve(reducer(accumulator, value)).then(function (result) {
33
+ accumulator = result;
34
+ loop();
35
+ }, reject);
36
+ }
37
+ }
38
+ } catch (err) { reject(err); }
39
+ }, reject);
40
+ } catch (error) { reject(error); }
41
+ };
42
+
43
+ loop();
44
+ });
45
+ }
46
+ });
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var $some = require('../internals/async-iterator-iteration').some;
5
+
6
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
7
+ some: function some(fn) {
8
+ return $some(this, fn);
9
+ }
10
+ });
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var anObject = require('../internals/an-object');
5
+ var toPositiveInteger = require('../internals/to-positive-integer');
6
+ var createAsyncIteratorProxy = require('../internals/create-async-iterator-proxy');
7
+
8
+ var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg) {
9
+ if (!this.remaining--) {
10
+ this.done = true;
11
+ return { done: true, value: undefined };
12
+ } return this.next.call(this.iterator, arg);
13
+ });
14
+
15
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
16
+ take: function take(limit) {
17
+ return new AsyncIteratorProxy({
18
+ iterator: anObject(this),
19
+ remaining: toPositiveInteger(limit)
20
+ });
21
+ }
22
+ });
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var $toArray = require('../internals/async-iterator-iteration').toArray;
5
+
6
+ $({ target: 'AsyncIterator', proto: true, real: true }, {
7
+ toArray: function toArray() {
8
+ return $toArray(this);
9
+ }
10
+ });
@@ -1,8 +1,2 @@
1
- var $ = require('../internals/export');
2
- var global = require('../internals/global');
3
-
4
- // `globalThis` object
5
- // https://github.com/tc39/proposal-global
6
- $({ global: true }, {
7
- globalThis: global
8
- });
1
+ // TODO: Remove from `core-js@4`
2
+ require('./es.global-this');
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var anObject = require('../internals/an-object');
5
+ var createIteratorProxy = require('../internals/create-iterator-proxy');
6
+
7
+ var IteratorProxy = createIteratorProxy(function (arg) {
8
+ var result = anObject(this.next.call(this.iterator, arg));
9
+ var done = this.done = !!result.done;
10
+ if (!done) return [this.index++, result.value];
11
+ });
12
+
13
+ $({ target: 'Iterator', proto: true, real: true }, {
14
+ asIndexedPairs: function asIndexedPairs() {
15
+ return new IteratorProxy({
16
+ iterator: anObject(this),
17
+ index: 0
18
+ });
19
+ }
20
+ });
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var global = require('../internals/global');
5
+ var anInstance = require('../internals/an-instance');
6
+ var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
7
+ var has = require('../internals/has');
8
+ var wellKnownSymbol = require('../internals/well-known-symbol');
9
+ var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;
10
+ var IS_PURE = require('../internals/is-pure');
11
+
12
+ var ITERATOR = wellKnownSymbol('iterator');
13
+ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
14
+
15
+ var NativeIterator = global.Iterator;
16
+
17
+ // FF56- have non-standard global helper `Iterator`
18
+ var FORCED = IS_PURE || typeof NativeIterator != 'function' || NativeIterator.prototype !== IteratorPrototype;
19
+
20
+ var IteratorConstructor = function Iterator() {
21
+ anInstance(this, IteratorConstructor);
22
+ };
23
+
24
+ if (IS_PURE) {
25
+ IteratorPrototype = {};
26
+ createNonEnumerableProperty(IteratorPrototype, ITERATOR, function () {
27
+ return this;
28
+ });
29
+ }
30
+
31
+ if (!has(IteratorPrototype, TO_STRING_TAG)) {
32
+ createNonEnumerableProperty(IteratorPrototype, TO_STRING_TAG, 'Iterator');
33
+ }
34
+
35
+ IteratorConstructor.prototype = IteratorPrototype;
36
+
37
+ $({ global: true, forced: FORCED }, {
38
+ Iterator: IteratorConstructor
39
+ });
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var anObject = require('../internals/an-object');
5
+ var toPositiveInteger = require('../internals/to-positive-integer');
6
+ var createIteratorProxy = require('../internals/create-iterator-proxy');
7
+
8
+ var IteratorProxy = createIteratorProxy(function (arg) {
9
+ var iterator = this.iterator;
10
+ var next = this.next;
11
+ var result, done;
12
+ while (this.remaining) {
13
+ this.remaining--;
14
+ result = anObject(next.call(iterator));
15
+ done = this.done = !!result.done;
16
+ if (done) return;
17
+ }
18
+ result = anObject(next.call(iterator, arg));
19
+ done = this.done = !!result.done;
20
+ if (!done) return result.value;
21
+ });
22
+
23
+ $({ target: 'Iterator', proto: true, real: true }, {
24
+ drop: function drop(limit) {
25
+ return new IteratorProxy({
26
+ iterator: anObject(this),
27
+ remaining: toPositiveInteger(limit)
28
+ });
29
+ }
30
+ });
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var iterate = require('../internals/iterate');
5
+ var aFunction = require('../internals/a-function');
6
+ var anObject = require('../internals/an-object');
7
+
8
+ $({ target: 'Iterator', proto: true, real: true }, {
9
+ every: function every(fn) {
10
+ anObject(this);
11
+ aFunction(fn);
12
+ return !iterate(this, function (value) {
13
+ if (!fn(value)) return iterate.stop();
14
+ }, undefined, false, true).stopped;
15
+ }
16
+ });
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var aFunction = require('../internals/a-function');
5
+ var anObject = require('../internals/an-object');
6
+ var createIteratorProxy = require('../internals/create-iterator-proxy');
7
+ var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
8
+
9
+ var IteratorProxy = createIteratorProxy(function (arg) {
10
+ var iterator = this.iterator;
11
+ var filterer = this.filterer;
12
+ var next = this.next;
13
+ var result, done, value;
14
+ while (true) {
15
+ result = anObject(next.call(iterator, arg));
16
+ done = this.done = !!result.done;
17
+ if (done) return;
18
+ value = result.value;
19
+ if (callWithSafeIterationClosing(iterator, filterer, value)) return value;
20
+ }
21
+ });
22
+
23
+ $({ target: 'Iterator', proto: true, real: true }, {
24
+ filter: function filter(filterer) {
25
+ return new IteratorProxy({
26
+ iterator: anObject(this),
27
+ filterer: aFunction(filterer)
28
+ });
29
+ }
30
+ });
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var iterate = require('../internals/iterate');
5
+ var aFunction = require('../internals/a-function');
6
+ var anObject = require('../internals/an-object');
7
+
8
+ $({ target: 'Iterator', proto: true, real: true }, {
9
+ find: function find(fn) {
10
+ anObject(this);
11
+ aFunction(fn);
12
+ return iterate(this, function (value) {
13
+ if (fn(value)) return iterate.stop(value);
14
+ }, undefined, false, true).result;
15
+ }
16
+ });
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-helpers
3
+ var $ = require('../internals/export');
4
+ var aFunction = require('../internals/a-function');
5
+ var anObject = require('../internals/an-object');
6
+ var isObject = require('../internals/is-object');
7
+ var getIteratorMethod = require('../internals/get-iterator-method');
8
+ var createIteratorProxy = require('../internals/create-iterator-proxy');
9
+ var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
10
+
11
+ var IteratorProxy = createIteratorProxy(function (arg) {
12
+ var iterator = this.iterator;
13
+ var result, mapped, iteratorMethod, innerIterator;
14
+
15
+ while (true) {
16
+ if (innerIterator = this.innerIterator) {
17
+ result = anObject(this.innerNext.call(innerIterator));
18
+ if (!result.done) return result.value;
19
+ this.innerIterator = this.innerNext = null;
20
+ }
21
+
22
+ result = anObject(this.next.call(iterator, arg));
23
+
24
+ if (this.done = !!result.done) return;
25
+
26
+ mapped = callWithSafeIterationClosing(iterator, this.mapper, result.value);
27
+
28
+ if (isObject(mapped) && (iteratorMethod = getIteratorMethod(mapped)) !== undefined) {
29
+ this.innerIterator = innerIterator = iteratorMethod.call(mapped);
30
+ this.innerNext = aFunction(innerIterator.next);
31
+ continue;
32
+ } return mapped;
33
+ }
34
+ });
35
+
36
+ $({ target: 'Iterator', proto: true, real: true }, {
37
+ flatMap: function flatMap(mapper) {
38
+ return new IteratorProxy({
39
+ iterator: anObject(this),
40
+ mapper: aFunction(mapper),
41
+ innerIterator: null,
42
+ innerNext: null
43
+ });
44
+ }
45
+ });