Created
February 15, 2017 22:58
-
-
Save xMartin/6710a60c12a2f06491d8ef92e2c70a69 to your computer and use it in GitHub Desktop.
Running n async operations sequentially in JavaScript with Promises (note the re-assignment of `promise`)
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
const n = 10 | |
let promise = Promise.resolve() | |
for (let i = 0; i < n; ++i) | |
promise = promise.then(doSomethingAsync) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment