Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.
Symbol
import { EventEmitter } from 'node:events';const myEE = new EventEmitter();myEE.on('foo', () => {});myEE.on('bar', () => {});const sym = Symbol('symbol');myEE.on(sym, () => {});console.log(myEE.eventNames());// Prints: [ 'foo', 'bar', Symbol(symbol) ] Copy
import { EventEmitter } from 'node:events';const myEE = new EventEmitter();myEE.on('foo', () => {});myEE.on('bar', () => {});const sym = Symbol('symbol');myEE.on(sym, () => {});console.log(myEE.eventNames());// Prints: [ 'foo', 'bar', Symbol(symbol) ]
v6.0.0
Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or
Symbol
s.