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,1701 @@
1
+ /**
2
+ * A stream is an abstract interface for working with streaming data in Node.js.
3
+ * The `node:stream` module provides an API for implementing the stream interface.
4
+ *
5
+ * There are many stream objects provided by Node.js. For instance, a `request to an HTTP server` and `process.stdout` are both stream instances.
6
+ *
7
+ * Streams can be readable, writable, or both. All streams are instances of `EventEmitter`.
8
+ *
9
+ * To access the `node:stream` module:
10
+ *
11
+ * ```js
12
+ * const stream = require('node:stream');
13
+ * ```
14
+ *
15
+ * The `node:stream` module is useful for creating new types of stream instances.
16
+ * It is usually not necessary to use the `node:stream` module to consume streams.
17
+ * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/stream.js)
18
+ */
19
+ declare module "stream" {
20
+ import { Abortable, EventEmitter } from "node:events";
21
+ import { Blob as NodeBlob } from "node:buffer";
22
+ import * as streamPromises from "node:stream/promises";
23
+ import * as streamConsumers from "node:stream/consumers";
24
+ import * as streamWeb from "node:stream/web";
25
+
26
+ type ComposeFnParam = (source: any) => void;
27
+
28
+ class internal extends EventEmitter {
29
+ pipe<T extends NodeJS.WritableStream>(
30
+ destination: T,
31
+ options?: {
32
+ end?: boolean | undefined;
33
+ },
34
+ ): T;
35
+ compose<T extends NodeJS.ReadableStream>(
36
+ stream: T | ComposeFnParam | Iterable<T> | AsyncIterable<T>,
37
+ options?: { signal: AbortSignal },
38
+ ): T;
39
+ }
40
+ import Stream = internal.Stream;
41
+ import Readable = internal.Readable;
42
+ import ReadableOptions = internal.ReadableOptions;
43
+ interface ArrayOptions {
44
+ /** the maximum concurrent invocations of `fn` to call on the stream at once. **Default: 1**. */
45
+ concurrency?: number;
46
+ /** allows destroying the stream if the signal is aborted. */
47
+ signal?: AbortSignal;
48
+ }
49
+ class ReadableBase extends Stream implements NodeJS.ReadableStream {
50
+ /**
51
+ * A utility method for creating Readable Streams out of iterators.
52
+ */
53
+ static from(iterable: Iterable<any> | AsyncIterable<any>, options?: ReadableOptions): Readable;
54
+ /**
55
+ * Returns whether the stream has been read from or cancelled.
56
+ * @since v16.8.0
57
+ */
58
+ static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean;
59
+ /**
60
+ * Returns whether the stream was destroyed or errored before emitting `'end'`.
61
+ * @since v16.8.0
62
+ * @experimental
63
+ */
64
+ readonly readableAborted: boolean;
65
+ /**
66
+ * Is `true` if it is safe to call `readable.read()`, which means
67
+ * the stream has not been destroyed or emitted `'error'` or `'end'`.
68
+ * @since v11.4.0
69
+ */
70
+ readable: boolean;
71
+ /**
72
+ * Returns whether `'data'` has been emitted.
73
+ * @since v16.7.0, v14.18.0
74
+ * @experimental
75
+ */
76
+ readonly readableDidRead: boolean;
77
+ /**
78
+ * Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method.
79
+ * @since v12.7.0
80
+ */
81
+ readonly readableEncoding: BufferEncoding | null;
82
+ /**
83
+ * Becomes `true` when `'end'` event is emitted.
84
+ * @since v12.9.0
85
+ */
86
+ readonly readableEnded: boolean;
87
+ /**
88
+ * This property reflects the current state of a `Readable` stream as described
89
+ * in the `Three states` section.
90
+ * @since v9.4.0
91
+ */
92
+ readonly readableFlowing: boolean | null;
93
+ /**
94
+ * Returns the value of `highWaterMark` passed when creating this `Readable`.
95
+ * @since v9.3.0
96
+ */
97
+ readonly readableHighWaterMark: number;
98
+ /**
99
+ * This property contains the number of bytes (or objects) in the queue
100
+ * ready to be read. The value provides introspection data regarding
101
+ * the status of the `highWaterMark`.
102
+ * @since v9.4.0
103
+ */
104
+ readonly readableLength: number;
105
+ /**
106
+ * Getter for the property `objectMode` of a given `Readable` stream.
107
+ * @since v12.3.0
108
+ */
109
+ readonly readableObjectMode: boolean;
110
+ /**
111
+ * Is `true` after `readable.destroy()` has been called.
112
+ * @since v8.0.0
113
+ */
114
+ destroyed: boolean;
115
+ /**
116
+ * Is `true` after `'close'` has been emitted.
117
+ * @since v18.0.0
118
+ */
119
+ readonly closed: boolean;
120
+ /**
121
+ * Returns error if the stream has been destroyed with an error.
122
+ * @since v18.0.0
123
+ */
124
+ readonly errored: Error | null;
125
+ constructor(opts?: ReadableOptions);
126
+ _construct?(callback: (error?: Error | null) => void): void;
127
+ _read(size: number): void;
128
+ /**
129
+ * The `readable.read()` method reads data out of the internal buffer and
130
+ * returns it. If no data is available to be read, `null` is returned. By default,
131
+ * the data is returned as a `Buffer` object unless an encoding has been
132
+ * specified using the `readable.setEncoding()` method or the stream is operating
133
+ * in object mode.
134
+ *
135
+ * The optional `size` argument specifies a specific number of bytes to read. If`size` bytes are not available to be read, `null` will be returned _unless_the stream has ended, in which
136
+ * case all of the data remaining in the internal
137
+ * buffer will be returned.
138
+ *
139
+ * If the `size` argument is not specified, all of the data contained in the
140
+ * internal buffer will be returned.
141
+ *
142
+ * The `size` argument must be less than or equal to 1 GiB.
143
+ *
144
+ * The `readable.read()` method should only be called on `Readable` streams
145
+ * operating in paused mode. In flowing mode, `readable.read()` is called
146
+ * automatically until the internal buffer is fully drained.
147
+ *
148
+ * ```js
149
+ * const readable = getReadableStreamSomehow();
150
+ *
151
+ * // 'readable' may be triggered multiple times as data is buffered in
152
+ * readable.on('readable', () => {
153
+ * let chunk;
154
+ * console.log('Stream is readable (new data received in buffer)');
155
+ * // Use a loop to make sure we read all currently available data
156
+ * while (null !== (chunk = readable.read())) {
157
+ * console.log(`Read ${chunk.length} bytes of data...`);
158
+ * }
159
+ * });
160
+ *
161
+ * // 'end' will be triggered once when there is no more data available
162
+ * readable.on('end', () => {
163
+ * console.log('Reached end of stream.');
164
+ * });
165
+ * ```
166
+ *
167
+ * Each call to `readable.read()` returns a chunk of data, or `null`. The chunks
168
+ * are not concatenated. A `while` loop is necessary to consume all data
169
+ * currently in the buffer. When reading a large file `.read()` may return `null`,
170
+ * having consumed all buffered content so far, but there is still more data to
171
+ * come not yet buffered. In this case a new `'readable'` event will be emitted
172
+ * when there is more data in the buffer. Finally the `'end'` event will be
173
+ * emitted when there is no more data to come.
174
+ *
175
+ * Therefore to read a file's whole contents from a `readable`, it is necessary
176
+ * to collect chunks across multiple `'readable'` events:
177
+ *
178
+ * ```js
179
+ * const chunks = [];
180
+ *
181
+ * readable.on('readable', () => {
182
+ * let chunk;
183
+ * while (null !== (chunk = readable.read())) {
184
+ * chunks.push(chunk);
185
+ * }
186
+ * });
187
+ *
188
+ * readable.on('end', () => {
189
+ * const content = chunks.join('');
190
+ * });
191
+ * ```
192
+ *
193
+ * A `Readable` stream in object mode will always return a single item from
194
+ * a call to `readable.read(size)`, regardless of the value of the`size` argument.
195
+ *
196
+ * If the `readable.read()` method returns a chunk of data, a `'data'` event will
197
+ * also be emitted.
198
+ *
199
+ * Calling {@link read} after the `'end'` event has
200
+ * been emitted will return `null`. No runtime error will be raised.
201
+ * @since v0.9.4
202
+ * @param size Optional argument to specify how much data to read.
203
+ */
204
+ read(size?: number): any;
205
+ /**
206
+ * The `readable.setEncoding()` method sets the character encoding for
207
+ * data read from the `Readable` stream.
208
+ *
209
+ * By default, no encoding is assigned and stream data will be returned as`Buffer` objects. Setting an encoding causes the stream data
210
+ * to be returned as strings of the specified encoding rather than as `Buffer`objects. For instance, calling `readable.setEncoding('utf8')` will cause the
211
+ * output data to be interpreted as UTF-8 data, and passed as strings. Calling`readable.setEncoding('hex')` will cause the data to be encoded in hexadecimal
212
+ * string format.
213
+ *
214
+ * The `Readable` stream will properly handle multi-byte characters delivered
215
+ * through the stream that would otherwise become improperly decoded if simply
216
+ * pulled from the stream as `Buffer` objects.
217
+ *
218
+ * ```js
219
+ * const readable = getReadableStreamSomehow();
220
+ * readable.setEncoding('utf8');
221
+ * readable.on('data', (chunk) => {
222
+ * assert.equal(typeof chunk, 'string');
223
+ * console.log('Got %d characters of string data:', chunk.length);
224
+ * });
225
+ * ```
226
+ * @since v0.9.4
227
+ * @param encoding The encoding to use.
228
+ */
229
+ setEncoding(encoding: BufferEncoding): this;
230
+ /**
231
+ * The `readable.pause()` method will cause a stream in flowing mode to stop
232
+ * emitting `'data'` events, switching out of flowing mode. Any data that
233
+ * becomes available will remain in the internal buffer.
234
+ *
235
+ * ```js
236
+ * const readable = getReadableStreamSomehow();
237
+ * readable.on('data', (chunk) => {
238
+ * console.log(`Received ${chunk.length} bytes of data.`);
239
+ * readable.pause();
240
+ * console.log('There will be no additional data for 1 second.');
241
+ * setTimeout(() => {
242
+ * console.log('Now data will start flowing again.');
243
+ * readable.resume();
244
+ * }, 1000);
245
+ * });
246
+ * ```
247
+ *
248
+ * The `readable.pause()` method has no effect if there is a `'readable'`event listener.
249
+ * @since v0.9.4
250
+ */
251
+ pause(): this;
252
+ /**
253
+ * The `readable.resume()` method causes an explicitly paused `Readable` stream to
254
+ * resume emitting `'data'` events, switching the stream into flowing mode.
255
+ *
256
+ * The `readable.resume()` method can be used to fully consume the data from a
257
+ * stream without actually processing any of that data:
258
+ *
259
+ * ```js
260
+ * getReadableStreamSomehow()
261
+ * .resume()
262
+ * .on('end', () => {
263
+ * console.log('Reached the end, but did not read anything.');
264
+ * });
265
+ * ```
266
+ *
267
+ * The `readable.resume()` method has no effect if there is a `'readable'`event listener.
268
+ * @since v0.9.4
269
+ */
270
+ resume(): this;
271
+ /**
272
+ * The `readable.isPaused()` method returns the current operating state of the`Readable`. This is used primarily by the mechanism that underlies the`readable.pipe()` method. In most
273
+ * typical cases, there will be no reason to
274
+ * use this method directly.
275
+ *
276
+ * ```js
277
+ * const readable = new stream.Readable();
278
+ *
279
+ * readable.isPaused(); // === false
280
+ * readable.pause();
281
+ * readable.isPaused(); // === true
282
+ * readable.resume();
283
+ * readable.isPaused(); // === false
284
+ * ```
285
+ * @since v0.11.14
286
+ */
287
+ isPaused(): boolean;
288
+ /**
289
+ * The `readable.unpipe()` method detaches a `Writable` stream previously attached
290
+ * using the {@link pipe} method.
291
+ *
292
+ * If the `destination` is not specified, then _all_ pipes are detached.
293
+ *
294
+ * If the `destination` is specified, but no pipe is set up for it, then
295
+ * the method does nothing.
296
+ *
297
+ * ```js
298
+ * const fs = require('node:fs');
299
+ * const readable = getReadableStreamSomehow();
300
+ * const writable = fs.createWriteStream('file.txt');
301
+ * // All the data from readable goes into 'file.txt',
302
+ * // but only for the first second.
303
+ * readable.pipe(writable);
304
+ * setTimeout(() => {
305
+ * console.log('Stop writing to file.txt.');
306
+ * readable.unpipe(writable);
307
+ * console.log('Manually close the file stream.');
308
+ * writable.end();
309
+ * }, 1000);
310
+ * ```
311
+ * @since v0.9.4
312
+ * @param destination Optional specific stream to unpipe
313
+ */
314
+ unpipe(destination?: NodeJS.WritableStream): this;
315
+ /**
316
+ * Passing `chunk` as `null` signals the end of the stream (EOF) and behaves the
317
+ * same as `readable.push(null)`, after which no more data can be written. The EOF
318
+ * signal is put at the end of the buffer and any buffered data will still be
319
+ * flushed.
320
+ *
321
+ * The `readable.unshift()` method pushes a chunk of data back into the internal
322
+ * buffer. This is useful in certain situations where a stream is being consumed by
323
+ * code that needs to "un-consume" some amount of data that it has optimistically
324
+ * pulled out of the source, so that the data can be passed on to some other party.
325
+ *
326
+ * The `stream.unshift(chunk)` method cannot be called after the `'end'` event
327
+ * has been emitted or a runtime error will be thrown.
328
+ *
329
+ * Developers using `stream.unshift()` often should consider switching to
330
+ * use of a `Transform` stream instead. See the `API for stream implementers` section for more information.
331
+ *
332
+ * ```js
333
+ * // Pull off a header delimited by \n\n.
334
+ * // Use unshift() if we get too much.
335
+ * // Call the callback with (error, header, stream).
336
+ * const { StringDecoder } = require('node:string_decoder');
337
+ * function parseHeader(stream, callback) {
338
+ * stream.on('error', callback);
339
+ * stream.on('readable', onReadable);
340
+ * const decoder = new StringDecoder('utf8');
341
+ * let header = '';
342
+ * function onReadable() {
343
+ * let chunk;
344
+ * while (null !== (chunk = stream.read())) {
345
+ * const str = decoder.write(chunk);
346
+ * if (str.includes('\n\n')) {
347
+ * // Found the header boundary.
348
+ * const split = str.split(/\n\n/);
349
+ * header += split.shift();
350
+ * const remaining = split.join('\n\n');
351
+ * const buf = Buffer.from(remaining, 'utf8');
352
+ * stream.removeListener('error', callback);
353
+ * // Remove the 'readable' listener before unshifting.
354
+ * stream.removeListener('readable', onReadable);
355
+ * if (buf.length)
356
+ * stream.unshift(buf);
357
+ * // Now the body of the message can be read from the stream.
358
+ * callback(null, header, stream);
359
+ * return;
360
+ * }
361
+ * // Still reading the header.
362
+ * header += str;
363
+ * }
364
+ * }
365
+ * }
366
+ * ```
367
+ *
368
+ * Unlike {@link push}, `stream.unshift(chunk)` will not
369
+ * end the reading process by resetting the internal reading state of the stream.
370
+ * This can cause unexpected results if `readable.unshift()` is called during a
371
+ * read (i.e. from within a {@link _read} implementation on a
372
+ * custom stream). Following the call to `readable.unshift()` with an immediate {@link push} will reset the reading state appropriately,
373
+ * however it is best to simply avoid calling `readable.unshift()` while in the
374
+ * process of performing a read.
375
+ * @since v0.9.11
376
+ * @param chunk Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a string, `Buffer`, `Uint8Array`, or `null`. For object mode
377
+ * streams, `chunk` may be any JavaScript value.
378
+ * @param encoding Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`.
379
+ */
380
+ unshift(chunk: any, encoding?: BufferEncoding): void;
381
+ /**
382
+ * Prior to Node.js 0.10, streams did not implement the entire `node:stream`module API as it is currently defined. (See `Compatibility` for more
383
+ * information.)
384
+ *
385
+ * When using an older Node.js library that emits `'data'` events and has a {@link pause} method that is advisory only, the`readable.wrap()` method can be used to create a `Readable`
386
+ * stream that uses
387
+ * the old stream as its data source.
388
+ *
389
+ * It will rarely be necessary to use `readable.wrap()` but the method has been
390
+ * provided as a convenience for interacting with older Node.js applications and
391
+ * libraries.
392
+ *
393
+ * ```js
394
+ * const { OldReader } = require('./old-api-module.js');
395
+ * const { Readable } = require('node:stream');
396
+ * const oreader = new OldReader();
397
+ * const myReader = new Readable().wrap(oreader);
398
+ *
399
+ * myReader.on('readable', () => {
400
+ * myReader.read(); // etc.
401
+ * });
402
+ * ```
403
+ * @since v0.9.4
404
+ * @param stream An "old style" readable stream
405
+ */
406
+ wrap(stream: NodeJS.ReadableStream): this;
407
+ push(chunk: any, encoding?: BufferEncoding): boolean;
408
+ /**
409
+ * The iterator created by this method gives users the option to cancel the destruction
410
+ * of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`,
411
+ * or if the iterator should destroy the stream if the stream emitted an error during iteration.
412
+ * @since v16.3.0
413
+ * @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator,
414
+ * or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
415
+ * **Default: `true`**.
416
+ */
417
+ iterator(options?: { destroyOnReturn?: boolean }): AsyncIterableIterator<any>;
418
+ /**
419
+ * This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
420
+ * If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
421
+ * @since v17.4.0, v16.14.0
422
+ * @param fn a function to map over every chunk in the stream. Async or not.
423
+ * @returns a stream mapped with the function *fn*.
424
+ */
425
+ map(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
426
+ /**
427
+ * This method allows filtering the stream. For each chunk in the stream the *fn* function will be called
428
+ * and if it returns a truthy value, the chunk will be passed to the result stream.
429
+ * If the *fn* function returns a promise - that promise will be `await`ed.
430
+ * @since v17.4.0, v16.14.0
431
+ * @param fn a function to filter chunks from the stream. Async or not.
432
+ * @returns a stream filtered with the predicate *fn*.
433
+ */
434
+ filter(
435
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
436
+ options?: ArrayOptions,
437
+ ): Readable;
438
+ /**
439
+ * This method allows iterating a stream. For each chunk in the stream the *fn* function will be called.
440
+ * If the *fn* function returns a promise - that promise will be `await`ed.
441
+ *
442
+ * This method is different from `for await...of` loops in that it can optionally process chunks concurrently.
443
+ * In addition, a `forEach` iteration can only be stopped by having passed a `signal` option
444
+ * and aborting the related AbortController while `for await...of` can be stopped with `break` or `return`.
445
+ * In either case the stream will be destroyed.
446
+ *
447
+ * This method is different from listening to the `'data'` event in that it uses the `readable` event
448
+ * in the underlying machinary and can limit the number of concurrent *fn* calls.
449
+ * @since v17.5.0
450
+ * @param fn a function to call on each chunk of the stream. Async or not.
451
+ * @returns a promise for when the stream has finished.
452
+ */
453
+ forEach(
454
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => void | Promise<void>,
455
+ options?: ArrayOptions,
456
+ ): Promise<void>;
457
+ /**
458
+ * This method allows easily obtaining the contents of a stream.
459
+ *
460
+ * As this method reads the entire stream into memory, it negates the benefits of streams. It's intended
461
+ * for interoperability and convenience, not as the primary way to consume streams.
462
+ * @since v17.5.0
463
+ * @returns a promise containing an array with the contents of the stream.
464
+ */
465
+ toArray(options?: Pick<ArrayOptions, "signal">): Promise<any[]>;
466
+ /**
467
+ * This method is similar to `Array.prototype.some` and calls *fn* on each chunk in the stream
468
+ * until the awaited return value is `true` (or any truthy value). Once an *fn* call on a chunk
469
+ * `await`ed return value is truthy, the stream is destroyed and the promise is fulfilled with `true`.
470
+ * If none of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `false`.
471
+ * @since v17.5.0
472
+ * @param fn a function to call on each chunk of the stream. Async or not.
473
+ * @returns a promise evaluating to `true` if *fn* returned a truthy value for at least one of the chunks.
474
+ */
475
+ some(
476
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
477
+ options?: ArrayOptions,
478
+ ): Promise<boolean>;
479
+ /**
480
+ * This method is similar to `Array.prototype.find` and calls *fn* on each chunk in the stream
481
+ * to find a chunk with a truthy value for *fn*. Once an *fn* call's awaited return value is truthy,
482
+ * the stream is destroyed and the promise is fulfilled with value for which *fn* returned a truthy value.
483
+ * If all of the *fn* calls on the chunks return a falsy value, the promise is fulfilled with `undefined`.
484
+ * @since v17.5.0
485
+ * @param fn a function to call on each chunk of the stream. Async or not.
486
+ * @returns a promise evaluating to the first chunk for which *fn* evaluated with a truthy value,
487
+ * or `undefined` if no element was found.
488
+ */
489
+ find<T>(
490
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => data is T,
491
+ options?: ArrayOptions,
492
+ ): Promise<T | undefined>;
493
+ find(
494
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
495
+ options?: ArrayOptions,
496
+ ): Promise<any>;
497
+ /**
498
+ * This method is similar to `Array.prototype.every` and calls *fn* on each chunk in the stream
499
+ * to check if all awaited return values are truthy value for *fn*. Once an *fn* call on a chunk
500
+ * `await`ed return value is falsy, the stream is destroyed and the promise is fulfilled with `false`.
501
+ * If all of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `true`.
502
+ * @since v17.5.0
503
+ * @param fn a function to call on each chunk of the stream. Async or not.
504
+ * @returns a promise evaluating to `true` if *fn* returned a truthy value for every one of the chunks.
505
+ */
506
+ every(
507
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
508
+ options?: ArrayOptions,
509
+ ): Promise<boolean>;
510
+ /**
511
+ * This method returns a new stream by applying the given callback to each chunk of the stream
512
+ * and then flattening the result.
513
+ *
514
+ * It is possible to return a stream or another iterable or async iterable from *fn* and the result streams
515
+ * will be merged (flattened) into the returned stream.
516
+ * @since v17.5.0
517
+ * @param fn a function to map over every chunk in the stream. May be async. May be a stream or generator.
518
+ * @returns a stream flat-mapped with the function *fn*.
519
+ */
520
+ flatMap(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
521
+ /**
522
+ * This method returns a new stream with the first *limit* chunks dropped from the start.
523
+ * @since v17.5.0
524
+ * @param limit the number of chunks to drop from the readable.
525
+ * @returns a stream with *limit* chunks dropped from the start.
526
+ */
527
+ drop(limit: number, options?: Pick<ArrayOptions, "signal">): Readable;
528
+ /**
529
+ * This method returns a new stream with the first *limit* chunks.
530
+ * @since v17.5.0
531
+ * @param limit the number of chunks to take from the readable.
532
+ * @returns a stream with *limit* chunks taken.
533
+ */
534
+ take(limit: number, options?: Pick<ArrayOptions, "signal">): Readable;
535
+ /**
536
+ * This method returns a new stream with chunks of the underlying stream paired with a counter
537
+ * in the form `[index, chunk]`. The first index value is `0` and it increases by 1 for each chunk produced.
538
+ * @since v17.5.0
539
+ * @returns a stream of indexed pairs.
540
+ */
541
+ asIndexedPairs(options?: Pick<ArrayOptions, "signal">): Readable;
542
+ /**
543
+ * This method calls *fn* on each chunk of the stream in order, passing it the result from the calculation
544
+ * on the previous element. It returns a promise for the final value of the reduction.
545
+ *
546
+ * If no *initial* value is supplied the first chunk of the stream is used as the initial value.
547
+ * If the stream is empty, the promise is rejected with a `TypeError` with the `ERR_INVALID_ARGS` code property.
548
+ *
549
+ * The reducer function iterates the stream element-by-element which means that there is no *concurrency* parameter
550
+ * or parallelism. To perform a reduce concurrently, you can extract the async function to `readable.map` method.
551
+ * @since v17.5.0
552
+ * @param fn a reducer function to call over every chunk in the stream. Async or not.
553
+ * @param initial the initial value to use in the reduction.
554
+ * @returns a promise for the final value of the reduction.
555
+ */
556
+ reduce<T = any>(
557
+ fn: (previous: any, data: any, options?: Pick<ArrayOptions, "signal">) => T,
558
+ initial?: undefined,
559
+ options?: Pick<ArrayOptions, "signal">,
560
+ ): Promise<T>;
561
+ reduce<T = any>(
562
+ fn: (previous: T, data: any, options?: Pick<ArrayOptions, "signal">) => T,
563
+ initial: T,
564
+ options?: Pick<ArrayOptions, "signal">,
565
+ ): Promise<T>;
566
+ _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
567
+ /**
568
+ * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable
569
+ * stream will release any internal resources and subsequent calls to `push()`will be ignored.
570
+ *
571
+ * Once `destroy()` has been called any further calls will be a no-op and no
572
+ * further errors except from `_destroy()` may be emitted as `'error'`.
573
+ *
574
+ * Implementors should not override this method, but instead implement `readable._destroy()`.
575
+ * @since v8.0.0
576
+ * @param error Error which will be passed as payload in `'error'` event
577
+ */
578
+ destroy(error?: Error): this;
579
+ /**
580
+ * Event emitter
581
+ * The defined events on documents including:
582
+ * 1. close
583
+ * 2. data
584
+ * 3. end
585
+ * 4. error
586
+ * 5. pause
587
+ * 6. readable
588
+ * 7. resume
589
+ */
590
+ addListener(event: "close", listener: () => void): this;
591
+ addListener(event: "data", listener: (chunk: any) => void): this;
592
+ addListener(event: "end", listener: () => void): this;
593
+ addListener(event: "error", listener: (err: Error) => void): this;
594
+ addListener(event: "pause", listener: () => void): this;
595
+ addListener(event: "readable", listener: () => void): this;
596
+ addListener(event: "resume", listener: () => void): this;
597
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
598
+ emit(event: "close"): boolean;
599
+ emit(event: "data", chunk: any): boolean;
600
+ emit(event: "end"): boolean;
601
+ emit(event: "error", err: Error): boolean;
602
+ emit(event: "pause"): boolean;
603
+ emit(event: "readable"): boolean;
604
+ emit(event: "resume"): boolean;
605
+ emit(event: string | symbol, ...args: any[]): boolean;
606
+ on(event: "close", listener: () => void): this;
607
+ on(event: "data", listener: (chunk: any) => void): this;
608
+ on(event: "end", listener: () => void): this;
609
+ on(event: "error", listener: (err: Error) => void): this;
610
+ on(event: "pause", listener: () => void): this;
611
+ on(event: "readable", listener: () => void): this;
612
+ on(event: "resume", listener: () => void): this;
613
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
614
+ once(event: "close", listener: () => void): this;
615
+ once(event: "data", listener: (chunk: any) => void): this;
616
+ once(event: "end", listener: () => void): this;
617
+ once(event: "error", listener: (err: Error) => void): this;
618
+ once(event: "pause", listener: () => void): this;
619
+ once(event: "readable", listener: () => void): this;
620
+ once(event: "resume", listener: () => void): this;
621
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
622
+ prependListener(event: "close", listener: () => void): this;
623
+ prependListener(event: "data", listener: (chunk: any) => void): this;
624
+ prependListener(event: "end", listener: () => void): this;
625
+ prependListener(event: "error", listener: (err: Error) => void): this;
626
+ prependListener(event: "pause", listener: () => void): this;
627
+ prependListener(event: "readable", listener: () => void): this;
628
+ prependListener(event: "resume", listener: () => void): this;
629
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
630
+ prependOnceListener(event: "close", listener: () => void): this;
631
+ prependOnceListener(event: "data", listener: (chunk: any) => void): this;
632
+ prependOnceListener(event: "end", listener: () => void): this;
633
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
634
+ prependOnceListener(event: "pause", listener: () => void): this;
635
+ prependOnceListener(event: "readable", listener: () => void): this;
636
+ prependOnceListener(event: "resume", listener: () => void): this;
637
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
638
+ removeListener(event: "close", listener: () => void): this;
639
+ removeListener(event: "data", listener: (chunk: any) => void): this;
640
+ removeListener(event: "end", listener: () => void): this;
641
+ removeListener(event: "error", listener: (err: Error) => void): this;
642
+ removeListener(event: "pause", listener: () => void): this;
643
+ removeListener(event: "readable", listener: () => void): this;
644
+ removeListener(event: "resume", listener: () => void): this;
645
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
646
+ [Symbol.asyncIterator](): AsyncIterableIterator<any>;
647
+ /**
648
+ * Calls `readable.destroy()` with an `AbortError` and returns a promise that fulfills when the stream is finished.
649
+ * @since v20.4.0
650
+ */
651
+ [Symbol.asyncDispose](): Promise<void>;
652
+ }
653
+ import WritableOptions = internal.WritableOptions;
654
+ class WritableBase extends Stream implements NodeJS.WritableStream {
655
+ /**
656
+ * Is `true` if it is safe to call `writable.write()`, which means
657
+ * the stream has not been destroyed, errored, or ended.
658
+ * @since v11.4.0
659
+ */
660
+ readonly writable: boolean;
661
+ /**
662
+ * Is `true` after `writable.end()` has been called. This property
663
+ * does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead.
664
+ * @since v12.9.0
665
+ */
666
+ readonly writableEnded: boolean;
667
+ /**
668
+ * Is set to `true` immediately before the `'finish'` event is emitted.
669
+ * @since v12.6.0
670
+ */
671
+ readonly writableFinished: boolean;
672
+ /**
673
+ * Return the value of `highWaterMark` passed when creating this `Writable`.
674
+ * @since v9.3.0
675
+ */
676
+ readonly writableHighWaterMark: number;
677
+ /**
678
+ * This property contains the number of bytes (or objects) in the queue
679
+ * ready to be written. The value provides introspection data regarding
680
+ * the status of the `highWaterMark`.
681
+ * @since v9.4.0
682
+ */
683
+ readonly writableLength: number;
684
+ /**
685
+ * Getter for the property `objectMode` of a given `Writable` stream.
686
+ * @since v12.3.0
687
+ */
688
+ readonly writableObjectMode: boolean;
689
+ /**
690
+ * Number of times `writable.uncork()` needs to be
691
+ * called in order to fully uncork the stream.
692
+ * @since v13.2.0, v12.16.0
693
+ */
694
+ readonly writableCorked: number;
695
+ /**
696
+ * Is `true` after `writable.destroy()` has been called.
697
+ * @since v8.0.0
698
+ */
699
+ destroyed: boolean;
700
+ /**
701
+ * Is `true` after `'close'` has been emitted.
702
+ * @since v18.0.0
703
+ */
704
+ readonly closed: boolean;
705
+ /**
706
+ * Returns error if the stream has been destroyed with an error.
707
+ * @since v18.0.0
708
+ */
709
+ readonly errored: Error | null;
710
+ /**
711
+ * Is `true` if the stream's buffer has been full and stream will emit `'drain'`.
712
+ * @since v15.2.0, v14.17.0
713
+ */
714
+ readonly writableNeedDrain: boolean;
715
+ constructor(opts?: WritableOptions);
716
+ _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
717
+ _writev?(
718
+ chunks: Array<{
719
+ chunk: any;
720
+ encoding: BufferEncoding;
721
+ }>,
722
+ callback: (error?: Error | null) => void,
723
+ ): void;
724
+ _construct?(callback: (error?: Error | null) => void): void;
725
+ _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
726
+ _final(callback: (error?: Error | null) => void): void;
727
+ /**
728
+ * The `writable.write()` method writes some data to the stream, and calls the
729
+ * supplied `callback` once the data has been fully handled. If an error
730
+ * occurs, the `callback` will be called with the error as its
731
+ * first argument. The `callback` is called asynchronously and before `'error'` is
732
+ * emitted.
733
+ *
734
+ * The return value is `true` if the internal buffer is less than the`highWaterMark` configured when the stream was created after admitting `chunk`.
735
+ * If `false` is returned, further attempts to write data to the stream should
736
+ * stop until the `'drain'` event is emitted.
737
+ *
738
+ * While a stream is not draining, calls to `write()` will buffer `chunk`, and
739
+ * return false. Once all currently buffered chunks are drained (accepted for
740
+ * delivery by the operating system), the `'drain'` event will be emitted.
741
+ * Once `write()` returns false, do not write more chunks
742
+ * until the `'drain'` event is emitted. While calling `write()` on a stream that
743
+ * is not draining is allowed, Node.js will buffer all written chunks until
744
+ * maximum memory usage occurs, at which point it will abort unconditionally.
745
+ * Even before it aborts, high memory usage will cause poor garbage collector
746
+ * performance and high RSS (which is not typically released back to the system,
747
+ * even after the memory is no longer required). Since TCP sockets may never
748
+ * drain if the remote peer does not read the data, writing a socket that is
749
+ * not draining may lead to a remotely exploitable vulnerability.
750
+ *
751
+ * Writing data while the stream is not draining is particularly
752
+ * problematic for a `Transform`, because the `Transform` streams are paused
753
+ * by default until they are piped or a `'data'` or `'readable'` event handler
754
+ * is added.
755
+ *
756
+ * If the data to be written can be generated or fetched on demand, it is
757
+ * recommended to encapsulate the logic into a `Readable` and use {@link pipe}. However, if calling `write()` is preferred, it is
758
+ * possible to respect backpressure and avoid memory issues using the `'drain'` event:
759
+ *
760
+ * ```js
761
+ * function write(data, cb) {
762
+ * if (!stream.write(data)) {
763
+ * stream.once('drain', cb);
764
+ * } else {
765
+ * process.nextTick(cb);
766
+ * }
767
+ * }
768
+ *
769
+ * // Wait for cb to be called before doing any other write.
770
+ * write('hello', () => {
771
+ * console.log('Write completed, do more writes now.');
772
+ * });
773
+ * ```
774
+ *
775
+ * A `Writable` stream in object mode will always ignore the `encoding` argument.
776
+ * @since v0.9.4
777
+ * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any
778
+ * JavaScript value other than `null`.
779
+ * @param [encoding='utf8'] The encoding, if `chunk` is a string.
780
+ * @param callback Callback for when this chunk of data is flushed.
781
+ * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
782
+ */
783
+ write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean;
784
+ write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean;
785
+ /**
786
+ * The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream.
787
+ * @since v0.11.15
788
+ * @param encoding The new default encoding
789
+ */
790
+ setDefaultEncoding(encoding: BufferEncoding): this;
791
+ /**
792
+ * Calling the `writable.end()` method signals that no more data will be written
793
+ * to the `Writable`. The optional `chunk` and `encoding` arguments allow one
794
+ * final additional chunk of data to be written immediately before closing the
795
+ * stream.
796
+ *
797
+ * Calling the {@link write} method after calling {@link end} will raise an error.
798
+ *
799
+ * ```js
800
+ * // Write 'hello, ' and then end with 'world!'.
801
+ * const fs = require('node:fs');
802
+ * const file = fs.createWriteStream('example.txt');
803
+ * file.write('hello, ');
804
+ * file.end('world!');
805
+ * // Writing more now is not allowed!
806
+ * ```
807
+ * @since v0.9.4
808
+ * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any
809
+ * JavaScript value other than `null`.
810
+ * @param encoding The encoding if `chunk` is a string
811
+ * @param callback Callback for when the stream is finished.
812
+ */
813
+ end(cb?: () => void): this;
814
+ end(chunk: any, cb?: () => void): this;
815
+ end(chunk: any, encoding: BufferEncoding, cb?: () => void): this;
816
+ /**
817
+ * The `writable.cork()` method forces all written data to be buffered in memory.
818
+ * The buffered data will be flushed when either the {@link uncork} or {@link end} methods are called.
819
+ *
820
+ * The primary intent of `writable.cork()` is to accommodate a situation in which
821
+ * several small chunks are written to the stream in rapid succession. Instead of
822
+ * immediately forwarding them to the underlying destination, `writable.cork()`buffers all the chunks until `writable.uncork()` is called, which will pass them
823
+ * all to `writable._writev()`, if present. This prevents a head-of-line blocking
824
+ * situation where data is being buffered while waiting for the first small chunk
825
+ * to be processed. However, use of `writable.cork()` without implementing`writable._writev()` may have an adverse effect on throughput.
826
+ *
827
+ * See also: `writable.uncork()`, `writable._writev()`.
828
+ * @since v0.11.2
829
+ */
830
+ cork(): void;
831
+ /**
832
+ * The `writable.uncork()` method flushes all data buffered since {@link cork} was called.
833
+ *
834
+ * When using `writable.cork()` and `writable.uncork()` to manage the buffering
835
+ * of writes to a stream, defer calls to `writable.uncork()` using`process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event
836
+ * loop phase.
837
+ *
838
+ * ```js
839
+ * stream.cork();
840
+ * stream.write('some ');
841
+ * stream.write('data ');
842
+ * process.nextTick(() => stream.uncork());
843
+ * ```
844
+ *
845
+ * If the `writable.cork()` method is called multiple times on a stream, the
846
+ * same number of calls to `writable.uncork()` must be called to flush the buffered
847
+ * data.
848
+ *
849
+ * ```js
850
+ * stream.cork();
851
+ * stream.write('some ');
852
+ * stream.cork();
853
+ * stream.write('data ');
854
+ * process.nextTick(() => {
855
+ * stream.uncork();
856
+ * // The data will not be flushed until uncork() is called a second time.
857
+ * stream.uncork();
858
+ * });
859
+ * ```
860
+ *
861
+ * See also: `writable.cork()`.
862
+ * @since v0.11.2
863
+ */
864
+ uncork(): void;
865
+ /**
866
+ * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the writable
867
+ * stream has ended and subsequent calls to `write()` or `end()` will result in
868
+ * an `ERR_STREAM_DESTROYED` error.
869
+ * This is a destructive and immediate way to destroy a stream. Previous calls to`write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error.
870
+ * Use `end()` instead of destroy if data should flush before close, or wait for
871
+ * the `'drain'` event before destroying the stream.
872
+ *
873
+ * Once `destroy()` has been called any further calls will be a no-op and no
874
+ * further errors except from `_destroy()` may be emitted as `'error'`.
875
+ *
876
+ * Implementors should not override this method,
877
+ * but instead implement `writable._destroy()`.
878
+ * @since v8.0.0
879
+ * @param error Optional, an error to emit with `'error'` event.
880
+ */
881
+ destroy(error?: Error): this;
882
+ /**
883
+ * Event emitter
884
+ * The defined events on documents including:
885
+ * 1. close
886
+ * 2. drain
887
+ * 3. error
888
+ * 4. finish
889
+ * 5. pipe
890
+ * 6. unpipe
891
+ */
892
+ addListener(event: "close", listener: () => void): this;
893
+ addListener(event: "drain", listener: () => void): this;
894
+ addListener(event: "error", listener: (err: Error) => void): this;
895
+ addListener(event: "finish", listener: () => void): this;
896
+ addListener(event: "pipe", listener: (src: Readable) => void): this;
897
+ addListener(event: "unpipe", listener: (src: Readable) => void): this;
898
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
899
+ emit(event: "close"): boolean;
900
+ emit(event: "drain"): boolean;
901
+ emit(event: "error", err: Error): boolean;
902
+ emit(event: "finish"): boolean;
903
+ emit(event: "pipe", src: Readable): boolean;
904
+ emit(event: "unpipe", src: Readable): boolean;
905
+ emit(event: string | symbol, ...args: any[]): boolean;
906
+ on(event: "close", listener: () => void): this;
907
+ on(event: "drain", listener: () => void): this;
908
+ on(event: "error", listener: (err: Error) => void): this;
909
+ on(event: "finish", listener: () => void): this;
910
+ on(event: "pipe", listener: (src: Readable) => void): this;
911
+ on(event: "unpipe", listener: (src: Readable) => void): this;
912
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
913
+ once(event: "close", listener: () => void): this;
914
+ once(event: "drain", listener: () => void): this;
915
+ once(event: "error", listener: (err: Error) => void): this;
916
+ once(event: "finish", listener: () => void): this;
917
+ once(event: "pipe", listener: (src: Readable) => void): this;
918
+ once(event: "unpipe", listener: (src: Readable) => void): this;
919
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
920
+ prependListener(event: "close", listener: () => void): this;
921
+ prependListener(event: "drain", listener: () => void): this;
922
+ prependListener(event: "error", listener: (err: Error) => void): this;
923
+ prependListener(event: "finish", listener: () => void): this;
924
+ prependListener(event: "pipe", listener: (src: Readable) => void): this;
925
+ prependListener(event: "unpipe", listener: (src: Readable) => void): this;
926
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
927
+ prependOnceListener(event: "close", listener: () => void): this;
928
+ prependOnceListener(event: "drain", listener: () => void): this;
929
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
930
+ prependOnceListener(event: "finish", listener: () => void): this;
931
+ prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
932
+ prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
933
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
934
+ removeListener(event: "close", listener: () => void): this;
935
+ removeListener(event: "drain", listener: () => void): this;
936
+ removeListener(event: "error", listener: (err: Error) => void): this;
937
+ removeListener(event: "finish", listener: () => void): this;
938
+ removeListener(event: "pipe", listener: (src: Readable) => void): this;
939
+ removeListener(event: "unpipe", listener: (src: Readable) => void): this;
940
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
941
+ }
942
+ namespace internal {
943
+ class Stream extends internal {
944
+ constructor(opts?: ReadableOptions);
945
+ }
946
+ interface StreamOptions<T extends Stream> extends Abortable {
947
+ emitClose?: boolean | undefined;
948
+ highWaterMark?: number | undefined;
949
+ objectMode?: boolean | undefined;
950
+ construct?(this: T, callback: (error?: Error | null) => void): void;
951
+ destroy?(this: T, error: Error | null, callback: (error?: Error | null) => void): void;
952
+ autoDestroy?: boolean | undefined;
953
+ }
954
+ interface ReadableOptions extends StreamOptions<Readable> {
955
+ encoding?: BufferEncoding | undefined;
956
+ read?(this: Readable, size: number): void;
957
+ }
958
+ /**
959
+ * @since v0.9.4
960
+ */
961
+ class Readable extends ReadableBase {
962
+ /**
963
+ * A utility method for creating a `Readable` from a web `ReadableStream`.
964
+ * @since v17.0.0
965
+ * @experimental
966
+ */
967
+ static fromWeb(
968
+ readableStream: streamWeb.ReadableStream,
969
+ options?: Pick<ReadableOptions, "encoding" | "highWaterMark" | "objectMode" | "signal">,
970
+ ): Readable;
971
+ /**
972
+ * A utility method for creating a web `ReadableStream` from a `Readable`.
973
+ * @since v17.0.0
974
+ * @experimental
975
+ */
976
+ static toWeb(streamReadable: Readable): streamWeb.ReadableStream;
977
+ }
978
+ interface WritableOptions extends StreamOptions<Writable> {
979
+ decodeStrings?: boolean | undefined;
980
+ defaultEncoding?: BufferEncoding | undefined;
981
+ write?(
982
+ this: Writable,
983
+ chunk: any,
984
+ encoding: BufferEncoding,
985
+ callback: (error?: Error | null) => void,
986
+ ): void;
987
+ writev?(
988
+ this: Writable,
989
+ chunks: Array<{
990
+ chunk: any;
991
+ encoding: BufferEncoding;
992
+ }>,
993
+ callback: (error?: Error | null) => void,
994
+ ): void;
995
+ final?(this: Writable, callback: (error?: Error | null) => void): void;
996
+ }
997
+ /**
998
+ * @since v0.9.4
999
+ */
1000
+ class Writable extends WritableBase {
1001
+ /**
1002
+ * A utility method for creating a `Writable` from a web `WritableStream`.
1003
+ * @since v17.0.0
1004
+ * @experimental
1005
+ */
1006
+ static fromWeb(
1007
+ writableStream: streamWeb.WritableStream,
1008
+ options?: Pick<WritableOptions, "decodeStrings" | "highWaterMark" | "objectMode" | "signal">,
1009
+ ): Writable;
1010
+ /**
1011
+ * A utility method for creating a web `WritableStream` from a `Writable`.
1012
+ * @since v17.0.0
1013
+ * @experimental
1014
+ */
1015
+ static toWeb(streamWritable: Writable): streamWeb.WritableStream;
1016
+ }
1017
+ interface DuplexOptions extends ReadableOptions, WritableOptions {
1018
+ allowHalfOpen?: boolean | undefined;
1019
+ readableObjectMode?: boolean | undefined;
1020
+ writableObjectMode?: boolean | undefined;
1021
+ readableHighWaterMark?: number | undefined;
1022
+ writableHighWaterMark?: number | undefined;
1023
+ writableCorked?: number | undefined;
1024
+ construct?(this: Duplex, callback: (error?: Error | null) => void): void;
1025
+ read?(this: Duplex, size: number): void;
1026
+ write?(this: Duplex, chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
1027
+ writev?(
1028
+ this: Duplex,
1029
+ chunks: Array<{
1030
+ chunk: any;
1031
+ encoding: BufferEncoding;
1032
+ }>,
1033
+ callback: (error?: Error | null) => void,
1034
+ ): void;
1035
+ final?(this: Duplex, callback: (error?: Error | null) => void): void;
1036
+ destroy?(this: Duplex, error: Error | null, callback: (error?: Error | null) => void): void;
1037
+ }
1038
+ /**
1039
+ * Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.
1040
+ *
1041
+ * Examples of `Duplex` streams include:
1042
+ *
1043
+ * * `TCP sockets`
1044
+ * * `zlib streams`
1045
+ * * `crypto streams`
1046
+ * @since v0.9.4
1047
+ */
1048
+ class Duplex extends ReadableBase implements WritableBase {
1049
+ readonly writable: boolean;
1050
+ readonly writableEnded: boolean;
1051
+ readonly writableFinished: boolean;
1052
+ readonly writableHighWaterMark: number;
1053
+ readonly writableLength: number;
1054
+ readonly writableObjectMode: boolean;
1055
+ readonly writableCorked: number;
1056
+ readonly writableNeedDrain: boolean;
1057
+ readonly closed: boolean;
1058
+ readonly errored: Error | null;
1059
+ /**
1060
+ * If `false` then the stream will automatically end the writable side when the
1061
+ * readable side ends. Set initially by the `allowHalfOpen` constructor option,
1062
+ * which defaults to `true`.
1063
+ *
1064
+ * This can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is
1065
+ * emitted.
1066
+ * @since v0.9.4
1067
+ */
1068
+ allowHalfOpen: boolean;
1069
+ constructor(opts?: DuplexOptions);
1070
+ /**
1071
+ * A utility method for creating duplex streams.
1072
+ *
1073
+ * - `Stream` converts writable stream into writable `Duplex` and readable stream
1074
+ * to `Duplex`.
1075
+ * - `Blob` converts into readable `Duplex`.
1076
+ * - `string` converts into readable `Duplex`.
1077
+ * - `ArrayBuffer` converts into readable `Duplex`.
1078
+ * - `AsyncIterable` converts into a readable `Duplex`. Cannot yield `null`.
1079
+ * - `AsyncGeneratorFunction` converts into a readable/writable transform
1080
+ * `Duplex`. Must take a source `AsyncIterable` as first parameter. Cannot yield
1081
+ * `null`.
1082
+ * - `AsyncFunction` converts into a writable `Duplex`. Must return
1083
+ * either `null` or `undefined`
1084
+ * - `Object ({ writable, readable })` converts `readable` and
1085
+ * `writable` into `Stream` and then combines them into `Duplex` where the
1086
+ * `Duplex` will write to the `writable` and read from the `readable`.
1087
+ * - `Promise` converts into readable `Duplex`. Value `null` is ignored.
1088
+ *
1089
+ * @since v16.8.0
1090
+ */
1091
+ static from(
1092
+ src:
1093
+ | Stream
1094
+ | NodeBlob
1095
+ | ArrayBuffer
1096
+ | string
1097
+ | Iterable<any>
1098
+ | AsyncIterable<any>
1099
+ | AsyncGeneratorFunction
1100
+ | Promise<any>
1101
+ | Object,
1102
+ ): Duplex;
1103
+ _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
1104
+ _writev?(
1105
+ chunks: Array<{
1106
+ chunk: any;
1107
+ encoding: BufferEncoding;
1108
+ }>,
1109
+ callback: (error?: Error | null) => void,
1110
+ ): void;
1111
+ _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
1112
+ _final(callback: (error?: Error | null) => void): void;
1113
+ write(chunk: any, encoding?: BufferEncoding, cb?: (error: Error | null | undefined) => void): boolean;
1114
+ write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;
1115
+ setDefaultEncoding(encoding: BufferEncoding): this;
1116
+ end(cb?: () => void): this;
1117
+ end(chunk: any, cb?: () => void): this;
1118
+ end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this;
1119
+ cork(): void;
1120
+ uncork(): void;
1121
+ /**
1122
+ * A utility method for creating a web `ReadableStream` and `WritableStream` from a `Duplex`.
1123
+ * @since v17.0.0
1124
+ * @experimental
1125
+ */
1126
+ static toWeb(streamDuplex: Duplex): {
1127
+ readable: streamWeb.ReadableStream;
1128
+ writable: streamWeb.WritableStream;
1129
+ };
1130
+ /**
1131
+ * A utility method for creating a `Duplex` from a web `ReadableStream` and `WritableStream`.
1132
+ * @since v17.0.0
1133
+ * @experimental
1134
+ */
1135
+ static fromWeb(
1136
+ duplexStream: {
1137
+ readable: streamWeb.ReadableStream;
1138
+ writable: streamWeb.WritableStream;
1139
+ },
1140
+ options?: Pick<
1141
+ DuplexOptions,
1142
+ "allowHalfOpen" | "decodeStrings" | "encoding" | "highWaterMark" | "objectMode" | "signal"
1143
+ >,
1144
+ ): Duplex;
1145
+ /**
1146
+ * Event emitter
1147
+ * The defined events on documents including:
1148
+ * 1. close
1149
+ * 2. data
1150
+ * 3. drain
1151
+ * 4. end
1152
+ * 5. error
1153
+ * 6. finish
1154
+ * 7. pause
1155
+ * 8. pipe
1156
+ * 9. readable
1157
+ * 10. resume
1158
+ * 11. unpipe
1159
+ */
1160
+ addListener(event: "close", listener: () => void): this;
1161
+ addListener(event: "data", listener: (chunk: any) => void): this;
1162
+ addListener(event: "drain", listener: () => void): this;
1163
+ addListener(event: "end", listener: () => void): this;
1164
+ addListener(event: "error", listener: (err: Error) => void): this;
1165
+ addListener(event: "finish", listener: () => void): this;
1166
+ addListener(event: "pause", listener: () => void): this;
1167
+ addListener(event: "pipe", listener: (src: Readable) => void): this;
1168
+ addListener(event: "readable", listener: () => void): this;
1169
+ addListener(event: "resume", listener: () => void): this;
1170
+ addListener(event: "unpipe", listener: (src: Readable) => void): this;
1171
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1172
+ emit(event: "close"): boolean;
1173
+ emit(event: "data", chunk: any): boolean;
1174
+ emit(event: "drain"): boolean;
1175
+ emit(event: "end"): boolean;
1176
+ emit(event: "error", err: Error): boolean;
1177
+ emit(event: "finish"): boolean;
1178
+ emit(event: "pause"): boolean;
1179
+ emit(event: "pipe", src: Readable): boolean;
1180
+ emit(event: "readable"): boolean;
1181
+ emit(event: "resume"): boolean;
1182
+ emit(event: "unpipe", src: Readable): boolean;
1183
+ emit(event: string | symbol, ...args: any[]): boolean;
1184
+ on(event: "close", listener: () => void): this;
1185
+ on(event: "data", listener: (chunk: any) => void): this;
1186
+ on(event: "drain", listener: () => void): this;
1187
+ on(event: "end", listener: () => void): this;
1188
+ on(event: "error", listener: (err: Error) => void): this;
1189
+ on(event: "finish", listener: () => void): this;
1190
+ on(event: "pause", listener: () => void): this;
1191
+ on(event: "pipe", listener: (src: Readable) => void): this;
1192
+ on(event: "readable", listener: () => void): this;
1193
+ on(event: "resume", listener: () => void): this;
1194
+ on(event: "unpipe", listener: (src: Readable) => void): this;
1195
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
1196
+ once(event: "close", listener: () => void): this;
1197
+ once(event: "data", listener: (chunk: any) => void): this;
1198
+ once(event: "drain", listener: () => void): this;
1199
+ once(event: "end", listener: () => void): this;
1200
+ once(event: "error", listener: (err: Error) => void): this;
1201
+ once(event: "finish", listener: () => void): this;
1202
+ once(event: "pause", listener: () => void): this;
1203
+ once(event: "pipe", listener: (src: Readable) => void): this;
1204
+ once(event: "readable", listener: () => void): this;
1205
+ once(event: "resume", listener: () => void): this;
1206
+ once(event: "unpipe", listener: (src: Readable) => void): this;
1207
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
1208
+ prependListener(event: "close", listener: () => void): this;
1209
+ prependListener(event: "data", listener: (chunk: any) => void): this;
1210
+ prependListener(event: "drain", listener: () => void): this;
1211
+ prependListener(event: "end", listener: () => void): this;
1212
+ prependListener(event: "error", listener: (err: Error) => void): this;
1213
+ prependListener(event: "finish", listener: () => void): this;
1214
+ prependListener(event: "pause", listener: () => void): this;
1215
+ prependListener(event: "pipe", listener: (src: Readable) => void): this;
1216
+ prependListener(event: "readable", listener: () => void): this;
1217
+ prependListener(event: "resume", listener: () => void): this;
1218
+ prependListener(event: "unpipe", listener: (src: Readable) => void): this;
1219
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1220
+ prependOnceListener(event: "close", listener: () => void): this;
1221
+ prependOnceListener(event: "data", listener: (chunk: any) => void): this;
1222
+ prependOnceListener(event: "drain", listener: () => void): this;
1223
+ prependOnceListener(event: "end", listener: () => void): this;
1224
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
1225
+ prependOnceListener(event: "finish", listener: () => void): this;
1226
+ prependOnceListener(event: "pause", listener: () => void): this;
1227
+ prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
1228
+ prependOnceListener(event: "readable", listener: () => void): this;
1229
+ prependOnceListener(event: "resume", listener: () => void): this;
1230
+ prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
1231
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1232
+ removeListener(event: "close", listener: () => void): this;
1233
+ removeListener(event: "data", listener: (chunk: any) => void): this;
1234
+ removeListener(event: "drain", listener: () => void): this;
1235
+ removeListener(event: "end", listener: () => void): this;
1236
+ removeListener(event: "error", listener: (err: Error) => void): this;
1237
+ removeListener(event: "finish", listener: () => void): this;
1238
+ removeListener(event: "pause", listener: () => void): this;
1239
+ removeListener(event: "pipe", listener: (src: Readable) => void): this;
1240
+ removeListener(event: "readable", listener: () => void): this;
1241
+ removeListener(event: "resume", listener: () => void): this;
1242
+ removeListener(event: "unpipe", listener: (src: Readable) => void): this;
1243
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
1244
+ }
1245
+ type TransformCallback = (error?: Error | null, data?: any) => void;
1246
+ interface TransformOptions extends DuplexOptions {
1247
+ construct?(this: Transform, callback: (error?: Error | null) => void): void;
1248
+ read?(this: Transform, size: number): void;
1249
+ write?(
1250
+ this: Transform,
1251
+ chunk: any,
1252
+ encoding: BufferEncoding,
1253
+ callback: (error?: Error | null) => void,
1254
+ ): void;
1255
+ writev?(
1256
+ this: Transform,
1257
+ chunks: Array<{
1258
+ chunk: any;
1259
+ encoding: BufferEncoding;
1260
+ }>,
1261
+ callback: (error?: Error | null) => void,
1262
+ ): void;
1263
+ final?(this: Transform, callback: (error?: Error | null) => void): void;
1264
+ destroy?(this: Transform, error: Error | null, callback: (error?: Error | null) => void): void;
1265
+ transform?(this: Transform, chunk: any, encoding: BufferEncoding, callback: TransformCallback): void;
1266
+ flush?(this: Transform, callback: TransformCallback): void;
1267
+ }
1268
+ /**
1269
+ * Transform streams are `Duplex` streams where the output is in some way
1270
+ * related to the input. Like all `Duplex` streams, `Transform` streams
1271
+ * implement both the `Readable` and `Writable` interfaces.
1272
+ *
1273
+ * Examples of `Transform` streams include:
1274
+ *
1275
+ * * `zlib streams`
1276
+ * * `crypto streams`
1277
+ * @since v0.9.4
1278
+ */
1279
+ class Transform extends Duplex {
1280
+ constructor(opts?: TransformOptions);
1281
+ _transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void;
1282
+ _flush(callback: TransformCallback): void;
1283
+ }
1284
+ /**
1285
+ * The `stream.PassThrough` class is a trivial implementation of a `Transform` stream that simply passes the input bytes across to the output. Its purpose is
1286
+ * primarily for examples and testing, but there are some use cases where`stream.PassThrough` is useful as a building block for novel sorts of streams.
1287
+ */
1288
+ class PassThrough extends Transform {}
1289
+ /**
1290
+ * A stream to attach a signal to.
1291
+ *
1292
+ * Attaches an AbortSignal to a readable or writeable stream. This lets code
1293
+ * control stream destruction using an `AbortController`.
1294
+ *
1295
+ * Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream, and `controller.error(new
1296
+ * AbortError())` for webstreams.
1297
+ *
1298
+ * ```js
1299
+ * const fs = require('node:fs');
1300
+ *
1301
+ * const controller = new AbortController();
1302
+ * const read = addAbortSignal(
1303
+ * controller.signal,
1304
+ * fs.createReadStream(('object.json')),
1305
+ * );
1306
+ * // Later, abort the operation closing the stream
1307
+ * controller.abort();
1308
+ * ```
1309
+ *
1310
+ * Or using an `AbortSignal` with a readable stream as an async iterable:
1311
+ *
1312
+ * ```js
1313
+ * const controller = new AbortController();
1314
+ * setTimeout(() => controller.abort(), 10_000); // set a timeout
1315
+ * const stream = addAbortSignal(
1316
+ * controller.signal,
1317
+ * fs.createReadStream(('object.json')),
1318
+ * );
1319
+ * (async () => {
1320
+ * try {
1321
+ * for await (const chunk of stream) {
1322
+ * await process(chunk);
1323
+ * }
1324
+ * } catch (e) {
1325
+ * if (e.name === 'AbortError') {
1326
+ * // The operation was cancelled
1327
+ * } else {
1328
+ * throw e;
1329
+ * }
1330
+ * }
1331
+ * })();
1332
+ * ```
1333
+ *
1334
+ * Or using an `AbortSignal` with a ReadableStream:
1335
+ *
1336
+ * ```js
1337
+ * const controller = new AbortController();
1338
+ * const rs = new ReadableStream({
1339
+ * start(controller) {
1340
+ * controller.enqueue('hello');
1341
+ * controller.enqueue('world');
1342
+ * controller.close();
1343
+ * },
1344
+ * });
1345
+ *
1346
+ * addAbortSignal(controller.signal, rs);
1347
+ *
1348
+ * finished(rs, (err) => {
1349
+ * if (err) {
1350
+ * if (err.name === 'AbortError') {
1351
+ * // The operation was cancelled
1352
+ * }
1353
+ * }
1354
+ * });
1355
+ *
1356
+ * const reader = rs.getReader();
1357
+ *
1358
+ * reader.read().then(({ value, done }) => {
1359
+ * console.log(value); // hello
1360
+ * console.log(done); // false
1361
+ * controller.abort();
1362
+ * });
1363
+ * ```
1364
+ * @since v15.4.0
1365
+ * @param signal A signal representing possible cancellation
1366
+ * @param stream a stream to attach a signal to
1367
+ */
1368
+ function addAbortSignal<T extends Stream>(signal: AbortSignal, stream: T): T;
1369
+ /**
1370
+ * Returns the default highWaterMark used by streams.
1371
+ * Defaults to `16384` (16 KiB), or `16` for `objectMode`.
1372
+ * @since v19.9.0
1373
+ * @param objectMode
1374
+ */
1375
+ function getDefaultHighWaterMark(objectMode: boolean): number;
1376
+ /**
1377
+ * Sets the default highWaterMark used by streams.
1378
+ * @since v19.9.0
1379
+ * @param objectMode
1380
+ * @param value highWaterMark value
1381
+ */
1382
+ function setDefaultHighWaterMark(objectMode: boolean, value: number): void;
1383
+ interface FinishedOptions extends Abortable {
1384
+ error?: boolean | undefined;
1385
+ readable?: boolean | undefined;
1386
+ writable?: boolean | undefined;
1387
+ }
1388
+ /**
1389
+ * A readable and/or writable stream/webstream.
1390
+ *
1391
+ * A function to get notified when a stream is no longer readable, writable
1392
+ * or has experienced an error or a premature close event.
1393
+ *
1394
+ * ```js
1395
+ * const { finished } = require('node:stream');
1396
+ * const fs = require('node:fs');
1397
+ *
1398
+ * const rs = fs.createReadStream('archive.tar');
1399
+ *
1400
+ * finished(rs, (err) => {
1401
+ * if (err) {
1402
+ * console.error('Stream failed.', err);
1403
+ * } else {
1404
+ * console.log('Stream is done reading.');
1405
+ * }
1406
+ * });
1407
+ *
1408
+ * rs.resume(); // Drain the stream.
1409
+ * ```
1410
+ *
1411
+ * Especially useful in error handling scenarios where a stream is destroyed
1412
+ * prematurely (like an aborted HTTP request), and will not emit `'end'`or `'finish'`.
1413
+ *
1414
+ * The `finished` API provides `promise version`.
1415
+ *
1416
+ * `stream.finished()` leaves dangling event listeners (in particular`'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been
1417
+ * invoked. The reason for this is so that unexpected `'error'` events (due to
1418
+ * incorrect stream implementations) do not cause unexpected crashes.
1419
+ * If this is unwanted behavior then the returned cleanup function needs to be
1420
+ * invoked in the callback:
1421
+ *
1422
+ * ```js
1423
+ * const cleanup = finished(rs, (err) => {
1424
+ * cleanup();
1425
+ * // ...
1426
+ * });
1427
+ * ```
1428
+ * @since v10.0.0
1429
+ * @param stream A readable and/or writable stream.
1430
+ * @param callback A callback function that takes an optional error argument.
1431
+ * @return A cleanup function which removes all registered listeners.
1432
+ */
1433
+ function finished(
1434
+ stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream,
1435
+ options: FinishedOptions,
1436
+ callback: (err?: NodeJS.ErrnoException | null) => void,
1437
+ ): () => void;
1438
+ function finished(
1439
+ stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream,
1440
+ callback: (err?: NodeJS.ErrnoException | null) => void,
1441
+ ): () => void;
1442
+ namespace finished {
1443
+ function __promisify__(
1444
+ stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream,
1445
+ options?: FinishedOptions,
1446
+ ): Promise<void>;
1447
+ }
1448
+ type PipelineSourceFunction<T> = () => Iterable<T> | AsyncIterable<T>;
1449
+ type PipelineSource<T> = Iterable<T> | AsyncIterable<T> | NodeJS.ReadableStream | PipelineSourceFunction<T>;
1450
+ type PipelineTransform<S extends PipelineTransformSource<any>, U> =
1451
+ | NodeJS.ReadWriteStream
1452
+ | ((
1453
+ source: S extends (...args: any[]) => Iterable<infer ST> | AsyncIterable<infer ST> ? AsyncIterable<ST>
1454
+ : S,
1455
+ ) => AsyncIterable<U>);
1456
+ type PipelineTransformSource<T> = PipelineSource<T> | PipelineTransform<any, T>;
1457
+ type PipelineDestinationIterableFunction<T> = (source: AsyncIterable<T>) => AsyncIterable<any>;
1458
+ type PipelineDestinationPromiseFunction<T, P> = (source: AsyncIterable<T>) => Promise<P>;
1459
+ type PipelineDestination<S extends PipelineTransformSource<any>, P> = S extends
1460
+ PipelineTransformSource<infer ST> ?
1461
+ | NodeJS.WritableStream
1462
+ | PipelineDestinationIterableFunction<ST>
1463
+ | PipelineDestinationPromiseFunction<ST, P>
1464
+ : never;
1465
+ type PipelineCallback<S extends PipelineDestination<any, any>> = S extends
1466
+ PipelineDestinationPromiseFunction<any, infer P> ? (err: NodeJS.ErrnoException | null, value: P) => void
1467
+ : (err: NodeJS.ErrnoException | null) => void;
1468
+ type PipelinePromise<S extends PipelineDestination<any, any>> = S extends
1469
+ PipelineDestinationPromiseFunction<any, infer P> ? Promise<P> : Promise<void>;
1470
+ interface PipelineOptions {
1471
+ signal?: AbortSignal | undefined;
1472
+ end?: boolean | undefined;
1473
+ }
1474
+ /**
1475
+ * A module method to pipe between streams and generators forwarding errors and
1476
+ * properly cleaning up and provide a callback when the pipeline is complete.
1477
+ *
1478
+ * ```js
1479
+ * const { pipeline } = require('node:stream');
1480
+ * const fs = require('node:fs');
1481
+ * const zlib = require('node:zlib');
1482
+ *
1483
+ * // Use the pipeline API to easily pipe a series of streams
1484
+ * // together and get notified when the pipeline is fully done.
1485
+ *
1486
+ * // A pipeline to gzip a potentially huge tar file efficiently:
1487
+ *
1488
+ * pipeline(
1489
+ * fs.createReadStream('archive.tar'),
1490
+ * zlib.createGzip(),
1491
+ * fs.createWriteStream('archive.tar.gz'),
1492
+ * (err) => {
1493
+ * if (err) {
1494
+ * console.error('Pipeline failed.', err);
1495
+ * } else {
1496
+ * console.log('Pipeline succeeded.');
1497
+ * }
1498
+ * },
1499
+ * );
1500
+ * ```
1501
+ *
1502
+ * The `pipeline` API provides a `promise version`.
1503
+ *
1504
+ * `stream.pipeline()` will call `stream.destroy(err)` on all streams except:
1505
+ *
1506
+ * * `Readable` streams which have emitted `'end'` or `'close'`.
1507
+ * * `Writable` streams which have emitted `'finish'` or `'close'`.
1508
+ *
1509
+ * `stream.pipeline()` leaves dangling event listeners on the streams
1510
+ * after the `callback` has been invoked. In the case of reuse of streams after
1511
+ * failure, this can cause event listener leaks and swallowed errors. If the last
1512
+ * stream is readable, dangling event listeners will be removed so that the last
1513
+ * stream can be consumed later.
1514
+ *
1515
+ * `stream.pipeline()` closes all the streams when an error is raised.
1516
+ * The `IncomingRequest` usage with `pipeline` could lead to an unexpected behavior
1517
+ * once it would destroy the socket without sending the expected response.
1518
+ * See the example below:
1519
+ *
1520
+ * ```js
1521
+ * const fs = require('node:fs');
1522
+ * const http = require('node:http');
1523
+ * const { pipeline } = require('node:stream');
1524
+ *
1525
+ * const server = http.createServer((req, res) => {
1526
+ * const fileStream = fs.createReadStream('./fileNotExist.txt');
1527
+ * pipeline(fileStream, res, (err) => {
1528
+ * if (err) {
1529
+ * console.log(err); // No such file
1530
+ * // this message can't be sent once `pipeline` already destroyed the socket
1531
+ * return res.end('error!!!');
1532
+ * }
1533
+ * });
1534
+ * });
1535
+ * ```
1536
+ * @since v10.0.0
1537
+ * @param callback Called when the pipeline is fully done.
1538
+ */
1539
+ function pipeline<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(
1540
+ source: A,
1541
+ destination: B,
1542
+ callback?: PipelineCallback<B>,
1543
+ ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1544
+ function pipeline<
1545
+ A extends PipelineSource<any>,
1546
+ T1 extends PipelineTransform<A, any>,
1547
+ B extends PipelineDestination<T1, any>,
1548
+ >(
1549
+ source: A,
1550
+ transform1: T1,
1551
+ destination: B,
1552
+ callback?: PipelineCallback<B>,
1553
+ ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1554
+ function pipeline<
1555
+ A extends PipelineSource<any>,
1556
+ T1 extends PipelineTransform<A, any>,
1557
+ T2 extends PipelineTransform<T1, any>,
1558
+ B extends PipelineDestination<T2, any>,
1559
+ >(
1560
+ source: A,
1561
+ transform1: T1,
1562
+ transform2: T2,
1563
+ destination: B,
1564
+ callback?: PipelineCallback<B>,
1565
+ ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1566
+ function pipeline<
1567
+ A extends PipelineSource<any>,
1568
+ T1 extends PipelineTransform<A, any>,
1569
+ T2 extends PipelineTransform<T1, any>,
1570
+ T3 extends PipelineTransform<T2, any>,
1571
+ B extends PipelineDestination<T3, any>,
1572
+ >(
1573
+ source: A,
1574
+ transform1: T1,
1575
+ transform2: T2,
1576
+ transform3: T3,
1577
+ destination: B,
1578
+ callback?: PipelineCallback<B>,
1579
+ ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1580
+ function pipeline<
1581
+ A extends PipelineSource<any>,
1582
+ T1 extends PipelineTransform<A, any>,
1583
+ T2 extends PipelineTransform<T1, any>,
1584
+ T3 extends PipelineTransform<T2, any>,
1585
+ T4 extends PipelineTransform<T3, any>,
1586
+ B extends PipelineDestination<T4, any>,
1587
+ >(
1588
+ source: A,
1589
+ transform1: T1,
1590
+ transform2: T2,
1591
+ transform3: T3,
1592
+ transform4: T4,
1593
+ destination: B,
1594
+ callback?: PipelineCallback<B>,
1595
+ ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1596
+ function pipeline(
1597
+ streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
1598
+ callback?: (err: NodeJS.ErrnoException | null) => void,
1599
+ ): NodeJS.WritableStream;
1600
+ function pipeline(
1601
+ stream1: NodeJS.ReadableStream,
1602
+ stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
1603
+ ...streams: Array<
1604
+ NodeJS.ReadWriteStream | NodeJS.WritableStream | ((err: NodeJS.ErrnoException | null) => void)
1605
+ >
1606
+ ): NodeJS.WritableStream;
1607
+ namespace pipeline {
1608
+ function __promisify__<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(
1609
+ source: A,
1610
+ destination: B,
1611
+ options?: PipelineOptions,
1612
+ ): PipelinePromise<B>;
1613
+ function __promisify__<
1614
+ A extends PipelineSource<any>,
1615
+ T1 extends PipelineTransform<A, any>,
1616
+ B extends PipelineDestination<T1, any>,
1617
+ >(
1618
+ source: A,
1619
+ transform1: T1,
1620
+ destination: B,
1621
+ options?: PipelineOptions,
1622
+ ): PipelinePromise<B>;
1623
+ function __promisify__<
1624
+ A extends PipelineSource<any>,
1625
+ T1 extends PipelineTransform<A, any>,
1626
+ T2 extends PipelineTransform<T1, any>,
1627
+ B extends PipelineDestination<T2, any>,
1628
+ >(
1629
+ source: A,
1630
+ transform1: T1,
1631
+ transform2: T2,
1632
+ destination: B,
1633
+ options?: PipelineOptions,
1634
+ ): PipelinePromise<B>;
1635
+ function __promisify__<
1636
+ A extends PipelineSource<any>,
1637
+ T1 extends PipelineTransform<A, any>,
1638
+ T2 extends PipelineTransform<T1, any>,
1639
+ T3 extends PipelineTransform<T2, any>,
1640
+ B extends PipelineDestination<T3, any>,
1641
+ >(
1642
+ source: A,
1643
+ transform1: T1,
1644
+ transform2: T2,
1645
+ transform3: T3,
1646
+ destination: B,
1647
+ options?: PipelineOptions,
1648
+ ): PipelinePromise<B>;
1649
+ function __promisify__<
1650
+ A extends PipelineSource<any>,
1651
+ T1 extends PipelineTransform<A, any>,
1652
+ T2 extends PipelineTransform<T1, any>,
1653
+ T3 extends PipelineTransform<T2, any>,
1654
+ T4 extends PipelineTransform<T3, any>,
1655
+ B extends PipelineDestination<T4, any>,
1656
+ >(
1657
+ source: A,
1658
+ transform1: T1,
1659
+ transform2: T2,
1660
+ transform3: T3,
1661
+ transform4: T4,
1662
+ destination: B,
1663
+ options?: PipelineOptions,
1664
+ ): PipelinePromise<B>;
1665
+ function __promisify__(
1666
+ streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
1667
+ options?: PipelineOptions,
1668
+ ): Promise<void>;
1669
+ function __promisify__(
1670
+ stream1: NodeJS.ReadableStream,
1671
+ stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
1672
+ ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
1673
+ ): Promise<void>;
1674
+ }
1675
+ interface Pipe {
1676
+ close(): void;
1677
+ hasRef(): boolean;
1678
+ ref(): void;
1679
+ unref(): void;
1680
+ }
1681
+ /**
1682
+ * Returns whether the stream has encountered an error.
1683
+ * @since v17.3.0, v16.14.0
1684
+ * @experimental
1685
+ */
1686
+ function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
1687
+ /**
1688
+ * Returns whether the stream is readable.
1689
+ * @since v17.4.0, v16.14.0
1690
+ * @experimental
1691
+ */
1692
+ function isReadable(stream: Readable | NodeJS.ReadableStream): boolean;
1693
+ const promises: typeof streamPromises;
1694
+ const consumers: typeof streamConsumers;
1695
+ }
1696
+ export = internal;
1697
+ }
1698
+ declare module "node:stream" {
1699
+ import stream = require("stream");
1700
+ export = stream;
1701
+ }