Created
January 15, 2018 08:57
-
-
Save schahriar/ba4e45ee1b14aa453350667f37cbe012 to your computer and use it in GitHub Desktop.
In-flight promises #async-await #medium
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 (promises) => { | |
let inFlight = new Set(); | |
return promises.map((promise) => { | |
// Add promise to inFlight Set | |
inFlight.add(promise); | |
// Delete promise from Set when it is done | |
promise.then(() => inFlight.delete(promise)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment