Skip to content

Commit

Permalink
fix forced polyfilling of some iterator helpers that should return wr…
Browse files Browse the repository at this point in the history
…apped iterator in the pure version
  • Loading branch information
zloirock committed Jul 26, 2023
1 parent 4b19947 commit ce17c76
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- `DataView.prototype.getUint8Clamped`
- `DataView.prototype.setUint8Clamped`
- Used strict mode in some missed cases, [#1269](https://github.com/zloirock/core-js/issues/1269)
- Fixed forced polyfilling of some iterator helpers that should return wrapped iterator in the pure version
- Fixed and exposed [`AsyncIteratorPrototype` `core-js/configurator` option](https://github.com/zloirock/core-js#asynciterator-helpers), [#1268](https://github.com/zloirock/core-js/issues/1268)
- Compat data improvements:
- Sync [`Iterator` helpers proposal](https://github.com/tc39/proposal-iterator-helpers) features marked as [supported](https://chromestatus.com/feature/5102502917177344) from V8 ~ Chrome 117
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.async-iterator.drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var notANaN = require('../internals/not-a-nan');
var toPositiveInteger = require('../internals/to-positive-integer');
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
var createIterResultObject = require('../internals/create-iter-result-object');
var IS_PURE = require('../internals/is-pure');

var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
var state = this;
Expand Down Expand Up @@ -39,7 +40,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {

// `AsyncIterator.prototype.drop` method
// https://github.com/tc39/proposal-async-iterator-helpers
$({ target: 'AsyncIterator', proto: true, real: true }, {
$({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, {
drop: function drop(limit) {
anObject(this);
var remaining = toPositiveInteger(notANaN(+limit));
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.async-iterator.filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var getIteratorDirect = require('../internals/get-iterator-direct');
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
var createIterResultObject = require('../internals/create-iter-result-object');
var closeAsyncIteration = require('../internals/async-iterator-close');
var IS_PURE = require('../internals/is-pure');

var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
var state = this;
Expand Down Expand Up @@ -55,7 +56,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {

// `AsyncIterator.prototype.filter` method
// https://github.com/tc39/proposal-async-iterator-helpers
$({ target: 'AsyncIterator', proto: true, real: true }, {
$({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, {
filter: function filter(predicate) {
anObject(this);
aCallable(predicate);
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.async-iterator.flat-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy
var createIterResultObject = require('../internals/create-iter-result-object');
var getAsyncIteratorFlattenable = require('../internals/get-async-iterator-flattenable');
var closeAsyncIteration = require('../internals/async-iterator-close');
var IS_PURE = require('../internals/is-pure');

var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
var state = this;
Expand Down Expand Up @@ -75,7 +76,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {

// `AsyncIterator.prototype.flaMap` method
// https://github.com/tc39/proposal-async-iterator-helpers
$({ target: 'AsyncIterator', proto: true, real: true }, {
$({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, {
flatMap: function flatMap(mapper) {
anObject(this);
aCallable(mapper);
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.async-iterator.from.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ var isPrototypeOf = require('../internals/object-is-prototype-of');
var getAsyncIteratorFlattenable = require('../internals/get-async-iterator-flattenable');
var AsyncIteratorPrototype = require('../internals/async-iterator-prototype');
var WrapAsyncIterator = require('../internals/async-iterator-wrap');
var IS_PURE = require('../internals/is-pure');

// `AsyncIterator.from` method
// https://github.com/tc39/proposal-async-iterator-helpers
$({ target: 'AsyncIterator', stat: true }, {
$({ target: 'AsyncIterator', stat: true, forced: IS_PURE }, {
from: function from(O) {
var iteratorRecord = getAsyncIteratorFlattenable(typeof O == 'string' ? toObject(O) : O);
return isPrototypeOf(AsyncIteratorPrototype, iteratorRecord.iterator)
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.async-iterator.map.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';
var $ = require('../internals/export');
var map = require('../internals/async-iterator-map');
var IS_PURE = require('../internals/is-pure');

// `AsyncIterator.prototype.map` method
// https://github.com/tc39/proposal-async-iterator-helpers
$({ target: 'AsyncIterator', proto: true, real: true }, {
$({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, {
map: map
});

3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.async-iterator.take.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var notANaN = require('../internals/not-a-nan');
var toPositiveInteger = require('../internals/to-positive-integer');
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
var createIterResultObject = require('../internals/create-iter-result-object');
var IS_PURE = require('../internals/is-pure');

var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
var state = this;
Expand Down Expand Up @@ -36,7 +37,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {

// `AsyncIterator.prototype.take` method
// https://github.com/tc39/proposal-async-iterator-helpers
$({ target: 'AsyncIterator', proto: true, real: true }, {
$({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, {
take: function take(limit) {
anObject(this);
var remaining = toPositiveInteger(notANaN(+limit));
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.iterator.drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var getIteratorDirect = require('../internals/get-iterator-direct');
var notANaN = require('../internals/not-a-nan');
var toPositiveInteger = require('../internals/to-positive-integer');
var createIteratorProxy = require('../internals/iterator-create-proxy');
var IS_PURE = require('../internals/is-pure');

var IteratorProxy = createIteratorProxy(function () {
var iterator = this.iterator;
Expand All @@ -24,7 +25,7 @@ var IteratorProxy = createIteratorProxy(function () {

// `Iterator.prototype.drop` method
// https://github.com/tc39/proposal-iterator-helpers
$({ target: 'Iterator', proto: true, real: true }, {
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
drop: function drop(limit) {
anObject(this);
var remaining = toPositiveInteger(notANaN(+limit));
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.iterator.filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var anObject = require('../internals/an-object');
var getIteratorDirect = require('../internals/get-iterator-direct');
var createIteratorProxy = require('../internals/iterator-create-proxy');
var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
var IS_PURE = require('../internals/is-pure');

var IteratorProxy = createIteratorProxy(function () {
var iterator = this.iterator;
Expand All @@ -23,7 +24,7 @@ var IteratorProxy = createIteratorProxy(function () {

// `Iterator.prototype.filter` method
// https://github.com/tc39/proposal-iterator-helpers
$({ target: 'Iterator', proto: true, real: true }, {
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
filter: function filter(predicate) {
anObject(this);
aCallable(predicate);
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.iterator.flat-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var getIteratorDirect = require('../internals/get-iterator-direct');
var getIteratorFlattenable = require('../internals/get-iterator-flattenable');
var createIteratorProxy = require('../internals/iterator-create-proxy');
var iteratorClose = require('../internals/iterator-close');
var IS_PURE = require('../internals/is-pure');

var IteratorProxy = createIteratorProxy(function () {
var iterator = this.iterator;
Expand All @@ -32,7 +33,7 @@ var IteratorProxy = createIteratorProxy(function () {

// `Iterator.prototype.flatMap` method
// https://github.com/tc39/proposal-iterator-helpers
$({ target: 'Iterator', proto: true, real: true }, {
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
flatMap: function flatMap(mapper) {
anObject(this);
aCallable(mapper);
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.iterator.from.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ var isPrototypeOf = require('../internals/object-is-prototype-of');
var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;
var createIteratorProxy = require('../internals/iterator-create-proxy');
var getIteratorFlattenable = require('../internals/get-iterator-flattenable');
var IS_PURE = require('../internals/is-pure');

var IteratorProxy = createIteratorProxy(function () {
return call(this.next, this.iterator);
}, true);

// `Iterator.from` method
// https://github.com/tc39/proposal-iterator-helpers
$({ target: 'Iterator', stat: true }, {
$({ target: 'Iterator', stat: true, forced: IS_PURE }, {
from: function from(O) {
var iteratorRecord = getIteratorFlattenable(typeof O == 'string' ? toObject(O) : O, true);
return isPrototypeOf(IteratorPrototype, iteratorRecord.iterator)
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.iterator.map.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict';
var $ = require('../internals/export');
var map = require('../internals/iterator-map');
var IS_PURE = require('../internals/is-pure');

// `Iterator.prototype.map` method
// https://github.com/tc39/proposal-iterator-helpers
$({ target: 'Iterator', proto: true, real: true }, {
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
map: map
});
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.iterator.take.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var notANaN = require('../internals/not-a-nan');
var toPositiveInteger = require('../internals/to-positive-integer');
var createIteratorProxy = require('../internals/iterator-create-proxy');
var iteratorClose = require('../internals/iterator-close');
var IS_PURE = require('../internals/is-pure');

var IteratorProxy = createIteratorProxy(function () {
var iterator = this.iterator;
Expand All @@ -21,7 +22,7 @@ var IteratorProxy = createIteratorProxy(function () {

// `Iterator.prototype.take` method
// https://github.com/tc39/proposal-iterator-helpers
$({ target: 'Iterator', proto: true, real: true }, {
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
take: function take(limit) {
anObject(this);
var remaining = toPositiveInteger(notANaN(+limit));
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/modules/esnext.iterator.to-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ var anObject = require('../internals/an-object');
var AsyncFromSyncIterator = require('../internals/async-from-sync-iterator');
var WrapAsyncIterator = require('../internals/async-iterator-wrap');
var getIteratorDirect = require('../internals/get-iterator-direct');
var IS_PURE = require('../internals/is-pure');

// `Iterator.prototype.toAsync` method
// https://github.com/tc39/proposal-async-iterator-helpers
$({ target: 'Iterator', proto: true, real: true }, {
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
toAsync: function toAsync() {
return new WrapAsyncIterator(getIteratorDirect(new AsyncFromSyncIterator(getIteratorDirect(anObject(this)))));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/modules/esnext.map.group-by.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
var $ = require('../internals/export');
var IS_PURE = require('../internals/is-pure');
var uncurryThis = require('../internals/function-uncurry-this');
var aCallable = require('../internals/a-callable');
var requireObjectCoercible = require('../internals/require-object-coercible');
var iterate = require('../internals/iterate');
var MapHelpers = require('../internals/map-helpers');
var IS_PURE = require('../internals/is-pure');

var Map = MapHelpers.Map;
var has = MapHelpers.has;
Expand Down

0 comments on commit ce17c76

Please sign in to comment.