Skip to content

Commit 32aa077

Browse files
committed
explainer: Small fixes
• Mention similarity of array-like inputs to those of Array.prototype.values. • Mention index-integer argument to mapping callback. • Clarify that value argument has been awaited if yielded from synchronous input.
1 parent 56fcd21 commit 32aa077

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ see [§ Errors][].
112112
### Non-iterable array-like inputs
113113
Array.fromAsync’s valid inputs are a superset of Array.from’s valid inputs. This
114114
includes non-iterable array-likes: objects that have a length property as well
115-
as indexed elements. The return value is still a promise that will resolve to an
116-
array. If the array-like object’s elements are promises, then each accessed
117-
promise is awaited before its value is added to the new array.
115+
as indexed elements (similarly to Array.prototype.values). The return value is
116+
still a promise that will resolve to an array. If the array-like object’s
117+
elements are promises, then each accessed promise is awaited before its value is
118+
added to the new array.
118119

119120
One [TC39 representative’s opinion][issue #7 comment]: “[Array-likes are] very
120121
much not obsolete, and it’s very nice that things aren’t forced to implement the
@@ -180,9 +181,10 @@ const d = await Data.fromAsync(asyncGen(4));
180181
Array.fromAsync has two optional parameters: `mapfn` and `thisArg`.
181182

182183
`mapfn` is a mapping callback, which is called on each value yielded from the
183-
input – the result of which is awaited then added to the array. Unlike
184-
Array.from, `mapfn` may be an async function.) By default, this is essentially
185-
an identity function.
184+
input (and awaited if it came from a synchronous input), along with its index
185+
integer (starting from 0). Each result of the mapping callback is, in turn,
186+
awaited then added to the array. By default, the callback is essentially an
187+
identity function.
186188

187189
`thisArg` is a `this`-binding receiver value for the mapping callback. By
188190
default, this is undefined. These optional parameters match the behavior of

0 commit comments

Comments
 (0)