Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1x 1x 1x 5x 5x 4x 4x 22x 4x 4x 4x 1x | // https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_chunk // eslint-disable-next-line @typescript-eslint/no-explicit-any const chunk = <T>(input: T[], size: number): T[][] => { // Eject early if we're attempting to divide up items into arrays of length zero. if (size === 0) return []; return input.reduce<T[][]>( (arr, item, i) => i % size === 0 ? [...arr, [item]] : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]], [] ); }; export default chunk; |