Function filter

  • Filters elements in an input iterable based on a given async predicate function. Returns a new asynchronous iterable with elements that satisfy the predicate.

    Returns

    A function that accepts an input iterable and returns a new asynchronous iterable with the filtered elements.

    Example

    const input = [1, 2, 3, 4];
    const isEven = async (x: number) => x % 2 === 0;
    const filteredIterable = filter<number>(isEven)(input);

    (async () => {
    for await (const x of filteredIterable) {
    console.log(x); // Logs 2, 4
    }
    })();

    Type Parameters

    • T

      The type of elements in the input iterable.

    Parameters

    Returns ((input: AnyIterable<T>) => AsyncIterable<Awaited<T>>)

      • (input: AnyIterable<T>): AsyncIterable<Awaited<T>>
      • Parameters

        Returns AsyncIterable<Awaited<T>>

Generated using TypeDoc