@types/node 25.0.1 → 25.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. node/README.md +1 -1
  2. node/events.d.ts +390 -382
  3. node/package.json +2 -2
  4. node/process.d.ts +5 -0
node/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 12 Dec 2025 00:47:02 GMT
11
+ * Last updated: Tue, 16 Dec 2025 21:35:18 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/events.d.ts CHANGED
@@ -88,376 +88,390 @@ declare module "node:events" {
88
88
  */
89
89
  class EventEmitter<T extends EventMap<T> = any> {
90
90
  constructor(options?: EventEmitterOptions);
91
- /**
92
- * The `Symbol.for('nodejs.rejection')` method is called in case a
93
- * promise rejection happens when emitting an event and
94
- * `captureRejections` is enabled on the emitter.
95
- * It is possible to use `events.captureRejectionSymbol` in
96
- * place of `Symbol.for('nodejs.rejection')`.
97
- *
98
- * ```js
99
- * import { EventEmitter, captureRejectionSymbol } from 'node:events';
100
- *
101
- * class MyClass extends EventEmitter {
102
- * constructor() {
103
- * super({ captureRejections: true });
104
- * }
105
- *
106
- * [captureRejectionSymbol](err, event, ...args) {
107
- * console.log('rejection happened for', event, 'with', err, ...args);
108
- * this.destroy(err);
109
- * }
110
- *
111
- * destroy(err) {
112
- * // Tear the resource down here.
113
- * }
114
- * }
115
- * ```
116
- * @since v13.4.0, v12.16.0
117
- */
118
- [EventEmitter.captureRejectionSymbol]?(error: Error, event: string | symbol, ...args: any[]): void;
119
- /**
120
- * Alias for `emitter.on(eventName, listener)`.
121
- * @since v0.1.26
122
- */
123
- addListener<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
124
- /**
125
- * Synchronously calls each of the listeners registered for the event named
126
- * `eventName`, in the order they were registered, passing the supplied arguments
127
- * to each.
128
- *
129
- * Returns `true` if the event had listeners, `false` otherwise.
130
- *
131
- * ```js
132
- * import { EventEmitter } from 'node:events';
133
- * const myEmitter = new EventEmitter();
134
- *
135
- * // First listener
136
- * myEmitter.on('event', function firstListener() {
137
- * console.log('Helloooo! first listener');
138
- * });
139
- * // Second listener
140
- * myEmitter.on('event', function secondListener(arg1, arg2) {
141
- * console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
142
- * });
143
- * // Third listener
144
- * myEmitter.on('event', function thirdListener(...args) {
145
- * const parameters = args.join(', ');
146
- * console.log(`event with parameters ${parameters} in third listener`);
147
- * });
148
- *
149
- * console.log(myEmitter.listeners('event'));
150
- *
151
- * myEmitter.emit('event', 1, 2, 3, 4, 5);
152
- *
153
- * // Prints:
154
- * // [
155
- * // [Function: firstListener],
156
- * // [Function: secondListener],
157
- * // [Function: thirdListener]
158
- * // ]
159
- * // Helloooo! first listener
160
- * // event with parameters 1, 2 in second listener
161
- * // event with parameters 1, 2, 3, 4, 5 in third listener
162
- * ```
163
- * @since v0.1.26
164
- */
165
- emit<E extends string | symbol>(eventName: EventNames<T, E>, ...args: Args<T, E>): boolean;
166
- /**
167
- * Returns an array listing the events for which the emitter has registered
168
- * listeners.
169
- *
170
- * ```js
171
- * import { EventEmitter } from 'node:events';
172
- *
173
- * const myEE = new EventEmitter();
174
- * myEE.on('foo', () => {});
175
- * myEE.on('bar', () => {});
176
- *
177
- * const sym = Symbol('symbol');
178
- * myEE.on(sym, () => {});
179
- *
180
- * console.log(myEE.eventNames());
181
- * // Prints: [ 'foo', 'bar', Symbol(symbol) ]
182
- * ```
183
- * @since v6.0.0
184
- */
185
- eventNames(): (string | symbol)[];
186
- /**
187
- * Returns the current max listener value for the `EventEmitter` which is either
188
- * set by `emitter.setMaxListeners(n)` or defaults to
189
- * `events.defaultMaxListeners`.
190
- * @since v1.0.0
191
- */
192
- getMaxListeners(): number;
193
- /**
194
- * Returns the number of listeners listening for the event named `eventName`.
195
- * If `listener` is provided, it will return how many times the listener is found
196
- * in the list of the listeners of the event.
197
- * @since v3.2.0
198
- * @param eventName The name of the event being listened for
199
- * @param listener The event handler function
200
- */
201
- listenerCount<E extends string | symbol>(eventName: EventNames<T, E>, listener?: Listener<T, E>): number;
202
- /**
203
- * Returns a copy of the array of listeners for the event named `eventName`.
204
- *
205
- * ```js
206
- * server.on('connection', (stream) => {
207
- * console.log('someone connected!');
208
- * });
209
- * console.log(util.inspect(server.listeners('connection')));
210
- * // Prints: [ [Function] ]
211
- * ```
212
- * @since v0.1.26
213
- */
214
- listeners<E extends string | symbol>(eventName: EventNames<T, E>): Listener<T, E>[];
215
- /**
216
- * Alias for `emitter.removeListener()`.
217
- * @since v10.0.0
218
- */
219
- off<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
220
- /**
221
- * Adds the `listener` function to the end of the listeners array for the
222
- * event named `eventName`. No checks are made to see if the `listener` has
223
- * already been added. Multiple calls passing the same combination of `eventName`
224
- * and `listener` will result in the `listener` being added, and called, multiple
225
- * times.
226
- *
227
- * ```js
228
- * server.on('connection', (stream) => {
229
- * console.log('someone connected!');
230
- * });
231
- * ```
232
- *
233
- * Returns a reference to the `EventEmitter`, so that calls can be chained.
234
- *
235
- * By default, event listeners are invoked in the order they are added. The
236
- * `emitter.prependListener()` method can be used as an alternative to add the
237
- * event listener to the beginning of the listeners array.
238
- *
239
- * ```js
240
- * import { EventEmitter } from 'node:events';
241
- * const myEE = new EventEmitter();
242
- * myEE.on('foo', () => console.log('a'));
243
- * myEE.prependListener('foo', () => console.log('b'));
244
- * myEE.emit('foo');
245
- * // Prints:
246
- * // b
247
- * // a
248
- * ```
249
- * @since v0.1.101
250
- * @param eventName The name of the event.
251
- * @param listener The callback function
252
- */
253
- on<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
254
- /**
255
- * Adds a **one-time** `listener` function for the event named `eventName`. The
256
- * next time `eventName` is triggered, this listener is removed and then invoked.
257
- *
258
- * ```js
259
- * server.once('connection', (stream) => {
260
- * console.log('Ah, we have our first user!');
261
- * });
262
- * ```
263
- *
264
- * Returns a reference to the `EventEmitter`, so that calls can be chained.
265
- *
266
- * By default, event listeners are invoked in the order they are added. The
267
- * `emitter.prependOnceListener()` method can be used as an alternative to add the
268
- * event listener to the beginning of the listeners array.
269
- *
270
- * ```js
271
- * import { EventEmitter } from 'node:events';
272
- * const myEE = new EventEmitter();
273
- * myEE.once('foo', () => console.log('a'));
274
- * myEE.prependOnceListener('foo', () => console.log('b'));
275
- * myEE.emit('foo');
276
- * // Prints:
277
- * // b
278
- * // a
279
- * ```
280
- * @since v0.3.0
281
- * @param eventName The name of the event.
282
- * @param listener The callback function
283
- */
284
- once<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
285
- /**
286
- * Adds the `listener` function to the _beginning_ of the listeners array for the
287
- * event named `eventName`. No checks are made to see if the `listener` has
288
- * already been added. Multiple calls passing the same combination of `eventName`
289
- * and `listener` will result in the `listener` being added, and called, multiple
290
- * times.
291
- *
292
- * ```js
293
- * server.prependListener('connection', (stream) => {
294
- * console.log('someone connected!');
295
- * });
296
- * ```
297
- *
298
- * Returns a reference to the `EventEmitter`, so that calls can be chained.
299
- * @since v6.0.0
300
- * @param eventName The name of the event.
301
- * @param listener The callback function
302
- */
303
- prependListener<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
304
- /**
305
- * Adds a **one-time** `listener` function for the event named `eventName` to the
306
- * _beginning_ of the listeners array. The next time `eventName` is triggered, this
307
- * listener is removed, and then invoked.
308
- *
309
- * ```js
310
- * server.prependOnceListener('connection', (stream) => {
311
- * console.log('Ah, we have our first user!');
312
- * });
313
- * ```
314
- *
315
- * Returns a reference to the `EventEmitter`, so that calls can be chained.
316
- * @since v6.0.0
317
- * @param eventName The name of the event.
318
- * @param listener The callback function
319
- */
320
- prependOnceListener<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
321
- /**
322
- * Returns a copy of the array of listeners for the event named `eventName`,
323
- * including any wrappers (such as those created by `.once()`).
324
- *
325
- * ```js
326
- * import { EventEmitter } from 'node:events';
327
- * const emitter = new EventEmitter();
328
- * emitter.once('log', () => console.log('log once'));
329
- *
330
- * // Returns a new Array with a function `onceWrapper` which has a property
331
- * // `listener` which contains the original listener bound above
332
- * const listeners = emitter.rawListeners('log');
333
- * const logFnWrapper = listeners[0];
334
- *
335
- * // Logs "log once" to the console and does not unbind the `once` event
336
- * logFnWrapper.listener();
337
- *
338
- * // Logs "log once" to the console and removes the listener
339
- * logFnWrapper();
340
- *
341
- * emitter.on('log', () => console.log('log persistently'));
342
- * // Will return a new Array with a single function bound by `.on()` above
343
- * const newListeners = emitter.rawListeners('log');
344
- *
345
- * // Logs "log persistently" twice
346
- * newListeners[0]();
347
- * emitter.emit('log');
348
- * ```
349
- * @since v9.4.0
350
- */
351
- rawListeners<E extends string | symbol>(eventName: EventNames<T, E>): Listener<T, E>[];
352
- /**
353
- * Removes all listeners, or those of the specified `eventName`.
354
- *
355
- * It is bad practice to remove listeners added elsewhere in the code,
356
- * particularly when the `EventEmitter` instance was created by some other
357
- * component or module (e.g. sockets or file streams).
358
- *
359
- * Returns a reference to the `EventEmitter`, so that calls can be chained.
360
- * @since v0.1.26
361
- */
362
- removeAllListeners<E extends string | symbol>(eventName?: EventNames<T, E>): this;
363
- /**
364
- * Removes the specified `listener` from the listener array for the event named
365
- * `eventName`.
366
- *
367
- * ```js
368
- * const callback = (stream) => {
369
- * console.log('someone connected!');
370
- * };
371
- * server.on('connection', callback);
372
- * // ...
373
- * server.removeListener('connection', callback);
374
- * ```
375
- *
376
- * `removeListener()` will remove, at most, one instance of a listener from the
377
- * listener array. If any single listener has been added multiple times to the
378
- * listener array for the specified `eventName`, then `removeListener()` must be
379
- * called multiple times to remove each instance.
380
- *
381
- * Once an event is emitted, all listeners attached to it at the
382
- * time of emitting are called in order. This implies that any
383
- * `removeListener()` or `removeAllListeners()` calls _after_ emitting and
384
- * _before_ the last listener finishes execution will not remove them from
385
- * `emit()` in progress. Subsequent events behave as expected.
386
- *
387
- * ```js
388
- * import { EventEmitter } from 'node:events';
389
- * class MyEmitter extends EventEmitter {}
390
- * const myEmitter = new MyEmitter();
391
- *
392
- * const callbackA = () => {
393
- * console.log('A');
394
- * myEmitter.removeListener('event', callbackB);
395
- * };
396
- *
397
- * const callbackB = () => {
398
- * console.log('B');
399
- * };
400
- *
401
- * myEmitter.on('event', callbackA);
402
- *
403
- * myEmitter.on('event', callbackB);
404
- *
405
- * // callbackA removes listener callbackB but it will still be called.
406
- * // Internal listener array at time of emit [callbackA, callbackB]
407
- * myEmitter.emit('event');
408
- * // Prints:
409
- * // A
410
- * // B
411
- *
412
- * // callbackB is now removed.
413
- * // Internal listener array [callbackA]
414
- * myEmitter.emit('event');
415
- * // Prints:
416
- * // A
417
- * ```
418
- *
419
- * Because listeners are managed using an internal array, calling this will
420
- * change the position indexes of any listener registered _after_ the listener
421
- * being removed. This will not impact the order in which listeners are called,
422
- * but it means that any copies of the listener array as returned by
423
- * the `emitter.listeners()` method will need to be recreated.
424
- *
425
- * When a single function has been added as a handler multiple times for a single
426
- * event (as in the example below), `removeListener()` will remove the most
427
- * recently added instance. In the example the `once('ping')`
428
- * listener is removed:
429
- *
430
- * ```js
431
- * import { EventEmitter } from 'node:events';
432
- * const ee = new EventEmitter();
433
- *
434
- * function pong() {
435
- * console.log('pong');
436
- * }
437
- *
438
- * ee.on('ping', pong);
439
- * ee.once('ping', pong);
440
- * ee.removeListener('ping', pong);
441
- *
442
- * ee.emit('ping');
443
- * ee.emit('ping');
444
- * ```
445
- *
446
- * Returns a reference to the `EventEmitter`, so that calls can be chained.
447
- * @since v0.1.26
448
- */
449
- removeListener<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
450
- /**
451
- * By default `EventEmitter`s will print a warning if more than `10` listeners are
452
- * added for a particular event. This is a useful default that helps finding
453
- * memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
454
- * modified for this specific `EventEmitter` instance. The value can be set to
455
- * `Infinity` (or `0`) to indicate an unlimited number of listeners.
456
- *
457
- * Returns a reference to the `EventEmitter`, so that calls can be chained.
458
- * @since v0.3.5
459
- */
460
- setMaxListeners(n: number): this;
91
+ }
92
+ interface EventEmitter<T extends EventMap<T> = any> extends NodeJS.EventEmitter<T> {}
93
+ global {
94
+ namespace NodeJS {
95
+ interface EventEmitter<T extends EventMap<T> = any> {
96
+ /**
97
+ * The `Symbol.for('nodejs.rejection')` method is called in case a
98
+ * promise rejection happens when emitting an event and
99
+ * `captureRejections` is enabled on the emitter.
100
+ * It is possible to use `events.captureRejectionSymbol` in
101
+ * place of `Symbol.for('nodejs.rejection')`.
102
+ *
103
+ * ```js
104
+ * import { EventEmitter, captureRejectionSymbol } from 'node:events';
105
+ *
106
+ * class MyClass extends EventEmitter {
107
+ * constructor() {
108
+ * super({ captureRejections: true });
109
+ * }
110
+ *
111
+ * [captureRejectionSymbol](err, event, ...args) {
112
+ * console.log('rejection happened for', event, 'with', err, ...args);
113
+ * this.destroy(err);
114
+ * }
115
+ *
116
+ * destroy(err) {
117
+ * // Tear the resource down here.
118
+ * }
119
+ * }
120
+ * ```
121
+ * @since v13.4.0, v12.16.0
122
+ */
123
+ [EventEmitter.captureRejectionSymbol]?(error: Error, event: string | symbol, ...args: any[]): void;
124
+ /**
125
+ * Alias for `emitter.on(eventName, listener)`.
126
+ * @since v0.1.26
127
+ */
128
+ addListener<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
129
+ /**
130
+ * Synchronously calls each of the listeners registered for the event named
131
+ * `eventName`, in the order they were registered, passing the supplied arguments
132
+ * to each.
133
+ *
134
+ * Returns `true` if the event had listeners, `false` otherwise.
135
+ *
136
+ * ```js
137
+ * import { EventEmitter } from 'node:events';
138
+ * const myEmitter = new EventEmitter();
139
+ *
140
+ * // First listener
141
+ * myEmitter.on('event', function firstListener() {
142
+ * console.log('Helloooo! first listener');
143
+ * });
144
+ * // Second listener
145
+ * myEmitter.on('event', function secondListener(arg1, arg2) {
146
+ * console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
147
+ * });
148
+ * // Third listener
149
+ * myEmitter.on('event', function thirdListener(...args) {
150
+ * const parameters = args.join(', ');
151
+ * console.log(`event with parameters ${parameters} in third listener`);
152
+ * });
153
+ *
154
+ * console.log(myEmitter.listeners('event'));
155
+ *
156
+ * myEmitter.emit('event', 1, 2, 3, 4, 5);
157
+ *
158
+ * // Prints:
159
+ * // [
160
+ * // [Function: firstListener],
161
+ * // [Function: secondListener],
162
+ * // [Function: thirdListener]
163
+ * // ]
164
+ * // Helloooo! first listener
165
+ * // event with parameters 1, 2 in second listener
166
+ * // event with parameters 1, 2, 3, 4, 5 in third listener
167
+ * ```
168
+ * @since v0.1.26
169
+ */
170
+ emit<E extends string | symbol>(eventName: EventNames<T, E>, ...args: Args<T, E>): boolean;
171
+ /**
172
+ * Returns an array listing the events for which the emitter has registered
173
+ * listeners.
174
+ *
175
+ * ```js
176
+ * import { EventEmitter } from 'node:events';
177
+ *
178
+ * const myEE = new EventEmitter();
179
+ * myEE.on('foo', () => {});
180
+ * myEE.on('bar', () => {});
181
+ *
182
+ * const sym = Symbol('symbol');
183
+ * myEE.on(sym, () => {});
184
+ *
185
+ * console.log(myEE.eventNames());
186
+ * // Prints: [ 'foo', 'bar', Symbol(symbol) ]
187
+ * ```
188
+ * @since v6.0.0
189
+ */
190
+ eventNames(): (string | symbol)[];
191
+ /**
192
+ * Returns the current max listener value for the `EventEmitter` which is either
193
+ * set by `emitter.setMaxListeners(n)` or defaults to
194
+ * `events.defaultMaxListeners`.
195
+ * @since v1.0.0
196
+ */
197
+ getMaxListeners(): number;
198
+ /**
199
+ * Returns the number of listeners listening for the event named `eventName`.
200
+ * If `listener` is provided, it will return how many times the listener is found
201
+ * in the list of the listeners of the event.
202
+ * @since v3.2.0
203
+ * @param eventName The name of the event being listened for
204
+ * @param listener The event handler function
205
+ */
206
+ listenerCount<E extends string | symbol>(
207
+ eventName: EventNames<T, E>,
208
+ listener?: Listener<T, E>,
209
+ ): number;
210
+ /**
211
+ * Returns a copy of the array of listeners for the event named `eventName`.
212
+ *
213
+ * ```js
214
+ * server.on('connection', (stream) => {
215
+ * console.log('someone connected!');
216
+ * });
217
+ * console.log(util.inspect(server.listeners('connection')));
218
+ * // Prints: [ [Function] ]
219
+ * ```
220
+ * @since v0.1.26
221
+ */
222
+ listeners<E extends string | symbol>(eventName: EventNames<T, E>): Listener<T, E>[];
223
+ /**
224
+ * Alias for `emitter.removeListener()`.
225
+ * @since v10.0.0
226
+ */
227
+ off<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
228
+ /**
229
+ * Adds the `listener` function to the end of the listeners array for the
230
+ * event named `eventName`. No checks are made to see if the `listener` has
231
+ * already been added. Multiple calls passing the same combination of `eventName`
232
+ * and `listener` will result in the `listener` being added, and called, multiple
233
+ * times.
234
+ *
235
+ * ```js
236
+ * server.on('connection', (stream) => {
237
+ * console.log('someone connected!');
238
+ * });
239
+ * ```
240
+ *
241
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
242
+ *
243
+ * By default, event listeners are invoked in the order they are added. The
244
+ * `emitter.prependListener()` method can be used as an alternative to add the
245
+ * event listener to the beginning of the listeners array.
246
+ *
247
+ * ```js
248
+ * import { EventEmitter } from 'node:events';
249
+ * const myEE = new EventEmitter();
250
+ * myEE.on('foo', () => console.log('a'));
251
+ * myEE.prependListener('foo', () => console.log('b'));
252
+ * myEE.emit('foo');
253
+ * // Prints:
254
+ * // b
255
+ * // a
256
+ * ```
257
+ * @since v0.1.101
258
+ * @param eventName The name of the event.
259
+ * @param listener The callback function
260
+ */
261
+ on<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
262
+ /**
263
+ * Adds a **one-time** `listener` function for the event named `eventName`. The
264
+ * next time `eventName` is triggered, this listener is removed and then invoked.
265
+ *
266
+ * ```js
267
+ * server.once('connection', (stream) => {
268
+ * console.log('Ah, we have our first user!');
269
+ * });
270
+ * ```
271
+ *
272
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
273
+ *
274
+ * By default, event listeners are invoked in the order they are added. The
275
+ * `emitter.prependOnceListener()` method can be used as an alternative to add the
276
+ * event listener to the beginning of the listeners array.
277
+ *
278
+ * ```js
279
+ * import { EventEmitter } from 'node:events';
280
+ * const myEE = new EventEmitter();
281
+ * myEE.once('foo', () => console.log('a'));
282
+ * myEE.prependOnceListener('foo', () => console.log('b'));
283
+ * myEE.emit('foo');
284
+ * // Prints:
285
+ * // b
286
+ * // a
287
+ * ```
288
+ * @since v0.3.0
289
+ * @param eventName The name of the event.
290
+ * @param listener The callback function
291
+ */
292
+ once<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
293
+ /**
294
+ * Adds the `listener` function to the _beginning_ of the listeners array for the
295
+ * event named `eventName`. No checks are made to see if the `listener` has
296
+ * already been added. Multiple calls passing the same combination of `eventName`
297
+ * and `listener` will result in the `listener` being added, and called, multiple
298
+ * times.
299
+ *
300
+ * ```js
301
+ * server.prependListener('connection', (stream) => {
302
+ * console.log('someone connected!');
303
+ * });
304
+ * ```
305
+ *
306
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
307
+ * @since v6.0.0
308
+ * @param eventName The name of the event.
309
+ * @param listener The callback function
310
+ */
311
+ prependListener<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
312
+ /**
313
+ * Adds a **one-time** `listener` function for the event named `eventName` to the
314
+ * _beginning_ of the listeners array. The next time `eventName` is triggered, this
315
+ * listener is removed, and then invoked.
316
+ *
317
+ * ```js
318
+ * server.prependOnceListener('connection', (stream) => {
319
+ * console.log('Ah, we have our first user!');
320
+ * });
321
+ * ```
322
+ *
323
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
324
+ * @since v6.0.0
325
+ * @param eventName The name of the event.
326
+ * @param listener The callback function
327
+ */
328
+ prependOnceListener<E extends string | symbol>(
329
+ eventName: EventNames<T, E>,
330
+ listener: Listener<T, E>,
331
+ ): this;
332
+ /**
333
+ * Returns a copy of the array of listeners for the event named `eventName`,
334
+ * including any wrappers (such as those created by `.once()`).
335
+ *
336
+ * ```js
337
+ * import { EventEmitter } from 'node:events';
338
+ * const emitter = new EventEmitter();
339
+ * emitter.once('log', () => console.log('log once'));
340
+ *
341
+ * // Returns a new Array with a function `onceWrapper` which has a property
342
+ * // `listener` which contains the original listener bound above
343
+ * const listeners = emitter.rawListeners('log');
344
+ * const logFnWrapper = listeners[0];
345
+ *
346
+ * // Logs "log once" to the console and does not unbind the `once` event
347
+ * logFnWrapper.listener();
348
+ *
349
+ * // Logs "log once" to the console and removes the listener
350
+ * logFnWrapper();
351
+ *
352
+ * emitter.on('log', () => console.log('log persistently'));
353
+ * // Will return a new Array with a single function bound by `.on()` above
354
+ * const newListeners = emitter.rawListeners('log');
355
+ *
356
+ * // Logs "log persistently" twice
357
+ * newListeners[0]();
358
+ * emitter.emit('log');
359
+ * ```
360
+ * @since v9.4.0
361
+ */
362
+ rawListeners<E extends string | symbol>(eventName: EventNames<T, E>): Listener<T, E>[];
363
+ /**
364
+ * Removes all listeners, or those of the specified `eventName`.
365
+ *
366
+ * It is bad practice to remove listeners added elsewhere in the code,
367
+ * particularly when the `EventEmitter` instance was created by some other
368
+ * component or module (e.g. sockets or file streams).
369
+ *
370
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
371
+ * @since v0.1.26
372
+ */
373
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
374
+ removeAllListeners<E extends string | symbol>(eventName?: EventNames<T, E>): this;
375
+ /**
376
+ * Removes the specified `listener` from the listener array for the event named
377
+ * `eventName`.
378
+ *
379
+ * ```js
380
+ * const callback = (stream) => {
381
+ * console.log('someone connected!');
382
+ * };
383
+ * server.on('connection', callback);
384
+ * // ...
385
+ * server.removeListener('connection', callback);
386
+ * ```
387
+ *
388
+ * `removeListener()` will remove, at most, one instance of a listener from the
389
+ * listener array. If any single listener has been added multiple times to the
390
+ * listener array for the specified `eventName`, then `removeListener()` must be
391
+ * called multiple times to remove each instance.
392
+ *
393
+ * Once an event is emitted, all listeners attached to it at the
394
+ * time of emitting are called in order. This implies that any
395
+ * `removeListener()` or `removeAllListeners()` calls _after_ emitting and
396
+ * _before_ the last listener finishes execution will not remove them from
397
+ * `emit()` in progress. Subsequent events behave as expected.
398
+ *
399
+ * ```js
400
+ * import { EventEmitter } from 'node:events';
401
+ * class MyEmitter extends EventEmitter {}
402
+ * const myEmitter = new MyEmitter();
403
+ *
404
+ * const callbackA = () => {
405
+ * console.log('A');
406
+ * myEmitter.removeListener('event', callbackB);
407
+ * };
408
+ *
409
+ * const callbackB = () => {
410
+ * console.log('B');
411
+ * };
412
+ *
413
+ * myEmitter.on('event', callbackA);
414
+ *
415
+ * myEmitter.on('event', callbackB);
416
+ *
417
+ * // callbackA removes listener callbackB but it will still be called.
418
+ * // Internal listener array at time of emit [callbackA, callbackB]
419
+ * myEmitter.emit('event');
420
+ * // Prints:
421
+ * // A
422
+ * // B
423
+ *
424
+ * // callbackB is now removed.
425
+ * // Internal listener array [callbackA]
426
+ * myEmitter.emit('event');
427
+ * // Prints:
428
+ * // A
429
+ * ```
430
+ *
431
+ * Because listeners are managed using an internal array, calling this will
432
+ * change the position indexes of any listener registered _after_ the listener
433
+ * being removed. This will not impact the order in which listeners are called,
434
+ * but it means that any copies of the listener array as returned by
435
+ * the `emitter.listeners()` method will need to be recreated.
436
+ *
437
+ * When a single function has been added as a handler multiple times for a single
438
+ * event (as in the example below), `removeListener()` will remove the most
439
+ * recently added instance. In the example the `once('ping')`
440
+ * listener is removed:
441
+ *
442
+ * ```js
443
+ * import { EventEmitter } from 'node:events';
444
+ * const ee = new EventEmitter();
445
+ *
446
+ * function pong() {
447
+ * console.log('pong');
448
+ * }
449
+ *
450
+ * ee.on('ping', pong);
451
+ * ee.once('ping', pong);
452
+ * ee.removeListener('ping', pong);
453
+ *
454
+ * ee.emit('ping');
455
+ * ee.emit('ping');
456
+ * ```
457
+ *
458
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
459
+ * @since v0.1.26
460
+ */
461
+ removeListener<E extends string | symbol>(eventName: EventNames<T, E>, listener: Listener<T, E>): this;
462
+ /**
463
+ * By default `EventEmitter`s will print a warning if more than `10` listeners are
464
+ * added for a particular event. This is a useful default that helps finding
465
+ * memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
466
+ * modified for this specific `EventEmitter` instance. The value can be set to
467
+ * `Infinity` (or `0`) to indicate an unlimited number of listeners.
468
+ *
469
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
470
+ * @since v0.3.5
471
+ */
472
+ setMaxListeners(n: number): this;
473
+ }
474
+ }
461
475
  }
462
476
  namespace EventEmitter {
463
477
  export { EventEmitter, EventEmitterEventMap, EventEmitterOptions };
@@ -592,7 +606,7 @@ declare module "node:events" {
592
606
  * ```
593
607
  * @since v15.2.0, v14.17.0
594
608
  */
595
- function getEventListeners(emitter: NodeJS.EventEmitter, name: string | symbol): ((...args: any[]) => void)[];
609
+ function getEventListeners(emitter: EventEmitter, name: string | symbol): ((...args: any[]) => void)[];
596
610
  function getEventListeners(emitter: EventTarget, name: string): ((...args: any[]) => void)[];
597
611
  /**
598
612
  * Returns the currently set max amount of listeners.
@@ -622,7 +636,7 @@ declare module "node:events" {
622
636
  * ```
623
637
  * @since v19.9.0
624
638
  */
625
- function getMaxListeners(emitter: NodeJS.EventEmitter | EventTarget): number;
639
+ function getMaxListeners(emitter: EventEmitter | EventTarget): number;
626
640
  /**
627
641
  * A class method that returns the number of listeners for the given `eventName`
628
642
  * registered on the given `emitter`.
@@ -641,7 +655,7 @@ declare module "node:events" {
641
655
  * @param emitter The emitter to query
642
656
  * @param eventName The event name
643
657
  */
644
- function listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
658
+ function listenerCount(emitter: EventEmitter, eventName: string | symbol): number;
645
659
  interface OnOptions extends Abortable {
646
660
  /**
647
661
  * Names of events that will end the iteration.
@@ -721,7 +735,7 @@ declare module "node:events" {
721
735
  * @returns `AsyncIterator` that iterates `eventName` events emitted by the `emitter`
722
736
  */
723
737
  function on(
724
- emitter: NodeJS.EventEmitter,
738
+ emitter: EventEmitter,
725
739
  eventName: string | symbol,
726
740
  options?: OnOptions,
727
741
  ): NodeJS.AsyncIterator<any[]>;
@@ -812,7 +826,7 @@ declare module "node:events" {
812
826
  * @since v11.13.0, v10.16.0
813
827
  */
814
828
  function once(
815
- emitter: NodeJS.EventEmitter,
829
+ emitter: EventEmitter,
816
830
  eventName: string | symbol,
817
831
  options?: OnceOptions,
818
832
  ): Promise<any[]>;
@@ -833,7 +847,7 @@ declare module "node:events" {
833
847
  * max for all newly created `EventTarget` and `EventEmitter` objects.
834
848
  * objects.
835
849
  */
836
- function setMaxListeners(n: number, ...eventTargets: ReadonlyArray<NodeJS.EventEmitter | EventTarget>): void;
850
+ function setMaxListeners(n: number, ...eventTargets: ReadonlyArray<EventEmitter | EventTarget>): void;
837
851
  /**
838
852
  * This is the interface from which event-emitting Node.js APIs inherit in the types package.
839
853
  * **It is not intended for consumer use.**
@@ -1032,12 +1046,6 @@ declare module "node:events" {
1032
1046
  [K in keyof T & string as `on${K}`]: ((ev: T[K]) => void) | null;
1033
1047
  };
1034
1048
  }
1035
- global {
1036
- import _ = EventEmitter;
1037
- namespace NodeJS {
1038
- interface EventEmitter<T extends EventMap<T> = any> extends _<T> {}
1039
- }
1040
- }
1041
1049
  export = EventEmitter;
1042
1050
  }
1043
1051
  declare module "events" {
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "25.0.1",
3
+ "version": "25.0.3",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -150,6 +150,6 @@
150
150
  "undici-types": "~7.16.0"
151
151
  },
152
152
  "peerDependencies": {},
153
- "typesPublisherContentHash": "ebf0dcd736cafaf9afe481dddb915eac63d9cd45eddc1dd09e32c138468b5a0b",
153
+ "typesPublisherContentHash": "f232fc4d25235ca95f233b42be2cfd08c384791f716e60e2c105ff6db6b0bdc4",
154
154
  "typeScriptVersion": "5.2"
155
155
  }
node/process.d.ts CHANGED
@@ -1826,6 +1826,11 @@ declare module "node:process" {
1826
1826
  * @param args Additional arguments to pass when invoking the `callback`
1827
1827
  */
1828
1828
  nextTick(callback: Function, ...args: any[]): void;
1829
+ /**
1830
+ * The process.noDeprecation property indicates whether the --no-deprecation flag is set on the current Node.js process.
1831
+ * See the documentation for the ['warning' event](https://nodejs.org/docs/latest/api/process.html#event-warning) and the [emitWarning()](https://nodejs.org/docs/latest/api/process.html#processemitwarningwarning-type-code-ctor) method for more information about this flag's behavior.
1832
+ */
1833
+ noDeprecation?: boolean;
1829
1834
  /**
1830
1835
  * This API is available through the [--permission](https://nodejs.org/api/cli.html#--permission) flag.
1831
1836
  *