Events

EventEmitter.listeners()

Returns a separate array containing the registered listener functions. Tested on Node.js 22.16.0. Changing the returned array does not unregister listeners; use off with the original handler.

Formal Syntax & Structure

nodejs syntaxnodejs
emitter.listeners(eventName)

Parameters & Attributes

NameTypeDescription
eventNamestring | symbolName of the event.

Return Value

Function[]

Snapshot of listeners.

Working Example

Example Snippetnodejs
import { EventEmitter } from 'node:events';const bus=new EventEmitter();const h=()=>{};bus.once('ready',h);const list=bus.listeners('ready');list.pop();console.log(bus.listenerCount('ready'));
Node.js Reference