Level 39

emit doesn't wait

An async listener awaits before it logs. Does emit wait for it?

const { EventEmitter } = require('node:events');const bus = new EventEmitter();bus.on('save', async () => {  await null;  console.log('saved');});bus.emit('save');console.log('emit returned');

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…