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

Usage in Deno

import { type EventEmitter } from "node:events";
EventEmitter.prependOnceListener<K>(
eventName: Key<K, T>,
listener: Listener1<K, T>,
): this

Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

server.prependOnceListener('connection', (stream) => {
  console.log('Ah, we have our first user!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

Type Parameters

K

Parameters

eventName: Key<K, T>

The name of the event.

listener: Listener1<K, T>

The callback function

Return Type

this