Creates an array from an async iterator or iterable object.
Symbol
ArrayConstructor.fromAsync
An async iterator or array-like object to convert to an array.
Creates an array from an async iterator or iterable object.
An async iterator or array-like object to convert to an array.
Value of 'this' used when executing mapfn.
Create an array from an iterable or async iterable object. Values from the iterable are awaited.
await Array.fromAsync([1]); // [1]
await Array.fromAsync([Promise.resolve(1)]); // [1]
await Array.fromAsync((async function*() { yield 1 })()); // [1]
The iterable or async iterable to convert to an array.
A Promise whose fulfillment is a new Array instance containing the values from the iterator.
Create an array from an iterable or async iterable object. Values from the iterable are awaited. Results of the map function are also awaited.
await Array.fromAsync([1]); // [1]
await Array.fromAsync([Promise.resolve(1)]); // [1]
await Array.fromAsync((async function*() { yield 1 })()); // [1]
await Array.fromAsync([1], (n) => n + 1); // [2]
await Array.fromAsync([1], (n) => Promise.resolve(n + 1)); // [2]
The iterable or async iterable to convert to an array.
A mapper function that transforms each element of arrayLike
after awaiting them.
The this
to which mapFn
is bound.
A Promise whose fulfillment is a new Array instance containing the values from the iterator.