@newdash/newdash
Version:
javascript/typescript utility library
23 lines (22 loc) • 619 B
TypeScript
/**
* Creates an array of elements split into groups the length of `size`.
* If `array` can't be split evenly, the final chunk will be the remaining
* elements.
*
* @since 5.18.0
* @category Array
* @param array The array to process.
* @param size The length of each chunk, default is 1
* @returns Returns the new array of chunks.
* @example
*
* ```js
* chunk(['a', 'b', 'c', 'd'], 2)
* // => [['a', 'b'], ['c', 'd']]
*
* chunk(['a', 'b', 'c', 'd'], 3)
* // => [['a', 'b', 'c'], ['d']]
* ```
*/
export declare function chunk<T>(array: Array<T>, size?: number): Array<Array<T>>;
export default chunk;