radix-vue
Version:
Vue port for Radix UI Primitives.
13 lines (12 loc) • 437 B
TypeScript
/**
* Splits an array into chunks of a given size.
* @param arr The array to split.
* @param size The size of each chunk.
* @returns An array of arrays, where each sub-array has `size` elements from the original array.
* @example ```ts
* const arr = [1, 2, 3, 4, 5, 6, 7, 8];
* const chunks = chunk(arr, 3);
* // chunks = [[1, 2, 3], [4, 5, 6], [7, 8]]
* ```
*/
export declare function chunk<T>(arr: T[], size: number): T[][];