Function split

  • Breaks an array into an array of two arrays. The first contains the elements before index, and the second contains the elements at index and thereafter.

    Remarks

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

    Example

    import * as A from "flurp/array";

    const split = A.split(3);
    split([0, 1, 2, 3, 4]); // [[0, 1, 2], [3, 4]]

    const splitLast = A.split(-1);
    splitLast([0, 1, 2, 3, 4]); // [[0, 1, 2, 3], [4]]

    Type Parameters

    • T

    Parameters

    • index: number

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

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

        • arr: readonly T[]

        Returns null | T[][]