Function splitMulti

  • Breaks an array into an array of arrays. The indices are where each new array begins.

    Remarks

    Negative indices count backwards from the end of the array. Returns null if any index is fractional or NaN.

    Example

    import * as A from "flurp/array";

    const splitFirstAndLastPairs = A/split(2, -2);
    splitFirstAndLastPairs([0, 1, 2, 3, 4, 5, 6, 7]); // [[0, 1], [2, 3, 4], [6, 7]]

    Type Parameters

    • T

    Parameters

    • indices: number[]

    Returns ((arr: readonly T[]) => null | T[][])

      • (arr: readonly T[]): null | T[][]
      • Parameters

        • arr: readonly T[]

        Returns null | T[][]