Example 1 — Array of Promises
Pass an array of Promises — each value is awaited into the result.
const nums = await Array.fromAsync([
Promise.resolve(1),
Promise.resolve(2),
Promise.resolve(3)
]);
console.log(nums);
// [1, 2, 3] How It Works
- Source is thenables. Each element is a Promise that resolves to a number.
- Await each value.
fromAsyncwaits for every Promise. - Build a real Array. Resolved values become
[1, 2, 3]. - Await the call. The method itself returns a Promise — use
await.

