tc39 / proposal-record-tuple

ECMAScript proposal for the Record and Tuple value types. | Stage 2: it will change!
https://tc39.es/proposal-record-tuple/
2.5k stars 62 forks source link

Tuple.fromAsync? #385

Open js-choi opened 11 months ago

js-choi commented 11 months ago

This proposal’s spec defines a Tuple.from method akin to Array.from. #250 (see #369) also added support for proposal-iterator-helpers’s Iterator.from and proposal-async-iterator-helpers’s AsyncIterator.from. proposal-iterator-helpers is at Stage 3 and proposal-async-iterator-helpers is at Stage 2.

proposal-array-from-async is also at Stage 3 (conditional on editor review). Its Array.fromAsync is meant to coexist with AsyncIterator.from like how Array.from coexists with Iterator.from.

Should this proposal add a parallel Tuple.fromAsync?

let tup = #[];
for await (const v of asyncIter) {
  tup = #[ ...tup, v ];
}
let tup = await Tuple.fromAsync(asyncIter);