From 565447149308397169e15549f17a331c106858b7 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Thu, 17 Jul 2025 18:03:51 +0300 Subject: [PATCH] move `Iterator` chunking proposal to stage 2.7 --- CHANGELOG.md | 6 ++++ README.md | 58 +++++++++++++++++------------------ packages/core-js/stage/2.7.js | 1 + packages/core-js/stage/2.js | 1 - 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf73bb426bd7..56fe3f0aa6a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## Changelog ##### Unreleased +- [`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, July 2025 TC39 meeting - Added missing dependencies to some entries of static `Iterator` methods - Compat data improvements: - [`Uint8Array` to / from base64 and hex proposal](https://github.com/tc39/proposal-arraybuffer-base64) features marked as [supported from V8 ~ Chromium 140](https://issues.chromium.org/issues/42204568#comment37) diff --git a/README.md b/README.md index 6a7e1e914fe2..9c1de0260ddc 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`Symbol.metadata` for decorators metadata proposal](#symbolmetadata-for-decorators-metadata-proposal) - [Stage 2.7 proposals](#stage-27-proposals) - [`Iterator` sequencing](#iterator-sequencing) + - [`Iterator` chunking](#iterator-chunking) - [Joint iteration](#joint-iteration) - [`Map` upsert](#map-upsert) - [Stage 2 proposals](#stage-2-proposals) @@ -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) @@ -2767,6 +2767,34 @@ Iterator.concat([0, 1].values(), [2, 3], function * () { }()).toArray(); // => [0, 1, 2, 3, 4, 5] ``` +##### [`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), [`esnext.iterator.sliding`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.sliding.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; + sliding(windowSize: number): Iterator; + windows(windowSize: number): Iterator; +} +``` +[*CommonJS entry points:*](#commonjs-api) +``` +core-js/proposals/iterator-chunking +core-js(-pure)/full/iterator/chunks +core-js(-pure)/full/iterator/sliding +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 chunksOf2 = Array.from(digits().chunks(2)); // [ [0, 1], [2, 3], [4, 5], [6, 7], [8, 9] ] + +let slidingOf2 = Array.from(digits().sliding(2)); // [ [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9] ] + +let windowsOf2 = Array.from(digits().windows(2)); // [ [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9] ] +``` + ##### [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 @@ -3058,34 +3086,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), [`esnext.iterator.sliding`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.sliding.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; - sliding(windowSize: number): Iterator; - windows(windowSize: number): Iterator; -} -``` -[*CommonJS entry points:*](#commonjs-api) -``` -core-js/proposals/iterator-chunking -core-js(-pure)/full/iterator/chunks -core-js(-pure)/full/iterator/sliding -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 chunksOf2 = Array.from(digits().chunks(2)); // [ [0, 1], [2, 3], [4, 5], [6, 7], [8, 9] ] - -let slidingOf2 = Array.from(digits().sliding(2)); // [ [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9] ] - -let windowsOf2 = Array.from(digits().windows(2)); // [ [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9] ] -``` - #### 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 84da7a577f72..027194aef0ad 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/iterator-sequencing'); require('../proposals/map-upsert-v4'); diff --git a/packages/core-js/stage/2.js b/packages/core-js/stage/2.js index c497198e347b..8077860d2f02 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');