change Iterator chunking unconditional forced replacement to feature detection

This commit is contained in:
Denis Pushkarev
2026-06-27 01:15:21 +07:00
parent de1343407e
commit 2bdd805a6b
3 changed files with 5 additions and 3 deletions
@@ -6,6 +6,7 @@ var createIteratorProxy = require('../internals/iterator-create-proxy');
var getIteratorDirect = require('../internals/get-iterator-direct');
var iteratorClose = require('../internals/iterator-close');
var uncurryThis = require('../internals/function-uncurry-this');
var IS_PURE = require('../internals/is-pure');
var $RangeError = RangeError;
var push = uncurryThis([].push);
@@ -31,7 +32,7 @@ var IteratorProxy = createIteratorProxy(function () {
// `Iterator.prototype.chunks` method
// https://github.com/tc39/proposal-iterator-chunking
$({ target: 'Iterator', proto: true, real: true, forced: true }, {
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
chunks: function chunks(chunkSize) {
var O = anObject(this);
if (typeof chunkSize != 'number' || !chunkSize || chunkSize >>> 0 !== chunkSize) {
@@ -1,10 +1,11 @@
'use strict';
var $ = require('../internals/export');
var iteratorWindow = require('../internals/iterator-window');
var IS_PURE = require('../internals/is-pure');
// `Iterator.prototype.windows` method
// https://github.com/tc39/proposal-iterator-chunking
$({ target: 'Iterator', proto: true, real: true, forced: true }, {
$({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
windows: function windows(windowSize /* , undersized */) {
return iteratorWindow(this, windowSize, arguments.length < 2 ? undefined : arguments[1]);
}