Function filterAsync

  • Filter an array in parallel using an async predicate function.

    Returns

    a promise of the filtered array. it will resolve when all of the async predicates resolve

    Example

    await filterAsync([1, 2, 3], x => Promise.resolve(x % 2 === 0)) === [2]
    

    Type Parameters

    • T

    Parameters

    • array: T[]

      the array to filter

    • asyncPredicateFn: ((value, i, arr) => Promise<boolean>)

      the predicate function as an async function

        • (value, i, arr): Promise<boolean>
        • Parameters

          • value: T
          • i: number
          • arr: T[]

          Returns Promise<boolean>

    Returns Promise<T[]>

Generated using TypeDoc