Skip to main content
EventEmitter.eventNames - events - Node documentation
method EventEmitter.eventNames

Usage in Deno

import { type EventEmitter } from "node:events";
EventEmitter.eventNames(): Array<(string | symbol) & Key2<unknown, T>>

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

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

Return Type

Array<(string | symbol) & Key2<unknown, T>>