Function map

  • Maps an input iterable using a provided map function. Returns a new asynchronous iterable.

    Returns

    A function that accepts an input iterable and returns a new asynchronous iterable.

    Example

    const input = [1, 2, 3];
    const double = (x: number) => x * 2;
    const mappedIterable = map(double)(input);

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

    Type Parameters

    • T

      The type of elements in the input iterable.

    • U

      The type of elements in the output iterable.

    Parameters

    • mapFn: MapFn<T, U>

      A function that takes a value and its index and returns a new value.

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

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

        Returns AsyncIterable<Awaited<U>>

Generated using TypeDoc