Events

EventEmitter.eventNames()

Lists event keys with registered listeners. Tested on Node.js 22.16.0. Inspect names to diagnose forgotten subscriptions; never log sensitive event payloads by default.

Formal Syntax & Structure

nodejs syntaxnodejs
emitter.eventNames()

Return Value

(string | symbol)[]

Registered event names.

Working Example

Example Snippetnodejs
import { EventEmitter } from 'node:events';const bus=new EventEmitter();bus.on('ready',()=>{});bus.on('closed',()=>{});console.log(JSON.stringify(bus.eventNames().sort()));
Node.js Reference