Skip to main content

Array.fromAsync

Less than 1 minutefeaturees-proposal

Array.fromAsyncopen in new window

Module

esnext.array.from-asyncopen in new window

Types

interface ArrayConstructor {
  fromAsync<T, U>(
    asyncItems: AsyncIterable<T> | Iterable<T> | ArrayLike<T>,
    mapfn?: (value: T, index: number) => U,
    thisArg?: any
  ): Array<T>;
}

Entry points

core-js/proposals/array-from-async-stage-2
core-js(-pure)/full/array/from-async

Example

Exampleopen in new window:

await Array.fromAsync(
  (async function* () {
    yield* [1, 2, 3];
  })(),
  (i) => i * i
); // => [1, 4, 9]