Mlisteners
Bun

method

http.Server.listeners

listeners<E extends keyof ServerEventMap<typeof IncomingMessage, typeof ServerResponse>>(
eventName: E
): (...args: ServerEventMap<Request, Response>[E]) => void[];

Returns a copy of the array of listeners for the event named eventName.

server.on('connection', (stream) => {
  console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]
eventName: string | symbol
): (...args: any[]) => void[];

Returns a copy of the array of listeners for the event named eventName.

server.on('connection', (stream) => {
  console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]