diff --git a/CHANGELOG.md b/CHANGELOG.md index 271c437e2b2d..190f0af016fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,12 @@ ##### Unreleased - [`Map` upsert stage 3 proposal](https://github.com/tc39/proposal-upsert): - Fixed [a FF `WeakMap.prototype.getOrInsertComputed` bug with callback calling before validation a key](https://bugzilla.mozilla.org/show_bug.cgi?id=1988369) -- [`Iterator` chunking stage 2 proposal](https://github.com/tc39/proposal-iterator-chunking): +- [`Iterator` chunking proposal](https://github.com/tc39/proposal-iterator-chunking): + - Built-ins: + - `Iterator.prototype.chunks` + - `Iterator.prototype.sliding` + - `Iterator.prototype.windows` + - Moved to stage 2.7, September 2025 TC39 meeting - `Iterator.prototype.sliding` method replaced with an extra parameter of `Iterator.prototype.windows` method, [tc39/proposal-iterator-chunking/#24](https://github.com/tc39/proposal-iterator-chunking/pull/24), [tc39/proposal-iterator-chunking/#26](https://github.com/tc39/proposal-iterator-chunking/pull/26) - Compat data improvements: - [`Map.prototype.{ getOrInsert, getOrInsertComputed }` and `WeakMap.prototype.getOrInsert`](https://github.com/tc39/proposal-upsert) marked as shipped from FF144 diff --git a/README.md b/README.md index 7f7e29ab8ec5..a085ff12620d 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`JSON.parse` source text access](#jsonparse-source-text-access) - [`Symbol.metadata` for decorators metadata proposal](#symbolmetadata-for-decorators-metadata-proposal) - [Stage 2.7 proposals](#stage-27-proposals) + - [`Iterator` chunking](#iterator-chunking) - [Joint iteration](#joint-iteration) - [Stage 2 proposals](#stage-2-proposals) - [`AsyncIterator` helpers](#asynciterator-helpers) @@ -181,7 +182,6 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`String.dedent`](#stringdedent) - [`Symbol` predicates](#symbol-predicates) - [`Symbol.customMatcher` for extractors](#symbolcustommatcher-for-extractors) - - [`Iterator` chunking](#iterator-chunking) - [Stage 1 proposals](#stage-1-proposals) - [`Observable`](#observable) - [New collections methods](#new-collections-methods) @@ -2812,6 +2812,34 @@ core-js(-pure)/actual|full/function/metadata core-js(-pure)/stage/2.7 ``` +##### [`Iterator` chunking](https://github.com/tc39/proposal-iterator-chunking)[⬆](#index) +Modules [`esnext.iterator.chunks`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.chunks.js) +and [`esnext.iterator.windows`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.windows.js) +```ts +class Iterator { + chunks(chunkSize: number): Iterator; + windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): Iterator; +} +``` +[*CommonJS entry points:*](#commonjs-api) +``` +core-js/proposals/iterator-chunking-v2 +core-js(-pure)/full/iterator/chunks +core-js(-pure)/full/iterator/windows +``` +[*Examples*](https://tinyurl.com/24xnkcnn) +```js +const digits = () => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].values(); + +let chunks = Array.from(digits().chunks(2)); // [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] + +let windows = Array.from(digits().windows(2)); // [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]] + +let windowsPartial = Array.from([0, 1].values().windows(3, 'allow-partial')); // [[0, 1]] + +let windowsFull = Array.from([0, 1].values().windows(3)); // [] +``` + ##### [Joint iteration](https://github.com/tc39/proposal-joint-iteration)[⬆](#index) Modules [esnext.iterator.zip](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.zip.js), [esnext.iterator.zip-keyed](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.zip-keyed.js) ```ts @@ -3067,34 +3095,6 @@ core-js/proposals/pattern-extractors core-js(-pure)/full/symbol/custom-matcher ``` -##### [`Iterator` chunking](https://github.com/tc39/proposal-iterator-chunking)[⬆](#index) -Modules [`esnext.iterator.chunks`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.chunks.js) -and [`esnext.iterator.windows`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.windows.js) -```ts -class Iterator { - chunks(chunkSize: number): Iterator; - windows(windowSize: number, undersized?: 'only-full' | 'allow-partial' | undefined): Iterator; -} -``` -[*CommonJS entry points:*](#commonjs-api) -``` -core-js/proposals/iterator-chunking-v2 -core-js(-pure)/full/iterator/chunks -core-js(-pure)/full/iterator/windows -``` -[*Examples*](https://tinyurl.com/24xnkcnn) -```js -const digits = () => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].values(); - -let chunks = Array.from(digits().chunks(2)); // [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] - -let windows = Array.from(digits().windows(2)); // [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]] - -let windowsPartial = Array.from([0, 1].values().windows(3, 'allow-partial')); // [[0, 1]] - -let windowsFull = Array.from([0, 1].values().windows(3)); // [] -``` - #### Stage 1 proposals[⬆](#index) [*CommonJS entry points:*](#commonjs-api) ``` diff --git a/packages/core-js/stage/2.7.js b/packages/core-js/stage/2.7.js index 9748eabcdd1f..25bf58ede7ea 100644 --- a/packages/core-js/stage/2.7.js +++ b/packages/core-js/stage/2.7.js @@ -1,6 +1,7 @@ 'use strict'; var parent = require('./3'); +require('../proposals/iterator-chunking'); require('../proposals/joint-iteration'); module.exports = parent; diff --git a/packages/core-js/stage/2.js b/packages/core-js/stage/2.js index babb016e4099..6d0921b25f91 100644 --- a/packages/core-js/stage/2.js +++ b/packages/core-js/stage/2.js @@ -4,7 +4,6 @@ var parent = require('./2.7'); require('../proposals/array-is-template-object'); require('../proposals/async-iterator-helpers'); require('../proposals/extractors'); -require('../proposals/iterator-chunking'); require('../proposals/iterator-range'); require('../proposals/string-dedent'); require('../proposals/symbol-predicates-v2');