/** * @file Split an array into fixed-size chunks. The last chunk holds the * leftover when length is not evenly divisible. */ /** * Split an array into chunks of a specified size. * * Divides an array into smaller arrays of the specified chunk size. The last * chunk may contain fewer elements if the array length is not evenly divisible * by the chunk size. * * @example * ;```ts * // Split into pairs (default) * arrayChunk([1, 2, 3, 4, 5]) * // Returns: [[1, 2], [3, 4], [5]] * * // Split into groups of 3 * arrayChunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3) * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']] * * // Works with readonly arrays * const readonlyArr = [1, 2, 3] as const * arrayChunk(readonlyArr) * // Returns: [[1, 2], [3]] * ``` * * @default 2 * * @param arr - The array to split into chunks. May be readonly. * @param size - Size of each chunk. Must be greater than 0. * * @returns Array of chunks, where each chunk is an array of elements * * @throws {Error} If chunk size is less than or equal to 0 */ export declare function arrayChunk(arr: T[] | readonly T[], size?: number | undefined): T[][];