Summary:
`Array.fromAsync` is a TC39 proposal [1] at Stage 3 of the TC39
standardization process [2]. It is the async sibling to `Array.from`,
adapted to handle async iterators and promise-returning functions.
It allows the construction of an array of results from an async iterator,
returning a promise for this array. Thus,
```
array = []
for await (x of asyncIter) {
array.push(await x);
}
```
can be simplified to `array = await Array.asyncFrom(asyncIter)`.
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1746209
Specification: https://tc39.es/proposal-array-from-async/
Platform Coverage: All
Preference: Currently available in the JS shell using the option
`--enable-array-from-async` . Will be preffable under
`javascript.options.experimental.enable_array_from_async` when Bug 1825356
lands.
Documentation: MDN documentation tracked here
https://github.com/mdn/content/issues/22145
Other Browsers: Safari Technical Preview has shipped; Chrome has a flagged
implementation.
Testing: Tested through our tests as well as the ECMAScript standard test
suite test262.
[1]: https://github.com/tc39/proposal-array-from-async
[2]: https://tc39.es/process-document/
-- Matthew Gaudet
--
You received this message because you are subscribed to the Google Groups
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/CAK1KXSYQEQ4m3ncpDMSm%3DJqAtLruLcriaO-X4dM7gaV7a%2B5BJQ%40mail.gmail.com.