Created
November 13, 2017 15:31
-
-
Save delucis/df9dc09870861deceb4d4134b81ebe76 to your computer and use it in GitHub Desktop.
Asynchronous, parallel 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
// ES7 with async/await and Promise.all | |
async function loopIt(array) { | |
await Promise.all(array.map(async member => { | |
// asyncStuff() will be called in parallel for all array members | |
let result = await asyncStuff(member) | |
})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment