Skip to content

Commit 3f26c95

Browse files
committed
docs: Update history/explainer with resolution of #19
1 parent 304bbe9 commit 3f26c95

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

HISTORY.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ Presented to [plenary meeting as an update on 2021-10-26][2021-10-26].
66

77
# 2021-12
88
Presented to [plenary meeting for Stage 2 on 2021-12-14][2021-12-14].
9-
Was rejected due to need to clarify awaiting semantics
9+
Was rejected due to need to clarify `await`ing semantics
1010
with and without mapping-function arguments.
1111

12+
# 2022-07
13+
Discussion occurred about `await`ing semantics and mapping functions in [issue
14+
#19][]. It was eventually decided to match `for await` and the proposed
15+
[AsyncIterator.prototype.toArray][iterator-helpers] by `await`ing values from
16+
input sync iterators once, `await`ing values from input async iterators not at
17+
all, and `await`ing results returned by mapping functions once.
18+
1219
[2021-08-31]: https://github.com/tc39/notes/blob/HEAD/meetings/2021-08/aug-31.md
1320
[2021-10-26]: https://github.com/tc39/notes/blob/HEAD/meetings/2021-10/oct-26.md#arrayfromasync-update
1421
[2021-12-14]: https://github.com/tc39/notes/blob/HEAD/meetings/2021-12/dec-14.md#arrayfromasync-for-stage-2
22+
[issue #19]: https://github.com/tc39/proposal-array-from-async/issues/19
23+
[iterator-helpers]: https://github.com/tc39/proposal-iterator-helpers
24+
[iterator-helpers#168]: https://github.com/tc39/proposal-iterator-helpers/issues/168

README.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,24 @@ Array.fromAsync([], 1);
402402
The [iterator-helpers][] proposal has toArray, which works with both sync and
403403
async iterables.
404404
405+
[iterator-helpers]: https://github.com/tc39/proposal-iterator-helpers
406+
405407
```js
406-
Array.from(gen())
407-
gen().toArray()
408-
Array.fromAsync(asyncGen())
409-
asyncGen().toArray()
408+
// Array.from
409+
410+
Array.from(input)
411+
Iterator(input).toArray()
412+
413+
Array.from(input, mapfn)
414+
Iterator(input).map(mapfn).toArray()
415+
416+
// Array.asyncFrom
417+
418+
Array.fromAsync(input)
419+
AsyncIterator(input).toArray()
420+
421+
Array.fromAsync(input, mapfn)
422+
AsyncIterator(input).map(mapfn).toArray()
410423
```
411424
412425
toArray overlaps with both Array.from and Array.fromAsync. This is okay. They
@@ -422,7 +435,6 @@ something one element at a time is the same as building it [more than one]
422435
element at a time, but sometimes it could be slow to build that way or produce
423436
a structure with equivalent semantics but different performance properties.”
424437
425-
[iterator-helpers]: https://github.com/tc39/proposal-iterator-helpers
426438
[tc39/proposal-iterator-helpers#156]: https://github.com/tc39/proposal-iterator-helpers/issues/156.
427439
428440
### TypedArray.fromAsync, Set.fromAsync, Object.fromEntriesAsync, etc.

0 commit comments

Comments
 (0)