Created
May 7, 2020 14:23
Revisions
-
hail2u created this gist
May 7, 2020 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ 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();