ts-prime
Version:
A utility library for JavaScript and Typescript.
27 lines • 860 B
TypeScript
/**
* Splits a given array at a given index.
* @param array the array to split
* @param index the index to split at
* @signature
* P.splitAt(array, index)
* @example
* P.splitAt([1, 2, 3], 1) // => [[1], [2, 3]]
* P.splitAt([1, 2, 3, 4, 5], -1) // => [[1, 2, 3, 4], [5]]
* @data_first
* @category Array
*/
export declare function splitAt<T>(array: readonly T[], index: number): [T[], T[]];
/**
* Splits a given array at a given index.
* @param array the array to split
* @param index the index to split at
* @signature
* P.splitAt(index)(array)
* @example
* P.splitAt(1)([1, 2, 3]) // => [[1], [2, 3]]
* P.splitAt(-1)([1, 2, 3, 4, 5]) // => [[1, 2, 3, 4], [5]]
* @data_last
* @category Array
*/
export declare function splitAt<T>(index: number): (array: readonly T[]) => [T[], T[]];
//# sourceMappingURL=splitAt.d.ts.map