Skip to content

eventNames

Compare
Choose a tag to compare
@lpinca lpinca released this 17 Mar 07:24
· 202 commits to master since this release

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) ]