-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert some async loops into parallel loops
If you use `await` inside a loop it makes the loop inherently serial. If you omit the `await` however, the tasks will all start but the loop will finish while the tasks are still being scheduled. So, to make a set of tasks run in parallel but then have the code block after the loop once all the tasks have been completed you have to get an array of Promises (one for each iteration) and then use `Promise.all()` to wait for those promises to be resolved. Using `Array#map` is a convenient way to go from an array of inputs to the require array of Promises.
- Loading branch information
Showing
2 changed files
with
52 additions
and
49 deletions.
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 characters
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