Created
July 11, 2018 02:30
-
-
Save hubertcross/481dcda7e563ad2fa3e26eacef9cd5c4 to your computer and use it in GitHub Desktop.
How to do async for each loop!!
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
| async function asyncForEach(array, callback) { | |
| const results = []; | |
| for (let index = 0; index < array.length; index += | |
| results.push(callback(array[index], index, array) | |
| } | |
| await Promise.all(results); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment