diginext-utils
Version:
README.md
17 lines • 535 B
TypeScript
/**
* Splits an array into chunks of a specified size.
*
* @template T - The type of elements in the array
* @param array - The array to chunk
* @param size - The size of each chunk (must be positive)
* @returns An array of chunks
*
* @example
* ```ts
* chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
* chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]
* chunk([1, 2, 3], 1); // [[1], [2], [3]]
* ```
*/
export declare function chunk<T>(array: T[], size: number): T[][];
//# sourceMappingURL=chunk.d.ts.map