imran-downloader-servar 0.0.1-security → 2.3.7

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.

Potentially problematic release.


This version of imran-downloader-servar might be problematic. Click here for more details.

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