css-variable-lsp 1.0.0 → 1.0.1

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