Function flatSync

  • Flattens an input sync iterable up to a specified depth. 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], [4, [5]]];
    const flatSyncIterable = flatSync<number>(1)(input);

    for (const x of flatSyncIterable) {
    console.log(x); // Logs 1, 2, 3, 4, [5]
    }

    Remarks

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

    Type Parameters

    • T

      The type of elements in the input sync iterable.

    • D extends number = 1

      The depth of flattening.

    Parameters

    • Optional depth: D

      The depth of flattening, defaults to 1.

    Returns ((input: Iterable<T>) => FlatIterable<T, D>)

Generated using TypeDoc