Last active
October 11, 2020 21:33
-
-
Save rodrigograca31/3377f34685d7740febb551b3c0b42585 to your computer and use it in GitHub Desktop.
Turn Events into Promises in JavaScript
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 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