Skip to content

Instantly share code, notes, and snippets.

@rodrigograca31
Last active October 11, 2020 21:33
Show Gist options
  • Save rodrigograca31/3377f34685d7740febb551b3c0b42585 to your computer and use it in GitHub Desktop.
Save rodrigograca31/3377f34685d7740febb551b3c0b42585 to your computer and use it in GitHub Desktop.
Turn Events into Promises in JavaScript
const events = [download, download2];
const promises = events.map((event) => {
return new Promise((resolve) => {
event.on("end", (paths) => {
resolve(paths);
});
});
});
Promise.all(promises).then((result) => {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment