• map异步回调版

    类型参数

    • T
    • R

    参数

    • arr: ArrayLike<T>
    • cbAsync: ((value: T, index: number, array: ArrayLike<T>) => Promise<R>)
        • (value, index, array): Promise<R>
        • 参数

          • value: T
          • index: number
          • array: ArrayLike<T>

          返回 Promise<R>

    返回 Promise<R[]>

    const asyncList = [
    async () => {
    await sleep(200);
    return 1;
    },
    async () => {
    await sleep(300);
    return 2;
    },
    async () => {
    await sleep(10);
    return 3;
    },
    ];
    const res = await fn(asyncList, (v) => v());
    console.log(res); // [1, 2, 3]