typedash
Version:
modern, type-safe collection of utility functions
20 lines (17 loc) • 540 B
text/typescript
import { M as Maybe } from '../Maybe-D6dwMjD9.cjs';
/**
* Splits an array into chunks of the given size.
* @param array The array to split.
* @param size The maximum size of each chunk.
* @returns An array of arrays where each sub-array has at most `size` elements.
* @example
* ```ts
* chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]
* ```
*/
declare function chunk<T>(array: Maybe<readonly T[]>, size: number): T[][];
/**
* Alias for {@link chunk}.
*/
declare const chunkArray: typeof chunk;
export { chunk, chunkArray };