Last active
September 27, 2019 08:34
-
-
Save lannex/46c34d35ebed1a2301ea8f40f8331bcf to your computer and use it in GitHub Desktop.
Async loops
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 characters
async function parallel(array) { | |
const promises = array.map(item => delay(item)); | |
await Promise.all(promises); | |
} |
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 characters
async function serial(array) { | |
for (const item of array) { | |
await delay(item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment