blob: de1151c038f1d917a683fbdd41e667b1548fdf1d (
plain)
1
2
3
4
5
6
7
8
9
10
|
export function chunk<T = any>(list: T[], len: number) {
if (len <= 0) {
throw new Error();
}
const result: T[][] = [];
for (let i = 0; i < list.length; i += len) {
result.push(list.slice(i, i + len));
}
return result;
}
|