Created
May 13, 2020 10:37
-
-
Save mafintosh/882235c9a76efc09c7ba9af2d18fa29f to your computer and use it in GitHub Desktop.
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 = new require('events') | |
const { once } = events | |
const e = new events.EventEmitter() | |
main() | |
async function main () { | |
await once(e, 'foo') | |
console.log('foo was emitted') | |
await once(e, 'bar') | |
console.log('bar was emitted') | |
} | |
e.emit('foo') | |
e.emit('bar') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment