Skip to content

Instantly share code, notes, and snippets.

@mafintosh
Created May 13, 2020 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mafintosh/40ae0b329777fc2208ccfeb09092d8e5 to your computer and use it in GitHub Desktop.
Save mafintosh/40ae0b329777fc2208ccfeb09092d8e5 to your computer and use it in GitHub Desktop.
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