Skip to content

Instantly share code, notes, and snippets.

@hail2u
Created May 7, 2020 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hail2u/65ec366a067763755efc9a73a4c5aca7 to your computer and use it in GitHub Desktop.
Save hail2u/65ec366a067763755efc9a73a4c5aca7 to your computer and use it in GitHub Desktop.
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