@types/node 24.10.3 → 25.0.1

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 (99) hide show
  1. node v24.10/README.md → node/README.md +2 -2
  2. node v24.10/assert/strict.d.ts → node/assert/strict.d.ts +5 -11
  3. node v24.10/assert.d.ts → node/assert.d.ts +9 -169
  4. node v24.10/async_hooks.d.ts → node/async_hooks.d.ts +8 -8
  5. node v24.10/buffer.buffer.d.ts → node/buffer.buffer.d.ts +1 -7
  6. node v24.10/buffer.d.ts → node/buffer.d.ts +44 -168
  7. node v24.10/child_process.d.ts → node/child_process.d.ts +16 -64
  8. node/cluster.d.ts +486 -0
  9. node/console.d.ts +151 -0
  10. node v24.10/constants.d.ts → node/constants.d.ts +3 -4
  11. node v24.10/crypto.d.ts → node/crypto.d.ts +279 -1631
  12. node v24.10/dgram.d.ts → node/dgram.d.ts +15 -51
  13. node v24.10/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +4 -4
  14. node v24.10/dns/promises.d.ts → node/dns/promises.d.ts +3 -3
  15. node v24.10/dns.d.ts → node/dns.d.ts +131 -132
  16. node v24.10/domain.d.ts → node/domain.d.ts +13 -17
  17. node/events.d.ts +1046 -0
  18. node v24.10/fs/promises.d.ts → node/fs/promises.d.ts +7 -8
  19. node v24.10/fs.d.ts → node/fs.d.ts +417 -455
  20. node v24.10/globals.d.ts → node/globals.d.ts +6 -26
  21. node/globals.typedarray.d.ts +101 -0
  22. node v24.10/http.d.ts → node/http.d.ts +263 -254
  23. node v24.10/http2.d.ts → node/http2.d.ts +528 -804
  24. node v24.10/https.d.ts → node/https.d.ts +59 -239
  25. node v24.10/index.d.ts → node/index.d.ts +15 -1
  26. node/inspector/promises.d.ts +41 -0
  27. node v24.10/inspector.d.ts → node/inspector.d.ts +6 -59
  28. node v24.10/inspector.generated.d.ts → node/inspector.generated.d.ts +3 -10
  29. node v24.10/module.d.ts → node/module.d.ts +47 -122
  30. node v24.10/net.d.ts → node/net.d.ts +63 -184
  31. node v24.10/os.d.ts → node/os.d.ts +6 -6
  32. node v24.10/package.json → node/package.json +2 -2
  33. node/path/posix.d.ts +8 -0
  34. node/path/win32.d.ts +8 -0
  35. node/path.d.ts +187 -0
  36. node/perf_hooks.d.ts +621 -0
  37. node v24.10/process.d.ts → node/process.d.ts +151 -128
  38. node v24.10/punycode.d.ts → node/punycode.d.ts +5 -5
  39. node v24.10/querystring.d.ts → node/querystring.d.ts +4 -4
  40. node/quic.d.ts +910 -0
  41. node v24.10/readline/promises.d.ts → node/readline/promises.d.ts +3 -3
  42. node v24.10/readline.d.ts → node/readline.d.ts +67 -120
  43. node v24.10/repl.d.ts → node/repl.d.ts +75 -98
  44. node v24.10/sea.d.ts → node/sea.d.ts +1 -1
  45. node v24.10/sqlite.d.ts → node/sqlite.d.ts +2 -2
  46. node v24.10/stream/consumers.d.ts → node/stream/consumers.d.ts +10 -10
  47. node/stream/promises.d.ts +211 -0
  48. node/stream/web.d.ts +296 -0
  49. node v24.10/stream.d.ts → node/stream.d.ts +555 -478
  50. node v24.10/string_decoder.d.ts → node/string_decoder.d.ts +4 -4
  51. node/test/reporters.d.ts +96 -0
  52. node v24.10/test.d.ts → node/test.d.ts +80 -180
  53. node v24.10/timers/promises.d.ts → node/timers/promises.d.ts +4 -4
  54. node v24.10/timers.d.ts → node/timers.d.ts +4 -130
  55. node v24.10/tls.d.ts → node/tls.d.ts +102 -177
  56. node v24.10/trace_events.d.ts → node/trace_events.d.ts +9 -9
  57. node v24.10/ts5.6/buffer.buffer.d.ts → node/ts5.6/buffer.buffer.d.ts +1 -7
  58. node v24.10/ts5.6/index.d.ts → node/ts5.6/index.d.ts +15 -1
  59. node v24.10/ts5.7/index.d.ts → node/ts5.7/index.d.ts +15 -1
  60. node v24.10/tty.d.ts → node/tty.d.ts +58 -16
  61. node/url.d.ts +519 -0
  62. node/util/types.d.ts +558 -0
  63. node v24.10/util.d.ts → node/util.d.ts +120 -792
  64. node v24.10/v8.d.ts → node/v8.d.ts +32 -5
  65. node v24.10/vm.d.ts → node/vm.d.ts +13 -13
  66. node v24.10/wasi.d.ts → node/wasi.d.ts +4 -4
  67. node v24.10/web-globals/abortcontroller.d.ts → node/web-globals/abortcontroller.d.ts +27 -2
  68. node/web-globals/blob.d.ts +23 -0
  69. node/web-globals/console.d.ts +9 -0
  70. node v24.10/web-globals/crypto.d.ts → node/web-globals/crypto.d.ts +7 -0
  71. node/web-globals/encoding.d.ts +11 -0
  72. node v24.10/web-globals/events.d.ts → node/web-globals/events.d.ts +9 -0
  73. node v24.10/web-globals/fetch.d.ts → node/web-globals/fetch.d.ts +4 -0
  74. node/web-globals/importmeta.d.ts +13 -0
  75. node/web-globals/messaging.d.ts +23 -0
  76. node/web-globals/performance.d.ts +45 -0
  77. node/web-globals/streams.d.ts +115 -0
  78. node/web-globals/timers.d.ts +44 -0
  79. node/web-globals/url.d.ts +24 -0
  80. node v24.10/worker_threads.d.ts → node/worker_threads.d.ts +176 -358
  81. node v24.10/zlib.d.ts → node/zlib.d.ts +8 -71
  82. node v24.10/cluster.d.ts +0 -578
  83. node v24.10/console.d.ts +0 -453
  84. node v24.10/events.d.ts +0 -976
  85. node v24.10/globals.typedarray.d.ts +0 -41
  86. node v24.10/path.d.ts +0 -200
  87. node v24.10/perf_hooks.d.ts +0 -982
  88. node v24.10/stream/promises.d.ts +0 -90
  89. node v24.10/stream/web.d.ts +0 -573
  90. node v24.10/url.d.ts +0 -1057
  91. node v24.10/web-globals/streams.d.ts +0 -22
  92. {node v24.10 → node}/LICENSE +0 -0
  93. {node v24.10 → node}/compatibility/iterators.d.ts +0 -0
  94. {node v24.10 → node}/ts5.6/compatibility/float16array.d.ts +0 -0
  95. {node v24.10 → node}/ts5.6/globals.typedarray.d.ts +0 -0
  96. {node v24.10 → node}/ts5.7/compatibility/float16array.d.ts +0 -0
  97. {node v24.10 → node}/web-globals/domexception.d.ts +0 -0
  98. {node v24.10 → node}/web-globals/navigator.d.ts +0 -0
  99. {node v24.10 → node}/web-globals/storage.d.ts +0 -0
node/events.d.ts ADDED
@@ -0,0 +1,1046 @@
1
+ /**
2
+ * Much of the Node.js core API is built around an idiomatic asynchronous
3
+ * event-driven architecture in which certain kinds of objects (called "emitters")
4
+ * emit named events that cause `Function` objects ("listeners") to be called.
5
+ *
6
+ * For instance: a `net.Server` object emits an event each time a peer
7
+ * connects to it; a `fs.ReadStream` emits an event when the file is opened;
8
+ * a `stream` emits an event whenever data is available to be read.
9
+ *
10
+ * All objects that emit events are instances of the `EventEmitter` class. These
11
+ * objects expose an `eventEmitter.on()` function that allows one or more
12
+ * functions to be attached to named events emitted by the object. Typically,
13
+ * event names are camel-cased strings but any valid JavaScript property key
14
+ * can be used.
15
+ *
16
+ * When the `EventEmitter` object emits an event, all of the functions attached
17
+ * to that specific event are called _synchronously_. Any values returned by the
18
+ * called listeners are _ignored_ and discarded.
19
+ *
20
+ * The following example shows a simple `EventEmitter` instance with a single
21
+ * listener. The `eventEmitter.on()` method is used to register listeners, while
22
+ * the `eventEmitter.emit()` method is used to trigger the event.
23
+ *
24
+ * ```js
25
+ * import { EventEmitter } from 'node:events';
26
+ *
27
+ * class MyEmitter extends EventEmitter {}
28
+ *
29
+ * const myEmitter = new MyEmitter();
30
+ * myEmitter.on('event', () => {
31
+ * console.log('an event occurred!');
32
+ * });
33
+ * myEmitter.emit('event');
34
+ * ```
35
+ * @see [source](https://github.com/nodejs/node/blob/v25.x/lib/events.js)
36
+ */
37
+ declare module "node:events" {
38
+ import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
39
+ // #region Event map helpers
40
+ type EventMap<T> = Record<keyof T, any[]>;
41
+ type IfEventMap<Events extends EventMap<Events>, True, False> = {} extends Events ? False : True;
42
+ type Args<Events extends EventMap<Events>, EventName extends string | symbol> = IfEventMap<
43
+ Events,
44
+ EventName extends keyof Events ? Events[EventName]
45
+ : EventName extends keyof EventEmitterEventMap ? EventEmitterEventMap[EventName]
46
+ : any[],
47
+ any[]
48
+ >;
49
+ type EventNames<Events extends EventMap<Events>, EventName extends string | symbol> = IfEventMap<
50
+ Events,
51
+ EventName | (keyof Events & (string | symbol)) | keyof EventEmitterEventMap,
52
+ string | symbol
53
+ >;
54
+ type Listener<Events extends EventMap<Events>, EventName extends string | symbol> = IfEventMap<
55
+ Events,
56
+ (
57
+ ...args: EventName extends keyof Events ? Events[EventName]
58
+ : EventName extends keyof EventEmitterEventMap ? EventEmitterEventMap[EventName]
59
+ : any[]
60
+ ) => void,
61
+ (...args: any[]) => void
62
+ >;
63
+ interface EventEmitterEventMap {
64
+ newListener: [eventName: string | symbol, listener: (...args: any[]) => void];
65
+ removeListener: [eventName: string | symbol, listener: (...args: any[]) => void];
66
+ }
67
+ // #endregion
68
+ interface EventEmitterOptions {
69
+ /**
70
+ * It enables
71
+ * [automatic capturing of promise rejection](https://nodejs.org/docs/latest-v25.x/api/events.html#capture-rejections-of-promises).
72
+ * @default false
73
+ */
74
+ captureRejections?: boolean | undefined;
75
+ }
76
+ /**
77
+ * The `EventEmitter` class is defined and exposed by the `node:events` module:
78
+ *
79
+ * ```js
80
+ * import { EventEmitter } from 'node:events';
81
+ * ```
82
+ *
83
+ * All `EventEmitter`s emit the event `'newListener'` when new listeners are
84
+ * added and `'removeListener'` when existing listeners are removed.
85
+ *
86
+ * It supports the following option:
87
+ * @since v0.1.26
88
+ */
89
+ class EventEmitter<T extends EventMap<T> = any> {
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;
461
+ }
462
+ namespace EventEmitter {
463
+ export { EventEmitter, EventEmitterEventMap, EventEmitterOptions };
464
+ }
465
+ namespace EventEmitter {
466
+ interface Abortable {
467
+ signal?: AbortSignal | undefined;
468
+ }
469
+ /**
470
+ * See how to write a custom [rejection handler](https://nodejs.org/docs/latest-v25.x/api/events.html#emittersymbolfornodejsrejectionerr-eventname-args).
471
+ * @since v13.4.0, v12.16.0
472
+ */
473
+ const captureRejectionSymbol: unique symbol;
474
+ /**
475
+ * Change the default `captureRejections` option on all new `EventEmitter` objects.
476
+ * @since v13.4.0, v12.16.0
477
+ */
478
+ let captureRejections: boolean;
479
+ /**
480
+ * By default, a maximum of `10` listeners can be registered for any single
481
+ * event. This limit can be changed for individual `EventEmitter` instances
482
+ * using the `emitter.setMaxListeners(n)` method. To change the default
483
+ * for _all_ `EventEmitter` instances, the `events.defaultMaxListeners`
484
+ * property can be used. If this value is not a positive number, a `RangeError`
485
+ * is thrown.
486
+ *
487
+ * Take caution when setting the `events.defaultMaxListeners` because the
488
+ * change affects _all_ `EventEmitter` instances, including those created before
489
+ * the change is made. However, calling `emitter.setMaxListeners(n)` still has
490
+ * precedence over `events.defaultMaxListeners`.
491
+ *
492
+ * This is not a hard limit. The `EventEmitter` instance will allow
493
+ * more listeners to be added but will output a trace warning to stderr indicating
494
+ * that a "possible EventEmitter memory leak" has been detected. For any single
495
+ * `EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()`
496
+ * methods can be used to temporarily avoid this warning:
497
+ *
498
+ * `defaultMaxListeners` has no effect on `AbortSignal` instances. While it is
499
+ * still possible to use `emitter.setMaxListeners(n)` to set a warning limit
500
+ * for individual `AbortSignal` instances, per default `AbortSignal` instances will not warn.
501
+ *
502
+ * ```js
503
+ * import { EventEmitter } from 'node:events';
504
+ * const emitter = new EventEmitter();
505
+ * emitter.setMaxListeners(emitter.getMaxListeners() + 1);
506
+ * emitter.once('event', () => {
507
+ * // do stuff
508
+ * emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
509
+ * });
510
+ * ```
511
+ *
512
+ * The `--trace-warnings` command-line flag can be used to display the
513
+ * stack trace for such warnings.
514
+ *
515
+ * The emitted warning can be inspected with `process.on('warning')` and will
516
+ * have the additional `emitter`, `type`, and `count` properties, referring to
517
+ * the event emitter instance, the event's name and the number of attached
518
+ * listeners, respectively.
519
+ * Its `name` property is set to `'MaxListenersExceededWarning'`.
520
+ * @since v0.11.2
521
+ */
522
+ let defaultMaxListeners: number;
523
+ /**
524
+ * This symbol shall be used to install a listener for only monitoring `'error'`
525
+ * events. Listeners installed using this symbol are called before the regular
526
+ * `'error'` listeners are called.
527
+ *
528
+ * Installing a listener using this symbol does not change the behavior once an
529
+ * `'error'` event is emitted. Therefore, the process will still crash if no
530
+ * regular `'error'` listener is installed.
531
+ * @since v13.6.0, v12.17.0
532
+ */
533
+ const errorMonitor: unique symbol;
534
+ /**
535
+ * Listens once to the `abort` event on the provided `signal`.
536
+ *
537
+ * Listening to the `abort` event on abort signals is unsafe and may
538
+ * lead to resource leaks since another third party with the signal can
539
+ * call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change
540
+ * this since it would violate the web standard. Additionally, the original
541
+ * API makes it easy to forget to remove listeners.
542
+ *
543
+ * This API allows safely using `AbortSignal`s in Node.js APIs by solving these
544
+ * two issues by listening to the event such that `stopImmediatePropagation` does
545
+ * not prevent the listener from running.
546
+ *
547
+ * Returns a disposable so that it may be unsubscribed from more easily.
548
+ *
549
+ * ```js
550
+ * import { addAbortListener } from 'node:events';
551
+ *
552
+ * function example(signal) {
553
+ * let disposable;
554
+ * try {
555
+ * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
556
+ * disposable = addAbortListener(signal, (e) => {
557
+ * // Do something when signal is aborted.
558
+ * });
559
+ * } finally {
560
+ * disposable?.[Symbol.dispose]();
561
+ * }
562
+ * }
563
+ * ```
564
+ * @since v20.5.0
565
+ * @return Disposable that removes the `abort` listener.
566
+ */
567
+ function addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
568
+ /**
569
+ * Returns a copy of the array of listeners for the event named `eventName`.
570
+ *
571
+ * For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
572
+ * the emitter.
573
+ *
574
+ * For `EventTarget`s this is the only way to get the event listeners for the
575
+ * event target. This is useful for debugging and diagnostic purposes.
576
+ *
577
+ * ```js
578
+ * import { getEventListeners, EventEmitter } from 'node:events';
579
+ *
580
+ * {
581
+ * const ee = new EventEmitter();
582
+ * const listener = () => console.log('Events are fun');
583
+ * ee.on('foo', listener);
584
+ * console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
585
+ * }
586
+ * {
587
+ * const et = new EventTarget();
588
+ * const listener = () => console.log('Events are fun');
589
+ * et.addEventListener('foo', listener);
590
+ * console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
591
+ * }
592
+ * ```
593
+ * @since v15.2.0, v14.17.0
594
+ */
595
+ function getEventListeners(emitter: NodeJS.EventEmitter, name: string | symbol): ((...args: any[]) => void)[];
596
+ function getEventListeners(emitter: EventTarget, name: string): ((...args: any[]) => void)[];
597
+ /**
598
+ * Returns the currently set max amount of listeners.
599
+ *
600
+ * For `EventEmitter`s this behaves exactly the same as calling `.getMaxListeners` on
601
+ * the emitter.
602
+ *
603
+ * For `EventTarget`s this is the only way to get the max event listeners for the
604
+ * event target. If the number of event handlers on a single EventTarget exceeds
605
+ * the max set, the EventTarget will print a warning.
606
+ *
607
+ * ```js
608
+ * import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
609
+ *
610
+ * {
611
+ * const ee = new EventEmitter();
612
+ * console.log(getMaxListeners(ee)); // 10
613
+ * setMaxListeners(11, ee);
614
+ * console.log(getMaxListeners(ee)); // 11
615
+ * }
616
+ * {
617
+ * const et = new EventTarget();
618
+ * console.log(getMaxListeners(et)); // 10
619
+ * setMaxListeners(11, et);
620
+ * console.log(getMaxListeners(et)); // 11
621
+ * }
622
+ * ```
623
+ * @since v19.9.0
624
+ */
625
+ function getMaxListeners(emitter: NodeJS.EventEmitter | EventTarget): number;
626
+ /**
627
+ * A class method that returns the number of listeners for the given `eventName`
628
+ * registered on the given `emitter`.
629
+ *
630
+ * ```js
631
+ * import { EventEmitter, listenerCount } from 'node:events';
632
+ *
633
+ * const myEmitter = new EventEmitter();
634
+ * myEmitter.on('event', () => {});
635
+ * myEmitter.on('event', () => {});
636
+ * console.log(listenerCount(myEmitter, 'event'));
637
+ * // Prints: 2
638
+ * ```
639
+ * @since v0.9.12
640
+ * @deprecated Use `emitter.listenerCount()` instead.
641
+ * @param emitter The emitter to query
642
+ * @param eventName The event name
643
+ */
644
+ function listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
645
+ interface OnOptions extends Abortable {
646
+ /**
647
+ * Names of events that will end the iteration.
648
+ */
649
+ close?: readonly string[] | undefined;
650
+ /**
651
+ * The high watermark. The emitter is paused every time the size of events
652
+ * being buffered is higher than it. Supported only on emitters implementing
653
+ * `pause()` and `resume()` methods.
654
+ * @default Number.MAX_SAFE_INTEGER
655
+ */
656
+ highWaterMark?: number | undefined;
657
+ /**
658
+ * The low watermark. The emitter is resumed every time the size of events
659
+ * being buffered is lower than it. Supported only on emitters implementing
660
+ * `pause()` and `resume()` methods.
661
+ * @default 1
662
+ */
663
+ lowWaterMark?: number | undefined;
664
+ }
665
+ /**
666
+ * ```js
667
+ * import { on, EventEmitter } from 'node:events';
668
+ * import process from 'node:process';
669
+ *
670
+ * const ee = new EventEmitter();
671
+ *
672
+ * // Emit later on
673
+ * process.nextTick(() => {
674
+ * ee.emit('foo', 'bar');
675
+ * ee.emit('foo', 42);
676
+ * });
677
+ *
678
+ * for await (const event of on(ee, 'foo')) {
679
+ * // The execution of this inner block is synchronous and it
680
+ * // processes one event at a time (even with await). Do not use
681
+ * // if concurrent execution is required.
682
+ * console.log(event); // prints ['bar'] [42]
683
+ * }
684
+ * // Unreachable here
685
+ * ```
686
+ *
687
+ * Returns an `AsyncIterator` that iterates `eventName` events. It will throw
688
+ * if the `EventEmitter` emits `'error'`. It removes all listeners when
689
+ * exiting the loop. The `value` returned by each iteration is an array
690
+ * composed of the emitted event arguments.
691
+ *
692
+ * An `AbortSignal` can be used to cancel waiting on events:
693
+ *
694
+ * ```js
695
+ * import { on, EventEmitter } from 'node:events';
696
+ * import process from 'node:process';
697
+ *
698
+ * const ac = new AbortController();
699
+ *
700
+ * (async () => {
701
+ * const ee = new EventEmitter();
702
+ *
703
+ * // Emit later on
704
+ * process.nextTick(() => {
705
+ * ee.emit('foo', 'bar');
706
+ * ee.emit('foo', 42);
707
+ * });
708
+ *
709
+ * for await (const event of on(ee, 'foo', { signal: ac.signal })) {
710
+ * // The execution of this inner block is synchronous and it
711
+ * // processes one event at a time (even with await). Do not use
712
+ * // if concurrent execution is required.
713
+ * console.log(event); // prints ['bar'] [42]
714
+ * }
715
+ * // Unreachable here
716
+ * })();
717
+ *
718
+ * process.nextTick(() => ac.abort());
719
+ * ```
720
+ * @since v13.6.0, v12.16.0
721
+ * @returns `AsyncIterator` that iterates `eventName` events emitted by the `emitter`
722
+ */
723
+ function on(
724
+ emitter: NodeJS.EventEmitter,
725
+ eventName: string | symbol,
726
+ options?: OnOptions,
727
+ ): NodeJS.AsyncIterator<any[]>;
728
+ function on(
729
+ emitter: EventTarget,
730
+ eventName: string,
731
+ options?: OnOptions,
732
+ ): NodeJS.AsyncIterator<any[]>;
733
+ interface OnceOptions extends Abortable {}
734
+ /**
735
+ * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
736
+ * event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
737
+ * The `Promise` will resolve with an array of all the arguments emitted to the
738
+ * given event.
739
+ *
740
+ * This method is intentionally generic and works with the web platform
741
+ * [EventTarget][WHATWG-EventTarget] interface, which has no special
742
+ * `'error'` event semantics and does not listen to the `'error'` event.
743
+ *
744
+ * ```js
745
+ * import { once, EventEmitter } from 'node:events';
746
+ * import process from 'node:process';
747
+ *
748
+ * const ee = new EventEmitter();
749
+ *
750
+ * process.nextTick(() => {
751
+ * ee.emit('myevent', 42);
752
+ * });
753
+ *
754
+ * const [value] = await once(ee, 'myevent');
755
+ * console.log(value);
756
+ *
757
+ * const err = new Error('kaboom');
758
+ * process.nextTick(() => {
759
+ * ee.emit('error', err);
760
+ * });
761
+ *
762
+ * try {
763
+ * await once(ee, 'myevent');
764
+ * } catch (err) {
765
+ * console.error('error happened', err);
766
+ * }
767
+ * ```
768
+ *
769
+ * The special handling of the `'error'` event is only used when `events.once()`
770
+ * is used to wait for another event. If `events.once()` is used to wait for the
771
+ * '`error'` event itself, then it is treated as any other kind of event without
772
+ * special handling:
773
+ *
774
+ * ```js
775
+ * import { EventEmitter, once } from 'node:events';
776
+ *
777
+ * const ee = new EventEmitter();
778
+ *
779
+ * once(ee, 'error')
780
+ * .then(([err]) => console.log('ok', err.message))
781
+ * .catch((err) => console.error('error', err.message));
782
+ *
783
+ * ee.emit('error', new Error('boom'));
784
+ *
785
+ * // Prints: ok boom
786
+ * ```
787
+ *
788
+ * An `AbortSignal` can be used to cancel waiting for the event:
789
+ *
790
+ * ```js
791
+ * import { EventEmitter, once } from 'node:events';
792
+ *
793
+ * const ee = new EventEmitter();
794
+ * const ac = new AbortController();
795
+ *
796
+ * async function foo(emitter, event, signal) {
797
+ * try {
798
+ * await once(emitter, event, { signal });
799
+ * console.log('event emitted!');
800
+ * } catch (error) {
801
+ * if (error.name === 'AbortError') {
802
+ * console.error('Waiting for the event was canceled!');
803
+ * } else {
804
+ * console.error('There was an error', error.message);
805
+ * }
806
+ * }
807
+ * }
808
+ *
809
+ * foo(ee, 'foo', ac.signal);
810
+ * ac.abort(); // Prints: Waiting for the event was canceled!
811
+ * ```
812
+ * @since v11.13.0, v10.16.0
813
+ */
814
+ function once(
815
+ emitter: NodeJS.EventEmitter,
816
+ eventName: string | symbol,
817
+ options?: OnceOptions,
818
+ ): Promise<any[]>;
819
+ function once(emitter: EventTarget, eventName: string, options?: OnceOptions): Promise<any[]>;
820
+ /**
821
+ * ```js
822
+ * import { setMaxListeners, EventEmitter } from 'node:events';
823
+ *
824
+ * const target = new EventTarget();
825
+ * const emitter = new EventEmitter();
826
+ *
827
+ * setMaxListeners(5, target, emitter);
828
+ * ```
829
+ * @since v15.4.0
830
+ * @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
831
+ * @param eventTargets Zero or more `EventTarget`
832
+ * or `EventEmitter` instances. If none are specified, `n` is set as the default
833
+ * max for all newly created `EventTarget` and `EventEmitter` objects.
834
+ * objects.
835
+ */
836
+ function setMaxListeners(n: number, ...eventTargets: ReadonlyArray<NodeJS.EventEmitter | EventTarget>): void;
837
+ /**
838
+ * This is the interface from which event-emitting Node.js APIs inherit in the types package.
839
+ * **It is not intended for consumer use.**
840
+ *
841
+ * It provides event-mapped definitions similar to EventEmitter, except that its signatures
842
+ * are deliberately permissive: they provide type _hinting_, but not rigid type-checking,
843
+ * for compatibility reasons.
844
+ *
845
+ * Classes that inherit directly from EventEmitter in JavaScript can inherit directly from
846
+ * this interface in the type definitions. Classes that are more than one inheritance level
847
+ * away from EventEmitter (eg. `net.Socket` > `stream.Duplex` > `EventEmitter`) must instead
848
+ * copy these method definitions into the derived class. Search "#region InternalEventEmitter"
849
+ * for examples.
850
+ * @internal
851
+ */
852
+ interface InternalEventEmitter<T extends EventMap<T>> extends EventEmitter {
853
+ addListener<E extends keyof T>(eventName: E, listener: (...args: T[E]) => void): this;
854
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
855
+ emit<E extends keyof T>(eventName: E, ...args: T[E]): boolean;
856
+ emit(eventName: string | symbol, ...args: any[]): boolean;
857
+ listenerCount<E extends keyof T>(eventName: E, listener?: (...args: T[E]) => void): number;
858
+ listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
859
+ listeners<E extends keyof T>(eventName: E): ((...args: T[E]) => void)[];
860
+ listeners(eventName: string | symbol): ((...args: any[]) => void)[];
861
+ off<E extends keyof T>(eventName: E, listener: (...args: T[E]) => void): this;
862
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
863
+ on<E extends keyof T>(eventName: E, listener: (...args: T[E]) => void): this;
864
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
865
+ once<E extends keyof T>(eventName: E, listener: (...args: T[E]) => void): this;
866
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
867
+ prependListener<E extends keyof T>(eventName: E, listener: (...args: T[E]) => void): this;
868
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
869
+ prependOnceListener<E extends keyof T>(eventName: E, listener: (...args: T[E]) => void): this;
870
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
871
+ rawListeners<E extends keyof T>(eventName: E): ((...args: T[E]) => void)[];
872
+ rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
873
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
874
+ removeAllListeners<E extends keyof T>(eventName?: E): this;
875
+ removeAllListeners(eventName?: string | symbol): this;
876
+ removeListener<E extends keyof T>(eventName: E, listener: (...args: T[E]) => void): this;
877
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
878
+ }
879
+ interface EventEmitterReferencingAsyncResource extends AsyncResource {
880
+ readonly eventEmitter: EventEmitterAsyncResource;
881
+ }
882
+ interface EventEmitterAsyncResourceOptions extends AsyncResourceOptions, EventEmitterOptions {
883
+ /**
884
+ * The type of async event.
885
+ * @default new.target.name
886
+ */
887
+ name?: string | undefined;
888
+ }
889
+ /**
890
+ * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that
891
+ * require manual async tracking. Specifically, all events emitted by instances
892
+ * of `events.EventEmitterAsyncResource` will run within its [async context](https://nodejs.org/docs/latest-v25.x/api/async_context.html).
893
+ *
894
+ * ```js
895
+ * import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
896
+ * import { notStrictEqual, strictEqual } from 'node:assert';
897
+ * import { executionAsyncId, triggerAsyncId } from 'node:async_hooks';
898
+ *
899
+ * // Async tracking tooling will identify this as 'Q'.
900
+ * const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
901
+ *
902
+ * // 'foo' listeners will run in the EventEmitters async context.
903
+ * ee1.on('foo', () => {
904
+ * strictEqual(executionAsyncId(), ee1.asyncId);
905
+ * strictEqual(triggerAsyncId(), ee1.triggerAsyncId);
906
+ * });
907
+ *
908
+ * const ee2 = new EventEmitter();
909
+ *
910
+ * // 'foo' listeners on ordinary EventEmitters that do not track async
911
+ * // context, however, run in the same async context as the emit().
912
+ * ee2.on('foo', () => {
913
+ * notStrictEqual(executionAsyncId(), ee2.asyncId);
914
+ * notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId);
915
+ * });
916
+ *
917
+ * Promise.resolve().then(() => {
918
+ * ee1.emit('foo');
919
+ * ee2.emit('foo');
920
+ * });
921
+ * ```
922
+ *
923
+ * The `EventEmitterAsyncResource` class has the same methods and takes the
924
+ * same options as `EventEmitter` and `AsyncResource` themselves.
925
+ * @since v17.4.0, v16.14.0
926
+ */
927
+ class EventEmitterAsyncResource extends EventEmitter {
928
+ constructor(options?: EventEmitterAsyncResourceOptions);
929
+ /**
930
+ * The unique `asyncId` assigned to the resource.
931
+ */
932
+ readonly asyncId: number;
933
+ /**
934
+ * The returned `AsyncResource` object has an additional `eventEmitter` property
935
+ * that provides a reference to this `EventEmitterAsyncResource`.
936
+ */
937
+ readonly asyncResource: EventEmitterReferencingAsyncResource;
938
+ /**
939
+ * Call all `destroy` hooks. This should only ever be called once. An error will
940
+ * be thrown if it is called more than once. This **must** be manually called. If
941
+ * the resource is left to be collected by the GC then the `destroy` hooks will
942
+ * never be called.
943
+ */
944
+ emitDestroy(): void;
945
+ /**
946
+ * The same `triggerAsyncId` that is passed to the
947
+ * `AsyncResource` constructor.
948
+ */
949
+ readonly triggerAsyncId: number;
950
+ }
951
+ /**
952
+ * The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
953
+ * that emulates a subset of the `EventEmitter` API.
954
+ * @since v14.5.0
955
+ */
956
+ interface NodeEventTarget extends EventTarget {
957
+ /**
958
+ * Node.js-specific extension to the `EventTarget` class that emulates the
959
+ * equivalent `EventEmitter` API. The only difference between `addListener()` and
960
+ * `addEventListener()` is that `addListener()` will return a reference to the
961
+ * `EventTarget`.
962
+ * @since v14.5.0
963
+ */
964
+ addListener(type: string, listener: (arg: any) => void): this;
965
+ /**
966
+ * Node.js-specific extension to the `EventTarget` class that dispatches the
967
+ * `arg` to the list of handlers for `type`.
968
+ * @since v15.2.0
969
+ * @returns `true` if event listeners registered for the `type` exist,
970
+ * otherwise `false`.
971
+ */
972
+ emit(type: string, arg: any): boolean;
973
+ /**
974
+ * Node.js-specific extension to the `EventTarget` class that returns an array
975
+ * of event `type` names for which event listeners are registered.
976
+ * @since 14.5.0
977
+ */
978
+ eventNames(): string[];
979
+ /**
980
+ * Node.js-specific extension to the `EventTarget` class that returns the number
981
+ * of event listeners registered for the `type`.
982
+ * @since v14.5.0
983
+ */
984
+ listenerCount(type: string): number;
985
+ /**
986
+ * Node.js-specific extension to the `EventTarget` class that sets the number
987
+ * of max event listeners as `n`.
988
+ * @since v14.5.0
989
+ */
990
+ setMaxListeners(n: number): void;
991
+ /**
992
+ * Node.js-specific extension to the `EventTarget` class that returns the number
993
+ * of max event listeners.
994
+ * @since v14.5.0
995
+ */
996
+ getMaxListeners(): number;
997
+ /**
998
+ * Node.js-specific alias for `eventTarget.removeEventListener()`.
999
+ * @since v14.5.0
1000
+ */
1001
+ off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
1002
+ /**
1003
+ * Node.js-specific alias for `eventTarget.addEventListener()`.
1004
+ * @since v14.5.0
1005
+ */
1006
+ on(type: string, listener: (arg: any) => void): this;
1007
+ /**
1008
+ * Node.js-specific extension to the `EventTarget` class that adds a `once`
1009
+ * listener for the given event `type`. This is equivalent to calling `on`
1010
+ * with the `once` option set to `true`.
1011
+ * @since v14.5.0
1012
+ */
1013
+ once(type: string, listener: (arg: any) => void): this;
1014
+ /**
1015
+ * Node.js-specific extension to the `EventTarget` class. If `type` is specified,
1016
+ * removes all registered listeners for `type`, otherwise removes all registered
1017
+ * listeners.
1018
+ * @since v14.5.0
1019
+ */
1020
+ removeAllListeners(type?: string): this;
1021
+ /**
1022
+ * Node.js-specific extension to the `EventTarget` class that removes the
1023
+ * `listener` for the given `type`. The only difference between `removeListener()`
1024
+ * and `removeEventListener()` is that `removeListener()` will return a reference
1025
+ * to the `EventTarget`.
1026
+ * @since v14.5.0
1027
+ */
1028
+ removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
1029
+ }
1030
+ /** @internal */
1031
+ type InternalEventTargetEventProperties<T> = {
1032
+ [K in keyof T & string as `on${K}`]: ((ev: T[K]) => void) | null;
1033
+ };
1034
+ }
1035
+ global {
1036
+ import _ = EventEmitter;
1037
+ namespace NodeJS {
1038
+ interface EventEmitter<T extends EventMap<T> = any> extends _<T> {}
1039
+ }
1040
+ }
1041
+ export = EventEmitter;
1042
+ }
1043
+ declare module "events" {
1044
+ import events = require("node:events");
1045
+ export = events;
1046
+ }