Function mapSync

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

    Returns

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

    Example

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

    for (const x of mappedSyncIterable) {
    console.log(x); // Logs 2, 4, 6
    }

    Remarks

    Available as map when imported from peter-piper/sync.

    Type Parameters

    • T

      The type of elements in the input sync 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: Iterable<T>) => Iterable<U>)

      • (input: Iterable<T>): Iterable<U>
      • Parameters

        • input: Iterable<T>

        Returns Iterable<U>

Generated using TypeDoc