• Returns a new IEnumerable with all sub-iterable elements concatenated into it one level deep.

    Example

    const items = [1, 2, [3, 4, [5, []]]];
    const res = from(items).flatten(); // [1, 2, 3, 4, [5, []]]

    Typeparam

    TSource The type of the source iterable.

    Returns

    A new IEnumerable with all sub-iterable elements concatenated into it recursively up.

    Type Parameters

    • TSource

    Parameters

    • src: Iterable<TSource>

      The source iterable.

    Returns IEnumerable<FlatIterable<Iterable<TSource>, 1>>

  • Returns a new IEnumerable with all sub-iterable elements concatenated into it recursively up to the specified depth.

    Example

    const items = [1, 2, [3, 4, [5, []]]];
    const res = from(items).flatten(2); // [1, 2, 3, 4, 5, []]

    Typeparam

    TSource The type of the source iterable.

    Returns

    A new IEnumerable with all sub-iterable elements concatenated into it recursively up.

    Type Parameters

    • TSource

    • Depth extends number

    Parameters

    • src: Iterable<TSource>

      The source iterable.

    • depth: Depth

      The depth to flatten to.

    Returns IEnumerable<FlatIterable<Iterable<TSource>, Depth>>

Generated using TypeDoc