mcpbrowser 0.2.0 → 0.2.2

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 (134) hide show
  1. package/.mcpregistry_github_token +1 -0
  2. package/.mcpregistry_registry_token +1 -0
  3. package/README.md +68 -35
  4. package/extension/.vscodeignore +6 -0
  5. package/extension/LICENSE +21 -0
  6. package/extension/README.md +61 -0
  7. package/extension/icon.png +0 -0
  8. package/extension/icon.svg +35 -0
  9. package/extension/mcpbrowser-0.1.1.vsix +0 -0
  10. package/extension/mcpbrowser-0.1.2.vsix +0 -0
  11. package/extension/mcpbrowser-0.1.3.vsix +0 -0
  12. package/extension/mcpbrowser-0.1.4.vsix +0 -0
  13. package/extension/mcpbrowser-config-0.1.0.vsix +0 -0
  14. package/extension/node_modules/.package-lock.json +32 -0
  15. package/extension/node_modules/@types/node/LICENSE +21 -0
  16. package/extension/node_modules/@types/node/README.md +15 -0
  17. package/extension/node_modules/@types/node/assert/strict.d.ts +8 -0
  18. package/extension/node_modules/@types/node/assert.d.ts +1062 -0
  19. package/extension/node_modules/@types/node/async_hooks.d.ts +605 -0
  20. package/extension/node_modules/@types/node/buffer.buffer.d.ts +471 -0
  21. package/extension/node_modules/@types/node/buffer.d.ts +1936 -0
  22. package/extension/node_modules/@types/node/child_process.d.ts +1475 -0
  23. package/extension/node_modules/@types/node/cluster.d.ts +577 -0
  24. package/extension/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
  25. package/extension/node_modules/@types/node/compatibility/index.d.ts +9 -0
  26. package/extension/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  27. package/extension/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  28. package/extension/node_modules/@types/node/console.d.ts +452 -0
  29. package/extension/node_modules/@types/node/constants.d.ts +21 -0
  30. package/extension/node_modules/@types/node/crypto.d.ts +4590 -0
  31. package/extension/node_modules/@types/node/dgram.d.ts +597 -0
  32. package/extension/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
  33. package/extension/node_modules/@types/node/dns/promises.d.ts +479 -0
  34. package/extension/node_modules/@types/node/dns.d.ts +871 -0
  35. package/extension/node_modules/@types/node/domain.d.ts +170 -0
  36. package/extension/node_modules/@types/node/events.d.ts +977 -0
  37. package/extension/node_modules/@types/node/fs/promises.d.ts +1270 -0
  38. package/extension/node_modules/@types/node/fs.d.ts +4375 -0
  39. package/extension/node_modules/@types/node/globals.d.ts +172 -0
  40. package/extension/node_modules/@types/node/globals.typedarray.d.ts +38 -0
  41. package/extension/node_modules/@types/node/http.d.ts +2049 -0
  42. package/extension/node_modules/@types/node/http2.d.ts +2631 -0
  43. package/extension/node_modules/@types/node/https.d.ts +578 -0
  44. package/extension/node_modules/@types/node/index.d.ts +93 -0
  45. package/extension/node_modules/@types/node/inspector.generated.d.ts +3966 -0
  46. package/extension/node_modules/@types/node/module.d.ts +539 -0
  47. package/extension/node_modules/@types/node/net.d.ts +1012 -0
  48. package/extension/node_modules/@types/node/os.d.ts +506 -0
  49. package/extension/node_modules/@types/node/package.json +140 -0
  50. package/extension/node_modules/@types/node/path.d.ts +200 -0
  51. package/extension/node_modules/@types/node/perf_hooks.d.ts +961 -0
  52. package/extension/node_modules/@types/node/process.d.ts +1957 -0
  53. package/extension/node_modules/@types/node/punycode.d.ts +117 -0
  54. package/extension/node_modules/@types/node/querystring.d.ts +152 -0
  55. package/extension/node_modules/@types/node/readline/promises.d.ts +162 -0
  56. package/extension/node_modules/@types/node/readline.d.ts +589 -0
  57. package/extension/node_modules/@types/node/repl.d.ts +430 -0
  58. package/extension/node_modules/@types/node/sea.d.ts +153 -0
  59. package/extension/node_modules/@types/node/stream/consumers.d.ts +38 -0
  60. package/extension/node_modules/@types/node/stream/promises.d.ts +90 -0
  61. package/extension/node_modules/@types/node/stream/web.d.ts +533 -0
  62. package/extension/node_modules/@types/node/stream.d.ts +1675 -0
  63. package/extension/node_modules/@types/node/string_decoder.d.ts +67 -0
  64. package/extension/node_modules/@types/node/test.d.ts +1787 -0
  65. package/extension/node_modules/@types/node/timers/promises.d.ts +108 -0
  66. package/extension/node_modules/@types/node/timers.d.ts +286 -0
  67. package/extension/node_modules/@types/node/tls.d.ts +1255 -0
  68. package/extension/node_modules/@types/node/trace_events.d.ts +197 -0
  69. package/extension/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  70. package/extension/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
  71. package/extension/node_modules/@types/node/ts5.6/index.d.ts +93 -0
  72. package/extension/node_modules/@types/node/tty.d.ts +208 -0
  73. package/extension/node_modules/@types/node/url.d.ts +964 -0
  74. package/extension/node_modules/@types/node/util.d.ts +2331 -0
  75. package/extension/node_modules/@types/node/v8.d.ts +809 -0
  76. package/extension/node_modules/@types/node/vm.d.ts +1001 -0
  77. package/extension/node_modules/@types/node/wasi.d.ts +181 -0
  78. package/extension/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  79. package/extension/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  80. package/extension/node_modules/@types/node/web-globals/events.d.ts +97 -0
  81. package/extension/node_modules/@types/node/web-globals/fetch.d.ts +46 -0
  82. package/extension/node_modules/@types/node/worker_threads.d.ts +715 -0
  83. package/extension/node_modules/@types/node/zlib.d.ts +540 -0
  84. package/extension/node_modules/@types/vscode/LICENSE +21 -0
  85. package/extension/node_modules/@types/vscode/README.md +15 -0
  86. package/extension/node_modules/@types/vscode/index.d.ts +21153 -0
  87. package/extension/node_modules/@types/vscode/package.json +26 -0
  88. package/extension/node_modules/undici-types/LICENSE +21 -0
  89. package/extension/node_modules/undici-types/README.md +6 -0
  90. package/extension/node_modules/undici-types/agent.d.ts +31 -0
  91. package/extension/node_modules/undici-types/api.d.ts +43 -0
  92. package/extension/node_modules/undici-types/balanced-pool.d.ts +29 -0
  93. package/extension/node_modules/undici-types/cache.d.ts +36 -0
  94. package/extension/node_modules/undici-types/client.d.ts +108 -0
  95. package/extension/node_modules/undici-types/connector.d.ts +34 -0
  96. package/extension/node_modules/undici-types/content-type.d.ts +21 -0
  97. package/extension/node_modules/undici-types/cookies.d.ts +28 -0
  98. package/extension/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
  99. package/extension/node_modules/undici-types/dispatcher.d.ts +256 -0
  100. package/extension/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
  101. package/extension/node_modules/undici-types/errors.d.ts +149 -0
  102. package/extension/node_modules/undici-types/eventsource.d.ts +61 -0
  103. package/extension/node_modules/undici-types/fetch.d.ts +209 -0
  104. package/extension/node_modules/undici-types/file.d.ts +39 -0
  105. package/extension/node_modules/undici-types/filereader.d.ts +54 -0
  106. package/extension/node_modules/undici-types/formdata.d.ts +108 -0
  107. package/extension/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  108. package/extension/node_modules/undici-types/global-origin.d.ts +7 -0
  109. package/extension/node_modules/undici-types/handlers.d.ts +15 -0
  110. package/extension/node_modules/undici-types/header.d.ts +4 -0
  111. package/extension/node_modules/undici-types/index.d.ts +71 -0
  112. package/extension/node_modules/undici-types/interceptors.d.ts +17 -0
  113. package/extension/node_modules/undici-types/mock-agent.d.ts +50 -0
  114. package/extension/node_modules/undici-types/mock-client.d.ts +25 -0
  115. package/extension/node_modules/undici-types/mock-errors.d.ts +12 -0
  116. package/extension/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  117. package/extension/node_modules/undici-types/mock-pool.d.ts +25 -0
  118. package/extension/node_modules/undici-types/package.json +55 -0
  119. package/extension/node_modules/undici-types/patch.d.ts +33 -0
  120. package/extension/node_modules/undici-types/pool-stats.d.ts +19 -0
  121. package/extension/node_modules/undici-types/pool.d.ts +39 -0
  122. package/extension/node_modules/undici-types/proxy-agent.d.ts +28 -0
  123. package/extension/node_modules/undici-types/readable.d.ts +65 -0
  124. package/extension/node_modules/undici-types/retry-agent.d.ts +8 -0
  125. package/extension/node_modules/undici-types/retry-handler.d.ts +116 -0
  126. package/extension/node_modules/undici-types/util.d.ts +18 -0
  127. package/extension/node_modules/undici-types/webidl.d.ts +228 -0
  128. package/extension/node_modules/undici-types/websocket.d.ts +150 -0
  129. package/extension/package-lock.json +44 -0
  130. package/extension/package.json +55 -0
  131. package/extension/src/extension.js +257 -0
  132. package/package.json +2 -1
  133. package/server.json +20 -0
  134. package/src/mcp-browser.js +1 -1
@@ -0,0 +1,977 @@
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/v20.13.1/lib/events.js)
36
+ */
37
+ declare module "events" {
38
+ import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
39
+ interface EventEmitterOptions {
40
+ /**
41
+ * Enables automatic capturing of promise rejection.
42
+ */
43
+ captureRejections?: boolean | undefined;
44
+ }
45
+ interface StaticEventEmitterOptions {
46
+ /**
47
+ * Can be used to cancel awaiting events.
48
+ */
49
+ signal?: AbortSignal | undefined;
50
+ }
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
+
87
+ /**
88
+ * The `EventEmitter` class is defined and exposed by the `node:events` module:
89
+ *
90
+ * ```js
91
+ * import { EventEmitter } from 'node:events';
92
+ * ```
93
+ *
94
+ * All `EventEmitter`s emit the event `'newListener'` when new listeners are
95
+ * added and `'removeListener'` when existing listeners are removed.
96
+ *
97
+ * It supports the following option:
98
+ * @since v0.1.26
99
+ */
100
+ class EventEmitter<T extends EventMap<T> = DefaultEventMap> {
101
+ constructor(options?: EventEmitterOptions);
102
+
103
+ [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
104
+
105
+ /**
106
+ * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
107
+ * event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
108
+ * The `Promise` will resolve with an array of all the arguments emitted to the
109
+ * given event.
110
+ *
111
+ * This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
112
+ * semantics and does not listen to the `'error'` event.
113
+ *
114
+ * ```js
115
+ * import { once, EventEmitter } from 'node:events';
116
+ * import process from 'node:process';
117
+ *
118
+ * const ee = new EventEmitter();
119
+ *
120
+ * process.nextTick(() => {
121
+ * ee.emit('myevent', 42);
122
+ * });
123
+ *
124
+ * const [value] = await once(ee, 'myevent');
125
+ * console.log(value);
126
+ *
127
+ * const err = new Error('kaboom');
128
+ * process.nextTick(() => {
129
+ * ee.emit('error', err);
130
+ * });
131
+ *
132
+ * try {
133
+ * await once(ee, 'myevent');
134
+ * } catch (err) {
135
+ * console.error('error happened', err);
136
+ * }
137
+ * ```
138
+ *
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
140
+ * '`error'` event itself, then it is treated as any other kind of event without
141
+ * special handling:
142
+ *
143
+ * ```js
144
+ * import { EventEmitter, once } from 'node:events';
145
+ *
146
+ * const ee = new EventEmitter();
147
+ *
148
+ * once(ee, 'error')
149
+ * .then(([err]) => console.log('ok', err.message))
150
+ * .catch((err) => console.error('error', err.message));
151
+ *
152
+ * ee.emit('error', new Error('boom'));
153
+ *
154
+ * // Prints: ok boom
155
+ * ```
156
+ *
157
+ * An `AbortSignal` can be used to cancel waiting for the event:
158
+ *
159
+ * ```js
160
+ * import { EventEmitter, once } from 'node:events';
161
+ *
162
+ * const ee = new EventEmitter();
163
+ * const ac = new AbortController();
164
+ *
165
+ * async function foo(emitter, event, signal) {
166
+ * try {
167
+ * await once(emitter, event, { signal });
168
+ * console.log('event emitted!');
169
+ * } catch (error) {
170
+ * if (error.name === 'AbortError') {
171
+ * console.error('Waiting for the event was canceled!');
172
+ * } else {
173
+ * console.error('There was an error', error.message);
174
+ * }
175
+ * }
176
+ * }
177
+ *
178
+ * foo(ee, 'foo', ac.signal);
179
+ * ac.abort(); // Abort waiting for the event
180
+ * ee.emit('foo'); // Prints: Waiting for the event was canceled!
181
+ * ```
182
+ * @since v11.13.0, v10.16.0
183
+ */
184
+ static once(
185
+ emitter: NodeJS.EventEmitter,
186
+ eventName: string | symbol,
187
+ options?: StaticEventEmitterOptions,
188
+ ): Promise<any[]>;
189
+ static once(emitter: EventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
190
+ /**
191
+ * ```js
192
+ * import { on, EventEmitter } from 'node:events';
193
+ * import process from 'node:process';
194
+ *
195
+ * const ee = new EventEmitter();
196
+ *
197
+ * // Emit later on
198
+ * process.nextTick(() => {
199
+ * ee.emit('foo', 'bar');
200
+ * ee.emit('foo', 42);
201
+ * });
202
+ *
203
+ * for await (const event of on(ee, 'foo')) {
204
+ * // The execution of this inner block is synchronous and it
205
+ * // processes one event at a time (even with await). Do not use
206
+ * // if concurrent execution is required.
207
+ * console.log(event); // prints ['bar'] [42]
208
+ * }
209
+ * // Unreachable here
210
+ * ```
211
+ *
212
+ * Returns an `AsyncIterator` that iterates `eventName` events. It will throw
213
+ * if the `EventEmitter` emits `'error'`. It removes all listeners when
214
+ * exiting the loop. The `value` returned by each iteration is an array
215
+ * composed of the emitted event arguments.
216
+ *
217
+ * An `AbortSignal` can be used to cancel waiting on events:
218
+ *
219
+ * ```js
220
+ * import { on, EventEmitter } from 'node:events';
221
+ * import process from 'node:process';
222
+ *
223
+ * const ac = new AbortController();
224
+ *
225
+ * (async () => {
226
+ * const ee = new EventEmitter();
227
+ *
228
+ * // Emit later on
229
+ * process.nextTick(() => {
230
+ * ee.emit('foo', 'bar');
231
+ * ee.emit('foo', 42);
232
+ * });
233
+ *
234
+ * for await (const event of on(ee, 'foo', { signal: ac.signal })) {
235
+ * // The execution of this inner block is synchronous and it
236
+ * // processes one event at a time (even with await). Do not use
237
+ * // if concurrent execution is required.
238
+ * console.log(event); // prints ['bar'] [42]
239
+ * }
240
+ * // Unreachable here
241
+ * })();
242
+ *
243
+ * process.nextTick(() => ac.abort());
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
+ * ```
267
+ * @since v13.6.0, v12.16.0
268
+ * @return An `AsyncIterator` that iterates `eventName` events emitted by the `emitter`
269
+ */
270
+ static on(
271
+ emitter: NodeJS.EventEmitter,
272
+ eventName: string | symbol,
273
+ options?: StaticEventEmitterIteratorOptions,
274
+ ): NodeJS.AsyncIterator<any[]>;
275
+ static on(
276
+ emitter: EventTarget,
277
+ eventName: string,
278
+ options?: StaticEventEmitterIteratorOptions,
279
+ ): NodeJS.AsyncIterator<any[]>;
280
+ /**
281
+ * A class method that returns the number of listeners for the given `eventName` registered on the given `emitter`.
282
+ *
283
+ * ```js
284
+ * import { EventEmitter, listenerCount } from 'node:events';
285
+ *
286
+ * const myEmitter = new EventEmitter();
287
+ * myEmitter.on('event', () => {});
288
+ * myEmitter.on('event', () => {});
289
+ * console.log(listenerCount(myEmitter, 'event'));
290
+ * // Prints: 2
291
+ * ```
292
+ * @since v0.9.12
293
+ * @deprecated Since v3.2.0 - Use `listenerCount` instead.
294
+ * @param emitter The emitter to query
295
+ * @param eventName The event name
296
+ */
297
+ static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
298
+ /**
299
+ * Returns a copy of the array of listeners for the event named `eventName`.
300
+ *
301
+ * For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
302
+ * the emitter.
303
+ *
304
+ * For `EventTarget`s this is the only way to get the event listeners for the
305
+ * event target. This is useful for debugging and diagnostic purposes.
306
+ *
307
+ * ```js
308
+ * import { getEventListeners, EventEmitter } from 'node:events';
309
+ *
310
+ * {
311
+ * const ee = new EventEmitter();
312
+ * const listener = () => console.log('Events are fun');
313
+ * ee.on('foo', listener);
314
+ * console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
315
+ * }
316
+ * {
317
+ * const et = new EventTarget();
318
+ * const listener = () => console.log('Events are fun');
319
+ * et.addEventListener('foo', listener);
320
+ * console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
321
+ * }
322
+ * ```
323
+ * @since v15.2.0, v14.17.0
324
+ */
325
+ static getEventListeners(emitter: EventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
326
+ /**
327
+ * Returns the currently set max amount of listeners.
328
+ *
329
+ * For `EventEmitter`s this behaves exactly the same as calling `.getMaxListeners` on
330
+ * the emitter.
331
+ *
332
+ * For `EventTarget`s this is the only way to get the max event listeners for the
333
+ * event target. If the number of event handlers on a single EventTarget exceeds
334
+ * the max set, the EventTarget will print a warning.
335
+ *
336
+ * ```js
337
+ * import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
338
+ *
339
+ * {
340
+ * const ee = new EventEmitter();
341
+ * console.log(getMaxListeners(ee)); // 10
342
+ * setMaxListeners(11, ee);
343
+ * console.log(getMaxListeners(ee)); // 11
344
+ * }
345
+ * {
346
+ * const et = new EventTarget();
347
+ * console.log(getMaxListeners(et)); // 10
348
+ * setMaxListeners(11, et);
349
+ * console.log(getMaxListeners(et)); // 11
350
+ * }
351
+ * ```
352
+ * @since v19.9.0
353
+ */
354
+ static getMaxListeners(emitter: EventTarget | NodeJS.EventEmitter): number;
355
+ /**
356
+ * ```js
357
+ * import { setMaxListeners, EventEmitter } from 'node:events';
358
+ *
359
+ * const target = new EventTarget();
360
+ * const emitter = new EventEmitter();
361
+ *
362
+ * setMaxListeners(5, target, emitter);
363
+ * ```
364
+ * @since v15.4.0
365
+ * @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
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}
367
+ * objects.
368
+ */
369
+ static setMaxListeners(n?: number, ...eventTargets: Array<EventTarget | NodeJS.EventEmitter>): void;
370
+ /**
371
+ * Listens once to the `abort` event on the provided `signal`.
372
+ *
373
+ * Listening to the `abort` event on abort signals is unsafe and may
374
+ * lead to resource leaks since another third party with the signal can
375
+ * call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change
376
+ * this since it would violate the web standard. Additionally, the original
377
+ * API makes it easy to forget to remove listeners.
378
+ *
379
+ * This API allows safely using `AbortSignal`s in Node.js APIs by solving these
380
+ * two issues by listening to the event such that `stopImmediatePropagation` does
381
+ * not prevent the listener from running.
382
+ *
383
+ * Returns a disposable so that it may be unsubscribed from more easily.
384
+ *
385
+ * ```js
386
+ * import { addAbortListener } from 'node:events';
387
+ *
388
+ * function example(signal) {
389
+ * let disposable;
390
+ * try {
391
+ * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
392
+ * disposable = addAbortListener(signal, (e) => {
393
+ * // Do something when signal is aborted.
394
+ * });
395
+ * } finally {
396
+ * disposable?.[Symbol.dispose]();
397
+ * }
398
+ * }
399
+ * ```
400
+ * @since v20.5.0
401
+ * @experimental
402
+ * @return Disposable that removes the `abort` listener.
403
+ */
404
+ static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
405
+ /**
406
+ * 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.
407
+ *
408
+ * 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
409
+ * regular `'error'` listener is installed.
410
+ * @since v13.6.0, v12.17.0
411
+ */
412
+ static readonly errorMonitor: unique symbol;
413
+ /**
414
+ * Value: `Symbol.for('nodejs.rejection')`
415
+ *
416
+ * See how to write a custom `rejection handler`.
417
+ * @since v13.4.0, v12.16.0
418
+ */
419
+ static readonly captureRejectionSymbol: unique symbol;
420
+ /**
421
+ * Value: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
422
+ *
423
+ * Change the default `captureRejections` option on all new `EventEmitter` objects.
424
+ * @since v13.4.0, v12.16.0
425
+ */
426
+ static captureRejections: boolean;
427
+ /**
428
+ * By default, a maximum of `10` listeners can be registered for any single
429
+ * event. This limit can be changed for individual `EventEmitter` instances
430
+ * using the `emitter.setMaxListeners(n)` method. To change the default
431
+ * for _all_`EventEmitter` instances, the `events.defaultMaxListeners` property
432
+ * can be used. If this value is not a positive number, a `RangeError` is thrown.
433
+ *
434
+ * Take caution when setting the `events.defaultMaxListeners` because the
435
+ * change affects _all_ `EventEmitter` instances, including those created before
436
+ * the change is made. However, calling `emitter.setMaxListeners(n)` still has
437
+ * precedence over `events.defaultMaxListeners`.
438
+ *
439
+ * This is not a hard limit. The `EventEmitter` instance will allow
440
+ * more listeners to be added but will output a trace warning to stderr indicating
441
+ * that a "possible EventEmitter memory leak" has been detected. For any single
442
+ * `EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()` methods can be used to
443
+ * temporarily avoid this warning:
444
+ *
445
+ * ```js
446
+ * import { EventEmitter } from 'node:events';
447
+ * const emitter = new EventEmitter();
448
+ * emitter.setMaxListeners(emitter.getMaxListeners() + 1);
449
+ * emitter.once('event', () => {
450
+ * // do stuff
451
+ * emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
452
+ * });
453
+ * ```
454
+ *
455
+ * The `--trace-warnings` command-line flag can be used to display the
456
+ * stack trace for such warnings.
457
+ *
458
+ * The emitted warning can be inspected with `process.on('warning')` and will
459
+ * have the additional `emitter`, `type`, and `count` properties, referring to
460
+ * the event emitter instance, the event's name and the number of attached
461
+ * listeners, respectively.
462
+ * Its `name` property is set to `'MaxListenersExceededWarning'`.
463
+ * @since v0.11.2
464
+ */
465
+ static defaultMaxListeners: number;
466
+ }
467
+ import internal = require("node:events");
468
+ namespace EventEmitter {
469
+ // Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
470
+ export { internal as EventEmitter };
471
+ export interface Abortable {
472
+ /**
473
+ * When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
474
+ */
475
+ signal?: AbortSignal | undefined;
476
+ }
477
+
478
+ export interface EventEmitterReferencingAsyncResource extends AsyncResource {
479
+ readonly eventEmitter: EventEmitterAsyncResource;
480
+ }
481
+
482
+ export interface EventEmitterAsyncResourceOptions extends AsyncResourceOptions, EventEmitterOptions {
483
+ /**
484
+ * The type of async event, this is required when instantiating `EventEmitterAsyncResource`
485
+ * directly rather than as a child class.
486
+ * @default new.target.name if instantiated as a child class.
487
+ */
488
+ name?: string | undefined;
489
+ }
490
+
491
+ /**
492
+ * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that
493
+ * require manual async tracking. Specifically, all events emitted by instances
494
+ * of `events.EventEmitterAsyncResource` will run within its `async context`.
495
+ *
496
+ * ```js
497
+ * import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
498
+ * import { notStrictEqual, strictEqual } from 'node:assert';
499
+ * import { executionAsyncId, triggerAsyncId } from 'node:async_hooks';
500
+ *
501
+ * // Async tracking tooling will identify this as 'Q'.
502
+ * const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
503
+ *
504
+ * // 'foo' listeners will run in the EventEmitters async context.
505
+ * ee1.on('foo', () => {
506
+ * strictEqual(executionAsyncId(), ee1.asyncId);
507
+ * strictEqual(triggerAsyncId(), ee1.triggerAsyncId);
508
+ * });
509
+ *
510
+ * const ee2 = new EventEmitter();
511
+ *
512
+ * // 'foo' listeners on ordinary EventEmitters that do not track async
513
+ * // context, however, run in the same async context as the emit().
514
+ * ee2.on('foo', () => {
515
+ * notStrictEqual(executionAsyncId(), ee2.asyncId);
516
+ * notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId);
517
+ * });
518
+ *
519
+ * Promise.resolve().then(() => {
520
+ * ee1.emit('foo');
521
+ * ee2.emit('foo');
522
+ * });
523
+ * ```
524
+ *
525
+ * The `EventEmitterAsyncResource` class has the same methods and takes the
526
+ * same options as `EventEmitter` and `AsyncResource` themselves.
527
+ * @since v17.4.0, v16.14.0
528
+ */
529
+ export class EventEmitterAsyncResource extends EventEmitter {
530
+ /**
531
+ * @param options Only optional in child class.
532
+ */
533
+ constructor(options?: EventEmitterAsyncResourceOptions);
534
+ /**
535
+ * Call all `destroy` hooks. This should only ever be called once. An error will
536
+ * be thrown if it is called more than once. This **must** be manually called. If
537
+ * the resource is left to be collected by the GC then the `destroy` hooks will
538
+ * never be called.
539
+ */
540
+ emitDestroy(): void;
541
+ /**
542
+ * The unique `asyncId` assigned to the resource.
543
+ */
544
+ readonly asyncId: number;
545
+ /**
546
+ * The same triggerAsyncId that is passed to the AsyncResource constructor.
547
+ */
548
+ readonly triggerAsyncId: number;
549
+ /**
550
+ * The returned `AsyncResource` object has an additional `eventEmitter` property
551
+ * that provides a reference to this `EventEmitterAsyncResource`.
552
+ */
553
+ readonly asyncResource: EventEmitterReferencingAsyncResource;
554
+ }
555
+ /**
556
+ * The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
557
+ * that emulates a subset of the `EventEmitter` API.
558
+ * @since v14.5.0
559
+ */
560
+ export interface NodeEventTarget extends EventTarget {
561
+ /**
562
+ * Node.js-specific extension to the `EventTarget` class that emulates the
563
+ * equivalent `EventEmitter` API. The only difference between `addListener()` and
564
+ * `addEventListener()` is that `addListener()` will return a reference to the
565
+ * `EventTarget`.
566
+ * @since v14.5.0
567
+ */
568
+ addListener(type: string, listener: (arg: any) => void): this;
569
+ /**
570
+ * Node.js-specific extension to the `EventTarget` class that dispatches the
571
+ * `arg` to the list of handlers for `type`.
572
+ * @since v15.2.0
573
+ * @returns `true` if event listeners registered for the `type` exist,
574
+ * otherwise `false`.
575
+ */
576
+ emit(type: string, arg: any): boolean;
577
+ /**
578
+ * Node.js-specific extension to the `EventTarget` class that returns an array
579
+ * of event `type` names for which event listeners are registered.
580
+ * @since 14.5.0
581
+ */
582
+ eventNames(): string[];
583
+ /**
584
+ * Node.js-specific extension to the `EventTarget` class that returns the number
585
+ * of event listeners registered for the `type`.
586
+ * @since v14.5.0
587
+ */
588
+ listenerCount(type: string): number;
589
+ /**
590
+ * Node.js-specific extension to the `EventTarget` class that sets the number
591
+ * of max event listeners as `n`.
592
+ * @since v14.5.0
593
+ */
594
+ setMaxListeners(n: number): void;
595
+ /**
596
+ * Node.js-specific extension to the `EventTarget` class that returns the number
597
+ * of max event listeners.
598
+ * @since v14.5.0
599
+ */
600
+ getMaxListeners(): number;
601
+ /**
602
+ * Node.js-specific alias for `eventTarget.removeEventListener()`.
603
+ * @since v14.5.0
604
+ */
605
+ off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
606
+ /**
607
+ * Node.js-specific alias for `eventTarget.addEventListener()`.
608
+ * @since v14.5.0
609
+ */
610
+ on(type: string, listener: (arg: any) => void): this;
611
+ /**
612
+ * Node.js-specific extension to the `EventTarget` class that adds a `once`
613
+ * listener for the given event `type`. This is equivalent to calling `on`
614
+ * with the `once` option set to `true`.
615
+ * @since v14.5.0
616
+ */
617
+ once(type: string, listener: (arg: any) => void): this;
618
+ /**
619
+ * Node.js-specific extension to the `EventTarget` class. If `type` is specified,
620
+ * removes all registered listeners for `type`, otherwise removes all registered
621
+ * listeners.
622
+ * @since v14.5.0
623
+ */
624
+ removeAllListeners(type?: string): this;
625
+ /**
626
+ * Node.js-specific extension to the `EventTarget` class that removes the
627
+ * `listener` for the given `type`. The only difference between `removeListener()`
628
+ * and `removeEventListener()` is that `removeListener()` will return a reference
629
+ * to the `EventTarget`.
630
+ * @since v14.5.0
631
+ */
632
+ removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
633
+ }
634
+ }
635
+ global {
636
+ namespace NodeJS {
637
+ interface EventEmitter<T extends EventMap<T> = DefaultEventMap> {
638
+ [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
639
+ /**
640
+ * Alias for `emitter.on(eventName, listener)`.
641
+ * @since v0.1.26
642
+ */
643
+ addListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
644
+ /**
645
+ * Adds the `listener` function to the end of the listeners array for the event
646
+ * named `eventName`. No checks are made to see if the `listener` has already
647
+ * been added. Multiple calls passing the same combination of `eventName` and
648
+ * `listener` will result in the `listener` being added, and called, multiple times.
649
+ *
650
+ * ```js
651
+ * server.on('connection', (stream) => {
652
+ * console.log('someone connected!');
653
+ * });
654
+ * ```
655
+ *
656
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
657
+ *
658
+ * 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
659
+ * event listener to the beginning of the listeners array.
660
+ *
661
+ * ```js
662
+ * import { EventEmitter } from 'node:events';
663
+ * const myEE = new EventEmitter();
664
+ * myEE.on('foo', () => console.log('a'));
665
+ * myEE.prependListener('foo', () => console.log('b'));
666
+ * myEE.emit('foo');
667
+ * // Prints:
668
+ * // b
669
+ * // a
670
+ * ```
671
+ * @since v0.1.101
672
+ * @param eventName The name of the event.
673
+ * @param listener The callback function
674
+ */
675
+ on<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
676
+ /**
677
+ * Adds a **one-time** `listener` function for the event named `eventName`. The
678
+ * next time `eventName` is triggered, this listener is removed and then invoked.
679
+ *
680
+ * ```js
681
+ * server.once('connection', (stream) => {
682
+ * console.log('Ah, we have our first user!');
683
+ * });
684
+ * ```
685
+ *
686
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
687
+ *
688
+ * 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
689
+ * event listener to the beginning of the listeners array.
690
+ *
691
+ * ```js
692
+ * import { EventEmitter } from 'node:events';
693
+ * const myEE = new EventEmitter();
694
+ * myEE.once('foo', () => console.log('a'));
695
+ * myEE.prependOnceListener('foo', () => console.log('b'));
696
+ * myEE.emit('foo');
697
+ * // Prints:
698
+ * // b
699
+ * // a
700
+ * ```
701
+ * @since v0.3.0
702
+ * @param eventName The name of the event.
703
+ * @param listener The callback function
704
+ */
705
+ once<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
706
+ /**
707
+ * Removes the specified `listener` from the listener array for the event named `eventName`.
708
+ *
709
+ * ```js
710
+ * const callback = (stream) => {
711
+ * console.log('someone connected!');
712
+ * };
713
+ * server.on('connection', callback);
714
+ * // ...
715
+ * server.removeListener('connection', callback);
716
+ * ```
717
+ *
718
+ * `removeListener()` will remove, at most, one instance of a listener from the
719
+ * listener array. If any single listener has been added multiple times to the
720
+ * listener array for the specified `eventName`, then `removeListener()` must be
721
+ * called multiple times to remove each instance.
722
+ *
723
+ * Once an event is emitted, all listeners attached to it at the
724
+ * time of emitting are called in order. This implies that any `removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
725
+ * will not remove them from`emit()` in progress. Subsequent events behave as expected.
726
+ *
727
+ * ```js
728
+ * import { EventEmitter } from 'node:events';
729
+ * class MyEmitter extends EventEmitter {}
730
+ * const myEmitter = new MyEmitter();
731
+ *
732
+ * const callbackA = () => {
733
+ * console.log('A');
734
+ * myEmitter.removeListener('event', callbackB);
735
+ * };
736
+ *
737
+ * const callbackB = () => {
738
+ * console.log('B');
739
+ * };
740
+ *
741
+ * myEmitter.on('event', callbackA);
742
+ *
743
+ * myEmitter.on('event', callbackB);
744
+ *
745
+ * // callbackA removes listener callbackB but it will still be called.
746
+ * // Internal listener array at time of emit [callbackA, callbackB]
747
+ * myEmitter.emit('event');
748
+ * // Prints:
749
+ * // A
750
+ * // B
751
+ *
752
+ * // callbackB is now removed.
753
+ * // Internal listener array [callbackA]
754
+ * myEmitter.emit('event');
755
+ * // Prints:
756
+ * // A
757
+ * ```
758
+ *
759
+ * Because listeners are managed using an internal array, calling this will
760
+ * change the position indices of any listener registered _after_ the listener
761
+ * being removed. This will not impact the order in which listeners are called,
762
+ * but it means that any copies of the listener array as returned by
763
+ * the `emitter.listeners()` method will need to be recreated.
764
+ *
765
+ * When a single function has been added as a handler multiple times for a single
766
+ * event (as in the example below), `removeListener()` will remove the most
767
+ * recently added instance. In the example the `once('ping')` listener is removed:
768
+ *
769
+ * ```js
770
+ * import { EventEmitter } from 'node:events';
771
+ * const ee = new EventEmitter();
772
+ *
773
+ * function pong() {
774
+ * console.log('pong');
775
+ * }
776
+ *
777
+ * ee.on('ping', pong);
778
+ * ee.once('ping', pong);
779
+ * ee.removeListener('ping', pong);
780
+ *
781
+ * ee.emit('ping');
782
+ * ee.emit('ping');
783
+ * ```
784
+ *
785
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
786
+ * @since v0.1.26
787
+ */
788
+ removeListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
789
+ /**
790
+ * Alias for `emitter.removeListener()`.
791
+ * @since v10.0.0
792
+ */
793
+ off<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
794
+ /**
795
+ * Removes all listeners, or those of the specified `eventName`.
796
+ *
797
+ * It is bad practice to remove listeners added elsewhere in the code,
798
+ * particularly when the `EventEmitter` instance was created by some other
799
+ * component or module (e.g. sockets or file streams).
800
+ *
801
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
802
+ * @since v0.1.26
803
+ */
804
+ removeAllListeners(eventName?: Key<unknown, T>): this;
805
+ /**
806
+ * By default `EventEmitter`s will print a warning if more than `10` listeners are
807
+ * added for a particular event. This is a useful default that helps finding
808
+ * memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
809
+ * modified for this specific `EventEmitter` instance. The value can be set to `Infinity` (or `0`) to indicate an unlimited number of listeners.
810
+ *
811
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
812
+ * @since v0.3.5
813
+ */
814
+ setMaxListeners(n: number): this;
815
+ /**
816
+ * Returns the current max listener value for the `EventEmitter` which is either
817
+ * set by `emitter.setMaxListeners(n)` or defaults to {@link EventEmitter.defaultMaxListeners}.
818
+ * @since v1.0.0
819
+ */
820
+ getMaxListeners(): number;
821
+ /**
822
+ * Returns a copy of the array of listeners for the event named `eventName`.
823
+ *
824
+ * ```js
825
+ * server.on('connection', (stream) => {
826
+ * console.log('someone connected!');
827
+ * });
828
+ * console.log(util.inspect(server.listeners('connection')));
829
+ * // Prints: [ [Function] ]
830
+ * ```
831
+ * @since v0.1.26
832
+ */
833
+ listeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
834
+ /**
835
+ * Returns a copy of the array of listeners for the event named `eventName`,
836
+ * including any wrappers (such as those created by `.once()`).
837
+ *
838
+ * ```js
839
+ * import { EventEmitter } from 'node:events';
840
+ * const emitter = new EventEmitter();
841
+ * emitter.once('log', () => console.log('log once'));
842
+ *
843
+ * // Returns a new Array with a function `onceWrapper` which has a property
844
+ * // `listener` which contains the original listener bound above
845
+ * const listeners = emitter.rawListeners('log');
846
+ * const logFnWrapper = listeners[0];
847
+ *
848
+ * // Logs "log once" to the console and does not unbind the `once` event
849
+ * logFnWrapper.listener();
850
+ *
851
+ * // Logs "log once" to the console and removes the listener
852
+ * logFnWrapper();
853
+ *
854
+ * emitter.on('log', () => console.log('log persistently'));
855
+ * // Will return a new Array with a single function bound by `.on()` above
856
+ * const newListeners = emitter.rawListeners('log');
857
+ *
858
+ * // Logs "log persistently" twice
859
+ * newListeners[0]();
860
+ * emitter.emit('log');
861
+ * ```
862
+ * @since v9.4.0
863
+ */
864
+ rawListeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
865
+ /**
866
+ * Synchronously calls each of the listeners registered for the event named `eventName`, in the order they were registered, passing the supplied arguments
867
+ * to each.
868
+ *
869
+ * Returns `true` if the event had listeners, `false` otherwise.
870
+ *
871
+ * ```js
872
+ * import { EventEmitter } from 'node:events';
873
+ * const myEmitter = new EventEmitter();
874
+ *
875
+ * // First listener
876
+ * myEmitter.on('event', function firstListener() {
877
+ * console.log('Helloooo! first listener');
878
+ * });
879
+ * // Second listener
880
+ * myEmitter.on('event', function secondListener(arg1, arg2) {
881
+ * console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
882
+ * });
883
+ * // Third listener
884
+ * myEmitter.on('event', function thirdListener(...args) {
885
+ * const parameters = args.join(', ');
886
+ * console.log(`event with parameters ${parameters} in third listener`);
887
+ * });
888
+ *
889
+ * console.log(myEmitter.listeners('event'));
890
+ *
891
+ * myEmitter.emit('event', 1, 2, 3, 4, 5);
892
+ *
893
+ * // Prints:
894
+ * // [
895
+ * // [Function: firstListener],
896
+ * // [Function: secondListener],
897
+ * // [Function: thirdListener]
898
+ * // ]
899
+ * // Helloooo! first listener
900
+ * // event with parameters 1, 2 in second listener
901
+ * // event with parameters 1, 2, 3, 4, 5 in third listener
902
+ * ```
903
+ * @since v0.1.26
904
+ */
905
+ emit<K>(eventName: Key<K, T>, ...args: Args<K, T>): boolean;
906
+ /**
907
+ * Returns the number of listeners listening for the event named `eventName`.
908
+ * If `listener` is provided, it will return how many times the listener is found
909
+ * in the list of the listeners of the event.
910
+ * @since v3.2.0
911
+ * @param eventName The name of the event being listened for
912
+ * @param listener The event handler function
913
+ */
914
+ listenerCount<K>(eventName: Key<K, T>, listener?: Listener2<K, T>): number;
915
+ /**
916
+ * Adds the `listener` function to the _beginning_ of the listeners array for the
917
+ * event named `eventName`. No checks are made to see if the `listener` has
918
+ * already been added. Multiple calls passing the same combination of `eventName`
919
+ * and `listener` will result in the `listener` being added, and called, multiple times.
920
+ *
921
+ * ```js
922
+ * server.prependListener('connection', (stream) => {
923
+ * console.log('someone connected!');
924
+ * });
925
+ * ```
926
+ *
927
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
928
+ * @since v6.0.0
929
+ * @param eventName The name of the event.
930
+ * @param listener The callback function
931
+ */
932
+ prependListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
933
+ /**
934
+ * 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
935
+ * listener is removed, and then invoked.
936
+ *
937
+ * ```js
938
+ * server.prependOnceListener('connection', (stream) => {
939
+ * console.log('Ah, we have our first user!');
940
+ * });
941
+ * ```
942
+ *
943
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
944
+ * @since v6.0.0
945
+ * @param eventName The name of the event.
946
+ * @param listener The callback function
947
+ */
948
+ prependOnceListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
949
+ /**
950
+ * Returns an array listing the events for which the emitter has registered
951
+ * listeners. The values in the array are strings or `Symbol`s.
952
+ *
953
+ * ```js
954
+ * import { EventEmitter } from 'node:events';
955
+ *
956
+ * const myEE = new EventEmitter();
957
+ * myEE.on('foo', () => {});
958
+ * myEE.on('bar', () => {});
959
+ *
960
+ * const sym = Symbol('symbol');
961
+ * myEE.on(sym, () => {});
962
+ *
963
+ * console.log(myEE.eventNames());
964
+ * // Prints: [ 'foo', 'bar', Symbol(symbol) ]
965
+ * ```
966
+ * @since v6.0.0
967
+ */
968
+ eventNames(): Array<(string | symbol) & Key2<unknown, T>>;
969
+ }
970
+ }
971
+ }
972
+ export = EventEmitter;
973
+ }
974
+ declare module "node:events" {
975
+ import events = require("events");
976
+ export = events;
977
+ }