跳至主要內容

Array.fromAsync

小于 1 分钟featurees-proposal

Array.fromAsyncopen in new window

模块

esnext.array.from-asyncopen in new window

类型

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

入口点

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

示例

示例open in new window:

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