Creates an array from an async iterator or iterable object.
Search the reference...
/
method
ArrayConstructor.fromAsyncfromAsyncT>(iterableOrArrayLike: AsyncIterableT, any, any> | IterableT | PromiseLikeT>, any, any> | ArrayLikeT | PromiseLikeT>>): PromiseT[]>;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.
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →ArrayConstructor.fromAsync method | globals module | Bun,AI智能索引,全网链接索引,智能导航,网页索引
- API documentation for method globals.ArrayConstructor.fromAsync | Bun