Skip to content

splitAt

splitAt(index): <A>(data) => readonly [readonly A[], readonly A[]]

Defined in: Utils/Arr.ts:656

Splits an array at an index into a [before, after] tuple. Negative indices clamp to 0; indices beyond the array length clamp to the end.

number

<A>(data): readonly [readonly A[], readonly A[]]

A

readonly A[]

readonly [readonly A[], readonly A[]]

pipe([1, 2, 3, 4], Arr.splitAt(2)); // [[1, 2], [3, 4]]
pipe([1, 2, 3], Arr.splitAt(0));    // [[], [1, 2, 3]]
pipe([1, 2, 3], Arr.splitAt(10));   // [[1, 2, 3], []]