@rio-cloud/cdk-v2-constructs 8.2.0-alpha.0 → 8.2.1-alpha.0

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 (179) hide show
  1. package/.jsii +2 -2
  2. package/node_modules/@types/node/README.md +3 -3
  3. package/node_modules/@types/node/assert/strict.d.ts +105 -2
  4. package/node_modules/@types/node/assert.d.ts +211 -92
  5. package/node_modules/@types/node/async_hooks.d.ts +103 -19
  6. package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
  7. package/node_modules/@types/node/buffer.d.ts +88 -516
  8. package/node_modules/@types/node/child_process.d.ts +167 -231
  9. package/node_modules/@types/node/cluster.d.ts +172 -26
  10. package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  11. package/node_modules/@types/node/console.d.ts +66 -28
  12. package/node_modules/@types/node/constants.d.ts +14 -12
  13. package/node_modules/@types/node/crypto.d.ts +1458 -497
  14. package/node_modules/@types/node/dgram.d.ts +44 -30
  15. package/node_modules/@types/node/diagnostics_channel.d.ts +389 -4
  16. package/node_modules/@types/node/dns/promises.d.ts +120 -42
  17. package/node_modules/@types/node/dns.d.ts +209 -95
  18. package/node_modules/@types/node/domain.d.ts +14 -18
  19. package/node_modules/@types/node/events.d.ts +245 -113
  20. package/node_modules/@types/node/fs/promises.d.ts +194 -96
  21. package/node_modules/@types/node/fs.d.ts +695 -270
  22. package/node_modules/@types/node/globals.d.ts +97 -308
  23. package/node_modules/@types/node/globals.typedarray.d.ts +41 -0
  24. package/node_modules/@types/node/http.d.ts +363 -97
  25. package/node_modules/@types/node/http2.d.ts +684 -231
  26. package/node_modules/@types/node/https.d.ts +122 -87
  27. package/node_modules/@types/node/index.d.ts +24 -11
  28. package/node_modules/@types/node/inspector.d.ts +220 -2690
  29. package/node_modules/@types/node/inspector.generated.d.ts +4239 -0
  30. package/node_modules/@types/node/module.d.ts +705 -149
  31. package/node_modules/@types/node/net.d.ts +178 -54
  32. package/node_modules/@types/node/os.d.ts +47 -17
  33. package/node_modules/@types/node/package.json +22 -97
  34. package/node_modules/@types/node/path.d.ts +12 -3
  35. package/node_modules/@types/node/perf_hooks.d.ts +500 -97
  36. package/node_modules/@types/node/process.d.ts +657 -87
  37. package/node_modules/@types/node/punycode.d.ts +5 -5
  38. package/node_modules/@types/node/querystring.d.ts +24 -13
  39. package/node_modules/@types/node/readline/promises.d.ts +25 -14
  40. package/node_modules/@types/node/readline.d.ts +102 -41
  41. package/node_modules/@types/node/repl.d.ts +38 -30
  42. package/node_modules/@types/node/sea.d.ts +162 -0
  43. package/node_modules/@types/node/sqlite.d.ts +1040 -0
  44. package/node_modules/@types/node/stream/consumers.d.ts +33 -7
  45. package/node_modules/@types/node/stream/promises.d.ts +8 -1
  46. package/node_modules/@types/node/stream/web.d.ts +251 -28
  47. package/node_modules/@types/node/stream.d.ts +1060 -1055
  48. package/node_modules/@types/node/string_decoder.d.ts +8 -8
  49. package/node_modules/@types/node/test.d.ts +2133 -1166
  50. package/node_modules/@types/node/timers/promises.d.ts +31 -16
  51. package/node_modules/@types/node/timers.d.ts +159 -114
  52. package/node_modules/@types/node/tls.d.ts +232 -163
  53. package/node_modules/@types/node/trace_events.d.ts +43 -28
  54. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  55. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  56. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  57. package/node_modules/@types/node/ts5.6/index.d.ts +103 -0
  58. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  59. package/node_modules/@types/node/ts5.7/index.d.ts +103 -0
  60. package/node_modules/@types/node/tty.d.ts +9 -9
  61. package/node_modules/@types/node/url.d.ts +236 -84
  62. package/node_modules/@types/node/util.d.ts +562 -412
  63. package/node_modules/@types/node/v8.d.ts +368 -21
  64. package/node_modules/@types/node/vm.d.ts +443 -149
  65. package/node_modules/@types/node/wasi.d.ts +62 -18
  66. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  67. package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  68. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  69. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  70. package/node_modules/@types/node/web-globals/fetch.d.ts +62 -0
  71. package/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  72. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  73. package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  74. package/node_modules/@types/node/worker_threads.d.ts +310 -107
  75. package/node_modules/@types/node/zlib.d.ts +301 -73
  76. package/node_modules/undici-types/LICENSE +21 -0
  77. package/node_modules/undici-types/agent.d.ts +13 -12
  78. package/node_modules/undici-types/api.d.ts +26 -26
  79. package/node_modules/undici-types/balanced-pool.d.ts +19 -7
  80. package/node_modules/undici-types/cache-interceptor.d.ts +173 -0
  81. package/node_modules/undici-types/client-stats.d.ts +15 -0
  82. package/node_modules/undici-types/client.d.ts +26 -15
  83. package/node_modules/undici-types/connector.d.ts +2 -2
  84. package/node_modules/undici-types/cookies.d.ts +2 -0
  85. package/node_modules/undici-types/diagnostics-channel.d.ts +19 -12
  86. package/node_modules/undici-types/dispatcher.d.ts +148 -113
  87. package/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  88. package/node_modules/undici-types/errors.d.ts +79 -46
  89. package/node_modules/undici-types/eventsource.d.ts +66 -0
  90. package/node_modules/undici-types/fetch.d.ts +41 -39
  91. package/node_modules/undici-types/formdata.d.ts +8 -8
  92. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  93. package/node_modules/undici-types/global-origin.d.ts +5 -5
  94. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  95. package/node_modules/undici-types/handlers.d.ts +11 -5
  96. package/node_modules/undici-types/header.d.ts +157 -1
  97. package/node_modules/undici-types/index.d.ts +68 -43
  98. package/node_modules/undici-types/interceptors.d.ts +71 -3
  99. package/node_modules/undici-types/mock-agent.d.ts +36 -18
  100. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  101. package/node_modules/undici-types/mock-client.d.ts +6 -4
  102. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  103. package/node_modules/undici-types/mock-interceptor.d.ts +24 -23
  104. package/node_modules/undici-types/mock-pool.d.ts +6 -4
  105. package/node_modules/undici-types/package.json +1 -1
  106. package/node_modules/undici-types/patch.d.ts +0 -42
  107. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  108. package/node_modules/undici-types/pool.d.ts +21 -8
  109. package/node_modules/undici-types/proxy-agent.d.ts +5 -6
  110. package/node_modules/undici-types/readable.d.ts +24 -17
  111. package/node_modules/undici-types/retry-agent.d.ts +8 -0
  112. package/node_modules/undici-types/retry-handler.d.ts +125 -0
  113. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  114. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  115. package/node_modules/undici-types/util.d.ts +18 -0
  116. package/node_modules/undici-types/utility.d.ts +7 -0
  117. package/node_modules/undici-types/webidl.d.ts +157 -36
  118. package/node_modules/undici-types/websocket.d.ts +67 -12
  119. package/package.json +9 -60
  120. package/version.json +1 -1
  121. package/node_modules/@types/node/dom-events.d.ts +0 -122
  122. package/node_modules/@types/node/globals.global.d.ts +0 -1
  123. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  124. package/node_modules/@types/node/ts4.8/assert.d.ts +0 -996
  125. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -539
  126. package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2362
  127. package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1540
  128. package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
  129. package/node_modules/@types/node/ts4.8/console.d.ts +0 -415
  130. package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
  131. package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4455
  132. package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -586
  133. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -191
  134. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -425
  135. package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
  136. package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
  137. package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  138. package/node_modules/@types/node/ts4.8/events.d.ts +0 -796
  139. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1232
  140. package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4289
  141. package/node_modules/@types/node/ts4.8/globals.d.ts +0 -381
  142. package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  143. package/node_modules/@types/node/ts4.8/http.d.ts +0 -1888
  144. package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2382
  145. package/node_modules/@types/node/ts4.8/https.d.ts +0 -550
  146. package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  147. package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2747
  148. package/node_modules/@types/node/ts4.8/module.d.ts +0 -287
  149. package/node_modules/@types/node/ts4.8/net.d.ts +0 -949
  150. package/node_modules/@types/node/ts4.8/os.d.ts +0 -477
  151. package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  152. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -639
  153. package/node_modules/@types/node/ts4.8/process.d.ts +0 -1532
  154. package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  155. package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
  156. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -150
  157. package/node_modules/@types/node/ts4.8/readline.d.ts +0 -539
  158. package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
  159. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  160. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
  161. package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -350
  162. package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1701
  163. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  164. package/node_modules/@types/node/ts4.8/test.d.ts +0 -1382
  165. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  166. package/node_modules/@types/node/ts4.8/timers.d.ts +0 -240
  167. package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1210
  168. package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -182
  169. package/node_modules/@types/node/ts4.8/tty.d.ts +0 -208
  170. package/node_modules/@types/node/ts4.8/url.d.ts +0 -927
  171. package/node_modules/@types/node/ts4.8/util.d.ts +0 -2186
  172. package/node_modules/@types/node/ts4.8/v8.d.ts +0 -635
  173. package/node_modules/@types/node/ts4.8/vm.d.ts +0 -901
  174. package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -158
  175. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -691
  176. package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  177. package/node_modules/argparse/CHANGELOG.md +0 -216
  178. package/node_modules/undici-types/file.d.ts +0 -39
  179. package/node_modules/undici-types/filereader.d.ts +0 -54
@@ -32,67 +32,58 @@
32
32
  * });
33
33
  * myEmitter.emit('event');
34
34
  * ```
35
- * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/events.js)
35
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/events.js)
36
36
  */
37
37
  declare module "events" {
38
38
  import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
39
- // NOTE: This class is in the docs but is **not actually exported** by Node.
40
- // If https://github.com/nodejs/node/issues/39903 gets resolved and Node
41
- // actually starts exporting the class, uncomment below.
42
- // import { EventListener, EventListenerObject } from '__dom-events';
43
- // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
44
- // interface NodeEventTarget extends EventTarget {
45
- // /**
46
- // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
47
- // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
48
- // */
49
- // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
50
- // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
51
- // eventNames(): string[];
52
- // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
53
- // listenerCount(type: string): number;
54
- // /** Node.js-specific alias for `eventTarget.removeListener()`. */
55
- // off(type: string, listener: EventListener | EventListenerObject): this;
56
- // /** Node.js-specific alias for `eventTarget.addListener()`. */
57
- // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
58
- // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
59
- // once(type: string, listener: EventListener | EventListenerObject): this;
60
- // /**
61
- // * Node.js-specific extension to the `EventTarget` class.
62
- // * If `type` is specified, removes all registered listeners for `type`,
63
- // * otherwise removes all registered listeners.
64
- // */
65
- // removeAllListeners(type: string): this;
66
- // /**
67
- // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
68
- // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
69
- // */
70
- // removeListener(type: string, listener: EventListener | EventListenerObject): this;
71
- // }
72
39
  interface EventEmitterOptions {
73
40
  /**
74
41
  * Enables automatic capturing of promise rejection.
75
42
  */
76
43
  captureRejections?: boolean | undefined;
77
44
  }
78
- // Any EventTarget with a Node-style `once` function
79
- interface _NodeEventTarget {
80
- once(eventName: string | symbol, listener: (...args: any[]) => void): this;
81
- }
82
- // Any EventTarget with a DOM-style `addEventListener`
83
- interface _DOMEventTarget {
84
- addEventListener(
85
- eventName: string,
86
- listener: (...args: any[]) => void,
87
- opts?: {
88
- once: boolean;
89
- },
90
- ): any;
91
- }
92
45
  interface StaticEventEmitterOptions {
46
+ /**
47
+ * Can be used to cancel awaiting events.
48
+ */
93
49
  signal?: AbortSignal | undefined;
94
50
  }
95
- interface EventEmitter extends NodeJS.EventEmitter {}
51
+ interface StaticEventEmitterIteratorOptions extends StaticEventEmitterOptions {
52
+ /**
53
+ * Names of events that will end the iteration.
54
+ */
55
+ close?: string[] | undefined;
56
+ /**
57
+ * The high watermark. The emitter is paused every time the size of events being buffered is higher than it.
58
+ * Supported only on emitters implementing `pause()` and `resume()` methods.
59
+ * @default Number.MAX_SAFE_INTEGER
60
+ */
61
+ highWaterMark?: number | undefined;
62
+ /**
63
+ * The low watermark. The emitter is resumed every time the size of events being buffered is lower than it.
64
+ * Supported only on emitters implementing `pause()` and `resume()` methods.
65
+ * @default 1
66
+ */
67
+ lowWaterMark?: number | undefined;
68
+ }
69
+ interface EventEmitter<T extends EventMap<T> = DefaultEventMap> extends NodeJS.EventEmitter<T> {}
70
+ type EventMap<T> = Record<keyof T, any[]> | DefaultEventMap;
71
+ type DefaultEventMap = [never];
72
+ type AnyRest = [...args: any[]];
73
+ type Args<K, T> = T extends DefaultEventMap ? AnyRest : (
74
+ K extends keyof T ? T[K] : never
75
+ );
76
+ type Key<K, T> = T extends DefaultEventMap ? string | symbol : K | keyof T;
77
+ type Key2<K, T> = T extends DefaultEventMap ? string | symbol : K & keyof T;
78
+ type Listener<K, T, F> = T extends DefaultEventMap ? F : (
79
+ K extends keyof T ? (
80
+ T[K] extends unknown[] ? (...args: T[K]) => void : never
81
+ )
82
+ : never
83
+ );
84
+ type Listener1<K, T> = Listener<K, T, (...args: any[]) => void>;
85
+ type Listener2<K, T> = Listener<K, T, Function>;
86
+
96
87
  /**
97
88
  * The `EventEmitter` class is defined and exposed by the `node:events` module:
98
89
  *
@@ -106,10 +97,10 @@ declare module "events" {
106
97
  * It supports the following option:
107
98
  * @since v0.1.26
108
99
  */
109
- class EventEmitter {
100
+ class EventEmitter<T extends EventMap<T> = DefaultEventMap> {
110
101
  constructor(options?: EventEmitterOptions);
111
102
 
112
- [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
103
+ [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
113
104
 
114
105
  /**
115
106
  * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
@@ -145,7 +136,7 @@ declare module "events" {
145
136
  * }
146
137
  * ```
147
138
  *
148
- * The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
139
+ * The special handling of the `'error'` event is only used when `events.once()` is used to wait for another event. If `events.once()` is used to wait for the
149
140
  * '`error'` event itself, then it is treated as any other kind of event without
150
141
  * special handling:
151
142
  *
@@ -191,11 +182,11 @@ declare module "events" {
191
182
  * @since v11.13.0, v10.16.0
192
183
  */
193
184
  static once(
194
- emitter: _NodeEventTarget,
185
+ emitter: NodeJS.EventEmitter,
195
186
  eventName: string | symbol,
196
187
  options?: StaticEventEmitterOptions,
197
188
  ): Promise<any[]>;
198
- static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
189
+ static once(emitter: EventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
199
190
  /**
200
191
  * ```js
201
192
  * import { on, EventEmitter } from 'node:events';
@@ -251,17 +242,43 @@ declare module "events" {
251
242
  *
252
243
  * process.nextTick(() => ac.abort());
253
244
  * ```
245
+ *
246
+ * Use the `close` option to specify an array of event names that will end the iteration:
247
+ *
248
+ * ```js
249
+ * import { on, EventEmitter } from 'node:events';
250
+ * import process from 'node:process';
251
+ *
252
+ * const ee = new EventEmitter();
253
+ *
254
+ * // Emit later on
255
+ * process.nextTick(() => {
256
+ * ee.emit('foo', 'bar');
257
+ * ee.emit('foo', 42);
258
+ * ee.emit('close');
259
+ * });
260
+ *
261
+ * for await (const event of on(ee, 'foo', { close: ['close'] })) {
262
+ * console.log(event); // prints ['bar'] [42]
263
+ * }
264
+ * // the loop will exit after 'close' is emitted
265
+ * console.log('done'); // prints 'done'
266
+ * ```
254
267
  * @since v13.6.0, v12.16.0
255
- * @param eventName The name of the event being listened for
256
- * @return that iterates `eventName` events emitted by the `emitter`
268
+ * @return An `AsyncIterator` that iterates `eventName` events emitted by the `emitter`
257
269
  */
258
270
  static on(
259
271
  emitter: NodeJS.EventEmitter,
272
+ eventName: string | symbol,
273
+ options?: StaticEventEmitterIteratorOptions,
274
+ ): NodeJS.AsyncIterator<any[]>;
275
+ static on(
276
+ emitter: EventTarget,
260
277
  eventName: string,
261
- options?: StaticEventEmitterOptions,
262
- ): AsyncIterableIterator<any>;
278
+ options?: StaticEventEmitterIteratorOptions,
279
+ ): NodeJS.AsyncIterator<any[]>;
263
280
  /**
264
- * A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
281
+ * A class method that returns the number of listeners for the given `eventName` registered on the given `emitter`.
265
282
  *
266
283
  * ```js
267
284
  * import { EventEmitter, listenerCount } from 'node:events';
@@ -305,7 +322,7 @@ declare module "events" {
305
322
  * ```
306
323
  * @since v15.2.0, v14.17.0
307
324
  */
308
- static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
325
+ static getEventListeners(emitter: EventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
309
326
  /**
310
327
  * Returns the currently set max amount of listeners.
311
328
  *
@@ -334,7 +351,7 @@ declare module "events" {
334
351
  * ```
335
352
  * @since v19.9.0
336
353
  */
337
- static getMaxListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter): number;
354
+ static getMaxListeners(emitter: EventTarget | NodeJS.EventEmitter): number;
338
355
  /**
339
356
  * ```js
340
357
  * import { setMaxListeners, EventEmitter } from 'node:events';
@@ -346,10 +363,10 @@ declare module "events" {
346
363
  * ```
347
364
  * @since v15.4.0
348
365
  * @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
349
- * @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
366
+ * @param eventTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
350
367
  * objects.
351
368
  */
352
- static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
369
+ static setMaxListeners(n?: number, ...eventTargets: Array<EventTarget | NodeJS.EventEmitter>): void;
353
370
  /**
354
371
  * Listens once to the `abort` event on the provided `signal`.
355
372
  *
@@ -381,14 +398,13 @@ declare module "events" {
381
398
  * }
382
399
  * ```
383
400
  * @since v20.5.0
384
- * @experimental
385
401
  * @return Disposable that removes the `abort` listener.
386
402
  */
387
403
  static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
388
404
  /**
389
- * This symbol shall be used to install a listener for only monitoring `'error'`events. Listeners installed using this symbol are called before the regular`'error'` listeners are called.
405
+ * This symbol shall be used to install a listener for only monitoring `'error'` events. Listeners installed using this symbol are called before the regular `'error'` listeners are called.
390
406
  *
391
- * Installing a listener using this symbol does not change the behavior once an`'error'` event is emitted. Therefore, the process will still crash if no
407
+ * Installing a listener using this symbol does not change the behavior once an `'error'` event is emitted. Therefore, the process will still crash if no
392
408
  * regular `'error'` listener is installed.
393
409
  * @since v13.6.0, v12.17.0
394
410
  */
@@ -411,16 +427,18 @@ declare module "events" {
411
427
  * By default, a maximum of `10` listeners can be registered for any single
412
428
  * event. This limit can be changed for individual `EventEmitter` instances
413
429
  * using the `emitter.setMaxListeners(n)` method. To change the default
414
- * for _all_`EventEmitter` instances, the `events.defaultMaxListeners`property can be used. If this value is not a positive number, a `RangeError`is thrown.
430
+ * for _all_`EventEmitter` instances, the `events.defaultMaxListeners` property
431
+ * can be used. If this value is not a positive number, a `RangeError` is thrown.
415
432
  *
416
433
  * Take caution when setting the `events.defaultMaxListeners` because the
417
- * change affects _all_`EventEmitter` instances, including those created before
434
+ * change affects _all_ `EventEmitter` instances, including those created before
418
435
  * the change is made. However, calling `emitter.setMaxListeners(n)` still has
419
436
  * precedence over `events.defaultMaxListeners`.
420
437
  *
421
438
  * This is not a hard limit. The `EventEmitter` instance will allow
422
439
  * more listeners to be added but will output a trace warning to stderr indicating
423
- * that a "possible EventEmitter memory leak" has been detected. For any single`EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()`methods can be used to
440
+ * that a "possible EventEmitter memory leak" has been detected. For any single
441
+ * `EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()` methods can be used to
424
442
  * temporarily avoid this warning:
425
443
  *
426
444
  * ```js
@@ -466,17 +484,45 @@ declare module "events" {
466
484
  * directly rather than as a child class.
467
485
  * @default new.target.name if instantiated as a child class.
468
486
  */
469
- name?: string;
487
+ name?: string | undefined;
470
488
  }
471
489
 
472
490
  /**
473
- * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that require
474
- * manual async tracking. Specifically, all events emitted by instances of
475
- * `EventEmitterAsyncResource` will run within its async context.
491
+ * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that
492
+ * require manual async tracking. Specifically, all events emitted by instances
493
+ * of `events.EventEmitterAsyncResource` will run within its `async context`.
494
+ *
495
+ * ```js
496
+ * import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
497
+ * import { notStrictEqual, strictEqual } from 'node:assert';
498
+ * import { executionAsyncId, triggerAsyncId } from 'node:async_hooks';
499
+ *
500
+ * // Async tracking tooling will identify this as 'Q'.
501
+ * const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
502
+ *
503
+ * // 'foo' listeners will run in the EventEmitters async context.
504
+ * ee1.on('foo', () => {
505
+ * strictEqual(executionAsyncId(), ee1.asyncId);
506
+ * strictEqual(triggerAsyncId(), ee1.triggerAsyncId);
507
+ * });
476
508
  *
477
- * The EventEmitterAsyncResource class has the same methods and takes the
478
- * same options as EventEmitter and AsyncResource themselves.
479
- * @throws if `options.name` is not provided when instantiated directly.
509
+ * const ee2 = new EventEmitter();
510
+ *
511
+ * // 'foo' listeners on ordinary EventEmitters that do not track async
512
+ * // context, however, run in the same async context as the emit().
513
+ * ee2.on('foo', () => {
514
+ * notStrictEqual(executionAsyncId(), ee2.asyncId);
515
+ * notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId);
516
+ * });
517
+ *
518
+ * Promise.resolve().then(() => {
519
+ * ee1.emit('foo');
520
+ * ee2.emit('foo');
521
+ * });
522
+ * ```
523
+ *
524
+ * The `EventEmitterAsyncResource` class has the same methods and takes the
525
+ * same options as `EventEmitter` and `AsyncResource` themselves.
480
526
  * @since v17.4.0, v16.14.0
481
527
  */
482
528
  export class EventEmitterAsyncResource extends EventEmitter {
@@ -485,34 +531,120 @@ declare module "events" {
485
531
  */
486
532
  constructor(options?: EventEmitterAsyncResourceOptions);
487
533
  /**
488
- * Call all destroy hooks. This should only ever be called once. An
489
- * error will be thrown if it is called more than once. This must be
490
- * manually called. If the resource is left to be collected by the GC then
491
- * the destroy hooks will never be called.
534
+ * Call all `destroy` hooks. This should only ever be called once. An error will
535
+ * be thrown if it is called more than once. This **must** be manually called. If
536
+ * the resource is left to be collected by the GC then the `destroy` hooks will
537
+ * never be called.
492
538
  */
493
539
  emitDestroy(): void;
494
- /** The unique asyncId assigned to the resource. */
540
+ /**
541
+ * The unique `asyncId` assigned to the resource.
542
+ */
495
543
  readonly asyncId: number;
496
- /** The same triggerAsyncId that is passed to the AsyncResource constructor. */
544
+ /**
545
+ * The same triggerAsyncId that is passed to the AsyncResource constructor.
546
+ */
497
547
  readonly triggerAsyncId: number;
498
- /** The underlying AsyncResource */
548
+ /**
549
+ * The returned `AsyncResource` object has an additional `eventEmitter` property
550
+ * that provides a reference to this `EventEmitterAsyncResource`.
551
+ */
499
552
  readonly asyncResource: EventEmitterReferencingAsyncResource;
500
553
  }
554
+ /**
555
+ * The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
556
+ * that emulates a subset of the `EventEmitter` API.
557
+ * @since v14.5.0
558
+ */
559
+ export interface NodeEventTarget extends EventTarget {
560
+ /**
561
+ * Node.js-specific extension to the `EventTarget` class that emulates the
562
+ * equivalent `EventEmitter` API. The only difference between `addListener()` and
563
+ * `addEventListener()` is that `addListener()` will return a reference to the
564
+ * `EventTarget`.
565
+ * @since v14.5.0
566
+ */
567
+ addListener(type: string, listener: (arg: any) => void): this;
568
+ /**
569
+ * Node.js-specific extension to the `EventTarget` class that dispatches the
570
+ * `arg` to the list of handlers for `type`.
571
+ * @since v15.2.0
572
+ * @returns `true` if event listeners registered for the `type` exist,
573
+ * otherwise `false`.
574
+ */
575
+ emit(type: string, arg: any): boolean;
576
+ /**
577
+ * Node.js-specific extension to the `EventTarget` class that returns an array
578
+ * of event `type` names for which event listeners are registered.
579
+ * @since 14.5.0
580
+ */
581
+ eventNames(): string[];
582
+ /**
583
+ * Node.js-specific extension to the `EventTarget` class that returns the number
584
+ * of event listeners registered for the `type`.
585
+ * @since v14.5.0
586
+ */
587
+ listenerCount(type: string): number;
588
+ /**
589
+ * Node.js-specific extension to the `EventTarget` class that sets the number
590
+ * of max event listeners as `n`.
591
+ * @since v14.5.0
592
+ */
593
+ setMaxListeners(n: number): void;
594
+ /**
595
+ * Node.js-specific extension to the `EventTarget` class that returns the number
596
+ * of max event listeners.
597
+ * @since v14.5.0
598
+ */
599
+ getMaxListeners(): number;
600
+ /**
601
+ * Node.js-specific alias for `eventTarget.removeEventListener()`.
602
+ * @since v14.5.0
603
+ */
604
+ off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
605
+ /**
606
+ * Node.js-specific alias for `eventTarget.addEventListener()`.
607
+ * @since v14.5.0
608
+ */
609
+ on(type: string, listener: (arg: any) => void): this;
610
+ /**
611
+ * Node.js-specific extension to the `EventTarget` class that adds a `once`
612
+ * listener for the given event `type`. This is equivalent to calling `on`
613
+ * with the `once` option set to `true`.
614
+ * @since v14.5.0
615
+ */
616
+ once(type: string, listener: (arg: any) => void): this;
617
+ /**
618
+ * Node.js-specific extension to the `EventTarget` class. If `type` is specified,
619
+ * removes all registered listeners for `type`, otherwise removes all registered
620
+ * listeners.
621
+ * @since v14.5.0
622
+ */
623
+ removeAllListeners(type?: string): this;
624
+ /**
625
+ * Node.js-specific extension to the `EventTarget` class that removes the
626
+ * `listener` for the given `type`. The only difference between `removeListener()`
627
+ * and `removeEventListener()` is that `removeListener()` will return a reference
628
+ * to the `EventTarget`.
629
+ * @since v14.5.0
630
+ */
631
+ removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
632
+ }
501
633
  }
502
634
  global {
503
635
  namespace NodeJS {
504
- interface EventEmitter {
505
- [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
636
+ interface EventEmitter<T extends EventMap<T> = DefaultEventMap> {
637
+ [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
506
638
  /**
507
639
  * Alias for `emitter.on(eventName, listener)`.
508
640
  * @since v0.1.26
509
641
  */
510
- addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
642
+ addListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
511
643
  /**
512
- * Adds the `listener` function to the end of the listeners array for the
513
- * event named `eventName`. No checks are made to see if the `listener` has
514
- * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
515
- * times.
644
+ * Adds the `listener` function to the end of the listeners array for the event
645
+ * named `eventName`. No checks are made to see if the `listener` has already
646
+ * been added. Multiple calls passing the same combination of `eventName` and
647
+ * `listener` will result in the `listener` being added, and called, multiple times.
516
648
  *
517
649
  * ```js
518
650
  * server.on('connection', (stream) => {
@@ -522,7 +654,7 @@ declare module "events" {
522
654
  *
523
655
  * Returns a reference to the `EventEmitter`, so that calls can be chained.
524
656
  *
525
- * By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
657
+ * By default, event listeners are invoked in the order they are added. The `emitter.prependListener()` method can be used as an alternative to add the
526
658
  * event listener to the beginning of the listeners array.
527
659
  *
528
660
  * ```js
@@ -539,9 +671,9 @@ declare module "events" {
539
671
  * @param eventName The name of the event.
540
672
  * @param listener The callback function
541
673
  */
542
- on(eventName: string | symbol, listener: (...args: any[]) => void): this;
674
+ on<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
543
675
  /**
544
- * Adds a **one-time**`listener` function for the event named `eventName`. The
676
+ * Adds a **one-time** `listener` function for the event named `eventName`. The
545
677
  * next time `eventName` is triggered, this listener is removed and then invoked.
546
678
  *
547
679
  * ```js
@@ -552,7 +684,7 @@ declare module "events" {
552
684
  *
553
685
  * Returns a reference to the `EventEmitter`, so that calls can be chained.
554
686
  *
555
- * By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
687
+ * By default, event listeners are invoked in the order they are added. The `emitter.prependOnceListener()` method can be used as an alternative to add the
556
688
  * event listener to the beginning of the listeners array.
557
689
  *
558
690
  * ```js
@@ -569,9 +701,9 @@ declare module "events" {
569
701
  * @param eventName The name of the event.
570
702
  * @param listener The callback function
571
703
  */
572
- once(eventName: string | symbol, listener: (...args: any[]) => void): this;
704
+ once<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
573
705
  /**
574
- * Removes the specified `listener` from the listener array for the event named`eventName`.
706
+ * Removes the specified `listener` from the listener array for the event named `eventName`.
575
707
  *
576
708
  * ```js
577
709
  * const callback = (stream) => {
@@ -588,7 +720,7 @@ declare module "events" {
588
720
  * called multiple times to remove each instance.
589
721
  *
590
722
  * Once an event is emitted, all listeners attached to it at the
591
- * time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
723
+ * time of emitting are called in order. This implies that any `removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
592
724
  * will not remove them from`emit()` in progress. Subsequent events behave as expected.
593
725
  *
594
726
  * ```js
@@ -631,7 +763,7 @@ declare module "events" {
631
763
  *
632
764
  * When a single function has been added as a handler multiple times for a single
633
765
  * event (as in the example below), `removeListener()` will remove the most
634
- * recently added instance. In the example the `once('ping')`listener is removed:
766
+ * recently added instance. In the example the `once('ping')` listener is removed:
635
767
  *
636
768
  * ```js
637
769
  * import { EventEmitter } from 'node:events';
@@ -652,12 +784,12 @@ declare module "events" {
652
784
  * Returns a reference to the `EventEmitter`, so that calls can be chained.
653
785
  * @since v0.1.26
654
786
  */
655
- removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
787
+ removeListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
656
788
  /**
657
789
  * Alias for `emitter.removeListener()`.
658
790
  * @since v10.0.0
659
791
  */
660
- off(eventName: string | symbol, listener: (...args: any[]) => void): this;
792
+ off<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
661
793
  /**
662
794
  * Removes all listeners, or those of the specified `eventName`.
663
795
  *
@@ -668,12 +800,12 @@ declare module "events" {
668
800
  * Returns a reference to the `EventEmitter`, so that calls can be chained.
669
801
  * @since v0.1.26
670
802
  */
671
- removeAllListeners(event?: string | symbol): this;
803
+ removeAllListeners(eventName?: Key<unknown, T>): this;
672
804
  /**
673
805
  * By default `EventEmitter`s will print a warning if more than `10` listeners are
674
806
  * added for a particular event. This is a useful default that helps finding
675
807
  * memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
676
- * modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
808
+ * modified for this specific `EventEmitter` instance. The value can be set to `Infinity` (or `0`) to indicate an unlimited number of listeners.
677
809
  *
678
810
  * Returns a reference to the `EventEmitter`, so that calls can be chained.
679
811
  * @since v0.3.5
@@ -681,7 +813,7 @@ declare module "events" {
681
813
  setMaxListeners(n: number): this;
682
814
  /**
683
815
  * Returns the current max listener value for the `EventEmitter` which is either
684
- * set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}.
816
+ * set by `emitter.setMaxListeners(n)` or defaults to {@link EventEmitter.defaultMaxListeners}.
685
817
  * @since v1.0.0
686
818
  */
687
819
  getMaxListeners(): number;
@@ -697,7 +829,7 @@ declare module "events" {
697
829
  * ```
698
830
  * @since v0.1.26
699
831
  */
700
- listeners(eventName: string | symbol): Function[];
832
+ listeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
701
833
  /**
702
834
  * Returns a copy of the array of listeners for the event named `eventName`,
703
835
  * including any wrappers (such as those created by `.once()`).
@@ -728,9 +860,9 @@ declare module "events" {
728
860
  * ```
729
861
  * @since v9.4.0
730
862
  */
731
- rawListeners(eventName: string | symbol): Function[];
863
+ rawListeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
732
864
  /**
733
- * Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
865
+ * Synchronously calls each of the listeners registered for the event named `eventName`, in the order they were registered, passing the supplied arguments
734
866
  * to each.
735
867
  *
736
868
  * Returns `true` if the event had listeners, `false` otherwise.
@@ -769,7 +901,7 @@ declare module "events" {
769
901
  * ```
770
902
  * @since v0.1.26
771
903
  */
772
- emit(eventName: string | symbol, ...args: any[]): boolean;
904
+ emit<K>(eventName: Key<K, T>, ...args: Args<K, T>): boolean;
773
905
  /**
774
906
  * Returns the number of listeners listening for the event named `eventName`.
775
907
  * If `listener` is provided, it will return how many times the listener is found
@@ -778,12 +910,12 @@ declare module "events" {
778
910
  * @param eventName The name of the event being listened for
779
911
  * @param listener The event handler function
780
912
  */
781
- listenerCount(eventName: string | symbol, listener?: Function): number;
913
+ listenerCount<K>(eventName: Key<K, T>, listener?: Listener2<K, T>): number;
782
914
  /**
783
915
  * Adds the `listener` function to the _beginning_ of the listeners array for the
784
916
  * event named `eventName`. No checks are made to see if the `listener` has
785
- * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
786
- * times.
917
+ * already been added. Multiple calls passing the same combination of `eventName`
918
+ * and `listener` will result in the `listener` being added, and called, multiple times.
787
919
  *
788
920
  * ```js
789
921
  * server.prependListener('connection', (stream) => {
@@ -796,7 +928,7 @@ declare module "events" {
796
928
  * @param eventName The name of the event.
797
929
  * @param listener The callback function
798
930
  */
799
- prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
931
+ prependListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
800
932
  /**
801
933
  * 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
802
934
  * listener is removed, and then invoked.
@@ -812,7 +944,7 @@ declare module "events" {
812
944
  * @param eventName The name of the event.
813
945
  * @param listener The callback function
814
946
  */
815
- prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
947
+ prependOnceListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
816
948
  /**
817
949
  * Returns an array listing the events for which the emitter has registered
818
950
  * listeners. The values in the array are strings or `Symbol`s.
@@ -832,7 +964,7 @@ declare module "events" {
832
964
  * ```
833
965
  * @since v6.0.0
834
966
  */
835
- eventNames(): Array<string | symbol>;
967
+ eventNames(): Array<(string | symbol) & Key2<unknown, T>>;
836
968
  }
837
969
  }
838
970
  }