Level 34

once fires once

One once listener, one on listener, and two emits.

const { EventEmitter } = require('node:events');const bus = new EventEmitter();bus.once('ping', () => console.log('once'));bus.on('ping', () => console.log('always'));bus.emit('ping');bus.emit('ping');

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…