Iterator Sequencing S4
- Stage: Stage 4
- Status: Finished
- ECMAScript edition: ES2026
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
This proposal adds a static Iterator.concat method to sequentially combine multiple iterables into one iterator. It addresses the ergonomic gap of manually using generators or helper libraries for concatenation.
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 Sequencing
A TC39 proposal to create iterators by sequencing existing iterators.
Stage: 4
Specification: https://tc39.es/proposal-iterator-sequencing/
presentations to committee
motivation
Often you have 2 or more iterators, the values of which you would like to
consume in sequence, as if they were a single iterator. Iterator libraries (and
standard libraries of other languages) often have a function called concat or
chain to do this. In JavaScript today, one can accomplish this with generators:
It is also useful to be able to sequence immediate values among the iterators,
as one would do with yield using the generator approach.
We should explore how to make this more ergonomic and functional.
chosen solution
For the (rare) case of infinite iterators of iterators, use Iterator.prototype.flatMap with the identity function.