Created
September 6, 2020 16:46
-
-
Save ArsenyYankovsky/5891d5efc2b2ae0bfeb22a94c3bf376a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 characters
export const saveBooks = async (books) => { | |
const chunks = chunk(chunk(books, 100), 10) | |
const results = [] | |
for (const chunkOfChunks of chunks) { | |
const chunkResults = await Promise.all(chunkOfChunks.map(saveBooksChunk)) | |
results.push(...chunkResults) | |
} | |
return results | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment