think/packages/client/src/helpers/chunk.ts

11 lines
214 B
TypeScript

export function chunk<T>(arr: Array<T>, size = 1) {
const res: Array<T[]> = [];
for (let i = 0; i < arr.length; i += size) {
const slice = arr.slice(i, i + size);
res.push(slice);
}
return res;
}