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

Usage in Deno

```typescript import { type EventEmitter } from "node:node__events.d.ts"; ```
EventEmitter.prependListener<K>(
eventName: Key<K, T>,
listener: Listener1<K, T>,
): this
Adds the `listener` function to the _beginning_ of the listeners array for the event named `eventName`. No checks are made to see if the `listener` has already been added. Multiple calls passing the same combination of `eventName` and `listener` will result in the `listener` being added, and called, multiple times. ```js server.prependListener('connection', (stream) => { console.log('someone connected!'); }); ``` 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