This repository has been archived on 2023-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
chainsafe-bls/test/unit/multithread/naive/utils.ts

11 lines
282 B
TypeScript
Raw Permalink Normal View History

export function chunkify<T>(arr: T[], chunkCount: number): T[][] {
const chunkSize = Math.round(arr.length / chunkCount);
const arrArr: T[][] = [];
for (let i = 0, j = arr.length; i < j; i += chunkSize) {
arrArr.push(arr.slice(i, i + chunkSize));
}
return arrArr;
}