Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const to8Chunks = (previous, current, index) => {
const remainder = index % 8;
if (!previous[remainder]) {
previous.push([]);
}
previous[remainder].push(current);
return previous;
};
const main = async () => {
const hugeArray = [];
const hugeChunks = hugeArray.reduce(to8Chunks, []);
let r = [];
for (const hugeChunk of hugeChunks) {
r = r.concat(await Promise.all(hugeChunk.map(doSomething)));
}
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.