Skip to main content
EventEmitter.prependOnceListener - node__events.d.ts - Node documentation
method EventEmitter.prependOnceListener

Usage in Deno

```typescript import { type EventEmitter } from "node:node__events.d.ts"; ```
EventEmitter.prependOnceListener<K>(
eventName: Key<K, T>,
listener: Listener1<K, T>,
): this
Adds a **one-time**`listener` 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. ```js 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