Function consume

  • Consumes an input iterable and optionally applies a mapping function to each element. Returns a Promise of an array containing the results of the mapping function.

    Returns

    A function that accepts an input iterable and returns a Promise of an array containing the results.

    Example

    const input = [1, 2, 3];
    const double = (x: number) => x * 2;
    const consumedIterable = await consume<number, number>(double)(input);
    console.log(consumedIterable); // Logs [2, 4, 6]

    Type Parameters

    • T

      The type of elements in the input iterable.

    • U

      The type of elements in the resulting array.

    Parameters

    • Optional mapFn: MapFn<T, MaybePromise<U>>

      An optional mapping function to apply to each element of the input iterable.

    Returns ((input: AnyIterable<T>) => Promise<U[]>)

Generated using TypeDoc