Skip to content

Instantly share code, notes, and snippets.

@schahriar
Created January 15, 2018 08:57
Show Gist options
  • Save schahriar/ba4e45ee1b14aa453350667f37cbe012 to your computer and use it in GitHub Desktop.
Save schahriar/ba4e45ee1b14aa453350667f37cbe012 to your computer and use it in GitHub Desktop.
In-flight promises #async-await #medium
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