eventNames
This release ships with a new method called eventNames
. It returns an array listing the events for which the emitter has registered listeners. The values in the array will be strings or Symbols.
const EventEmitter = require('eventemitter3');
const ee = new EventEmitter();
ee.on('foo', () => {});
ee.on('bar', () => {});
ee.on(Symbol('s'), () => {});
console.log(ee.eventNames());
// => [ 'foo', 'bar', Symbol(s) ]