Deprecated
Since v3.2.0 - Use listenerCount
instead.
import { listenerCount } from "https://dotland.deno.dev/std@0.177.0/node/events.ts";
A class method that returns the number of listeners for the given eventName
registered on the given emitter
.
const { EventEmitter, listenerCount } = require('events');
const myEmitter = new EventEmitter();
myEmitter.on('event', () => {});
myEmitter.on('event', () => {});
console.log(listenerCount(myEmitter, 'event'));
// Prints: 2