iterator chunking S4
- Stage: Stage 4
- Status: Finished
- ECMAScript edition: ES2027
- Synchronized: Nov 28, 2026
- 中文译文 · Source repository
The proposal adds iterator methods for consuming a sequence in groups of a configurable size. It supports non-overlapping chunks and overlapping sliding windows. The README illustrates how these operations produce arrays of subsequences and lists related use cases such as pagination, stream processing, and running computations.
The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.
Iterator Chunking
A TC39 proposal to consume an iterator as either overlapping or non-overlapping subsequences of configurable size.
Stage: 4. Further advancement is dependent on 2 or more shipping implementations.
Specification: https://tc39.es/proposal-iterator-chunking/
presentations to committee
- September 2026
- May 2026 (no slides)
- September 2025
- July 2025
- May 2025
- October 2024
- January 2024
motivation
It can be useful to consume a stream by more than one value at a time. For example, certain algorithms require looking at adjacent elements.
chunking
This is commonly solved for non-overlapping subsequences with a "chunking" method that works like the following:
use cases for chunking
- pagination
- columnar/grid layouts, such as calendars
- batch/stream processing
- matrix operations
- formatting/encoding
- bucketing (using a computed chunk size, for iterators of known size)
sliding window
When overlapping sequences are needed, this is commonly called a "sliding window".
use cases for sliding windows
- running/continuous computations, such as averages
- context-sensitive algorithms, such as pairwise comparisons
- carousels and their analogues (when applied to an infinite cycle)