coupeeeez 0.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 (881) hide show
  1. package/LICENSE.MD +7 -0
  2. package/command +18 -0
  3. package/makeApp.ts +17 -0
  4. package/package.json +41 -0
  5. package/stream-api/Message.ts +6 -0
  6. package/stream-api/SSEInjected.ts +3 -0
  7. package/stream-api/SSEServer.ts +37 -0
  8. package/stream-api/SSEServers.ts +36 -0
  9. package/stream-api/StreamApi.ts +39 -0
  10. package/stream-api/app.ts +14 -0
  11. package/stream-api/index.ts +1 -0
  12. package/stream-api/node_modules/.package-lock.json +971 -0
  13. package/stream-api/node_modules/@types/body-parser/LICENSE +21 -0
  14. package/stream-api/node_modules/@types/body-parser/README.md +15 -0
  15. package/stream-api/node_modules/@types/body-parser/index.d.ts +95 -0
  16. package/stream-api/node_modules/@types/body-parser/package.json +64 -0
  17. package/stream-api/node_modules/@types/connect/LICENSE +21 -0
  18. package/stream-api/node_modules/@types/connect/README.md +15 -0
  19. package/stream-api/node_modules/@types/connect/index.d.ts +91 -0
  20. package/stream-api/node_modules/@types/connect/package.json +32 -0
  21. package/stream-api/node_modules/@types/express/LICENSE +21 -0
  22. package/stream-api/node_modules/@types/express/README.md +15 -0
  23. package/stream-api/node_modules/@types/express/index.d.ts +122 -0
  24. package/stream-api/node_modules/@types/express/package.json +45 -0
  25. package/stream-api/node_modules/@types/express-serve-static-core/LICENSE +21 -0
  26. package/stream-api/node_modules/@types/express-serve-static-core/README.md +15 -0
  27. package/stream-api/node_modules/@types/express-serve-static-core/index.d.ts +1244 -0
  28. package/stream-api/node_modules/@types/express-serve-static-core/package.json +51 -0
  29. package/stream-api/node_modules/@types/http-errors/LICENSE +21 -0
  30. package/stream-api/node_modules/@types/http-errors/README.md +15 -0
  31. package/stream-api/node_modules/@types/http-errors/index.d.ts +77 -0
  32. package/stream-api/node_modules/@types/http-errors/package.json +36 -0
  33. package/stream-api/node_modules/@types/mime/LICENSE +21 -0
  34. package/stream-api/node_modules/@types/mime/Mime.d.ts +10 -0
  35. package/stream-api/node_modules/@types/mime/README.md +15 -0
  36. package/stream-api/node_modules/@types/mime/index.d.ts +31 -0
  37. package/stream-api/node_modules/@types/mime/lite.d.ts +7 -0
  38. package/stream-api/node_modules/@types/mime/package.json +30 -0
  39. package/stream-api/node_modules/@types/node/LICENSE +21 -0
  40. package/stream-api/node_modules/@types/node/README.md +15 -0
  41. package/stream-api/node_modules/@types/node/assert/strict.d.ts +111 -0
  42. package/stream-api/node_modules/@types/node/assert.d.ts +1115 -0
  43. package/stream-api/node_modules/@types/node/async_hooks.d.ts +623 -0
  44. package/stream-api/node_modules/@types/node/buffer.buffer.d.ts +472 -0
  45. package/stream-api/node_modules/@types/node/buffer.d.ts +1934 -0
  46. package/stream-api/node_modules/@types/node/child_process.d.ts +1476 -0
  47. package/stream-api/node_modules/@types/node/cluster.d.ts +578 -0
  48. package/stream-api/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  49. package/stream-api/node_modules/@types/node/console.d.ts +453 -0
  50. package/stream-api/node_modules/@types/node/constants.d.ts +21 -0
  51. package/stream-api/node_modules/@types/node/crypto.d.ts +5417 -0
  52. package/stream-api/node_modules/@types/node/dgram.d.ts +600 -0
  53. package/stream-api/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
  54. package/stream-api/node_modules/@types/node/dns/promises.d.ts +503 -0
  55. package/stream-api/node_modules/@types/node/dns.d.ts +923 -0
  56. package/stream-api/node_modules/@types/node/domain.d.ts +170 -0
  57. package/stream-api/node_modules/@types/node/events.d.ts +976 -0
  58. package/stream-api/node_modules/@types/node/fs/promises.d.ts +1317 -0
  59. package/stream-api/node_modules/@types/node/fs.d.ts +4714 -0
  60. package/stream-api/node_modules/@types/node/globals.d.ts +170 -0
  61. package/stream-api/node_modules/@types/node/globals.typedarray.d.ts +41 -0
  62. package/stream-api/node_modules/@types/node/http.d.ts +2134 -0
  63. package/stream-api/node_modules/@types/node/http2.d.ts +2756 -0
  64. package/stream-api/node_modules/@types/node/https.d.ts +579 -0
  65. package/stream-api/node_modules/@types/node/index.d.ts +101 -0
  66. package/stream-api/node_modules/@types/node/inspector.d.ts +277 -0
  67. package/stream-api/node_modules/@types/node/inspector.generated.d.ts +4233 -0
  68. package/stream-api/node_modules/@types/node/module.d.ts +894 -0
  69. package/stream-api/node_modules/@types/node/net.d.ts +1054 -0
  70. package/stream-api/node_modules/@types/node/os.d.ts +507 -0
  71. package/stream-api/node_modules/@types/node/package.json +155 -0
  72. package/stream-api/node_modules/@types/node/path.d.ts +200 -0
  73. package/stream-api/node_modules/@types/node/perf_hooks.d.ts +982 -0
  74. package/stream-api/node_modules/@types/node/process.d.ts +2069 -0
  75. package/stream-api/node_modules/@types/node/punycode.d.ts +117 -0
  76. package/stream-api/node_modules/@types/node/querystring.d.ts +152 -0
  77. package/stream-api/node_modules/@types/node/readline/promises.d.ts +161 -0
  78. package/stream-api/node_modules/@types/node/readline.d.ts +594 -0
  79. package/stream-api/node_modules/@types/node/repl.d.ts +438 -0
  80. package/stream-api/node_modules/@types/node/sea.d.ts +162 -0
  81. package/stream-api/node_modules/@types/node/sqlite.d.ts +937 -0
  82. package/stream-api/node_modules/@types/node/stream/consumers.d.ts +38 -0
  83. package/stream-api/node_modules/@types/node/stream/promises.d.ts +90 -0
  84. package/stream-api/node_modules/@types/node/stream/web.d.ts +573 -0
  85. package/stream-api/node_modules/@types/node/stream.d.ts +1683 -0
  86. package/stream-api/node_modules/@types/node/string_decoder.d.ts +67 -0
  87. package/stream-api/node_modules/@types/node/test.d.ts +2339 -0
  88. package/stream-api/node_modules/@types/node/timers/promises.d.ts +108 -0
  89. package/stream-api/node_modules/@types/node/timers.d.ts +285 -0
  90. package/stream-api/node_modules/@types/node/tls.d.ts +1269 -0
  91. package/stream-api/node_modules/@types/node/trace_events.d.ts +197 -0
  92. package/stream-api/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  93. package/stream-api/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  94. package/stream-api/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  95. package/stream-api/node_modules/@types/node/ts5.6/index.d.ts +103 -0
  96. package/stream-api/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  97. package/stream-api/node_modules/@types/node/ts5.7/index.d.ts +103 -0
  98. package/stream-api/node_modules/@types/node/tty.d.ts +208 -0
  99. package/stream-api/node_modules/@types/node/url.d.ts +1057 -0
  100. package/stream-api/node_modules/@types/node/util.d.ts +2325 -0
  101. package/stream-api/node_modules/@types/node/v8.d.ts +952 -0
  102. package/stream-api/node_modules/@types/node/vm.d.ts +1180 -0
  103. package/stream-api/node_modules/@types/node/wasi.d.ts +202 -0
  104. package/stream-api/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  105. package/stream-api/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  106. package/stream-api/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  107. package/stream-api/node_modules/@types/node/web-globals/events.d.ts +97 -0
  108. package/stream-api/node_modules/@types/node/web-globals/fetch.d.ts +50 -0
  109. package/stream-api/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  110. package/stream-api/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  111. package/stream-api/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  112. package/stream-api/node_modules/@types/node/worker_threads.d.ts +896 -0
  113. package/stream-api/node_modules/@types/node/zlib.d.ts +681 -0
  114. package/stream-api/node_modules/@types/qs/LICENSE +21 -0
  115. package/stream-api/node_modules/@types/qs/README.md +15 -0
  116. package/stream-api/node_modules/@types/qs/index.d.ts +82 -0
  117. package/stream-api/node_modules/@types/qs/package.json +66 -0
  118. package/stream-api/node_modules/@types/range-parser/LICENSE +21 -0
  119. package/stream-api/node_modules/@types/range-parser/README.md +53 -0
  120. package/stream-api/node_modules/@types/range-parser/index.d.ts +34 -0
  121. package/stream-api/node_modules/@types/range-parser/package.json +25 -0
  122. package/stream-api/node_modules/@types/send/LICENSE +21 -0
  123. package/stream-api/node_modules/@types/send/README.md +15 -0
  124. package/stream-api/node_modules/@types/send/index.d.ts +187 -0
  125. package/stream-api/node_modules/@types/send/package.json +38 -0
  126. package/stream-api/node_modules/@types/serve-static/LICENSE +21 -0
  127. package/stream-api/node_modules/@types/serve-static/README.md +15 -0
  128. package/stream-api/node_modules/@types/serve-static/index.d.ts +107 -0
  129. package/stream-api/node_modules/@types/serve-static/node_modules/@types/send/LICENSE +21 -0
  130. package/stream-api/node_modules/@types/serve-static/node_modules/@types/send/README.md +15 -0
  131. package/stream-api/node_modules/@types/serve-static/node_modules/@types/send/index.d.ts +225 -0
  132. package/stream-api/node_modules/@types/serve-static/node_modules/@types/send/package.json +39 -0
  133. package/stream-api/node_modules/@types/serve-static/package.json +45 -0
  134. package/stream-api/node_modules/accepts/HISTORY.md +250 -0
  135. package/stream-api/node_modules/accepts/LICENSE +23 -0
  136. package/stream-api/node_modules/accepts/README.md +140 -0
  137. package/stream-api/node_modules/accepts/index.js +238 -0
  138. package/stream-api/node_modules/accepts/package.json +47 -0
  139. package/stream-api/node_modules/any-base/LICENSE +21 -0
  140. package/stream-api/node_modules/any-base/README.md +55 -0
  141. package/stream-api/node_modules/any-base/dist/any-base.js +94 -0
  142. package/stream-api/node_modules/any-base/dist/any-base.min.js +1 -0
  143. package/stream-api/node_modules/any-base/index.js +30 -0
  144. package/stream-api/node_modules/any-base/package.json +40 -0
  145. package/stream-api/node_modules/any-base/src/converter.js +80 -0
  146. package/stream-api/node_modules/body-parser/LICENSE +23 -0
  147. package/stream-api/node_modules/body-parser/README.md +494 -0
  148. package/stream-api/node_modules/body-parser/index.js +80 -0
  149. package/stream-api/node_modules/body-parser/lib/read.js +250 -0
  150. package/stream-api/node_modules/body-parser/lib/types/json.js +166 -0
  151. package/stream-api/node_modules/body-parser/lib/types/raw.js +43 -0
  152. package/stream-api/node_modules/body-parser/lib/types/text.js +37 -0
  153. package/stream-api/node_modules/body-parser/lib/types/urlencoded.js +142 -0
  154. package/stream-api/node_modules/body-parser/lib/utils.js +96 -0
  155. package/stream-api/node_modules/body-parser/package.json +52 -0
  156. package/stream-api/node_modules/bytes/History.md +97 -0
  157. package/stream-api/node_modules/bytes/LICENSE +23 -0
  158. package/stream-api/node_modules/bytes/Readme.md +152 -0
  159. package/stream-api/node_modules/bytes/index.js +170 -0
  160. package/stream-api/node_modules/bytes/package.json +42 -0
  161. package/stream-api/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
  162. package/stream-api/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
  163. package/stream-api/node_modules/call-bind-apply-helpers/.nycrc +9 -0
  164. package/stream-api/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
  165. package/stream-api/node_modules/call-bind-apply-helpers/LICENSE +21 -0
  166. package/stream-api/node_modules/call-bind-apply-helpers/README.md +62 -0
  167. package/stream-api/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
  168. package/stream-api/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
  169. package/stream-api/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
  170. package/stream-api/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
  171. package/stream-api/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
  172. package/stream-api/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
  173. package/stream-api/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
  174. package/stream-api/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
  175. package/stream-api/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
  176. package/stream-api/node_modules/call-bind-apply-helpers/index.js +15 -0
  177. package/stream-api/node_modules/call-bind-apply-helpers/package.json +85 -0
  178. package/stream-api/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
  179. package/stream-api/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
  180. package/stream-api/node_modules/call-bind-apply-helpers/test/index.js +63 -0
  181. package/stream-api/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
  182. package/stream-api/node_modules/call-bound/.eslintrc +13 -0
  183. package/stream-api/node_modules/call-bound/.github/FUNDING.yml +12 -0
  184. package/stream-api/node_modules/call-bound/.nycrc +9 -0
  185. package/stream-api/node_modules/call-bound/CHANGELOG.md +42 -0
  186. package/stream-api/node_modules/call-bound/LICENSE +21 -0
  187. package/stream-api/node_modules/call-bound/README.md +53 -0
  188. package/stream-api/node_modules/call-bound/index.d.ts +94 -0
  189. package/stream-api/node_modules/call-bound/index.js +19 -0
  190. package/stream-api/node_modules/call-bound/package.json +99 -0
  191. package/stream-api/node_modules/call-bound/test/index.js +61 -0
  192. package/stream-api/node_modules/call-bound/tsconfig.json +10 -0
  193. package/stream-api/node_modules/commander/LICENSE +22 -0
  194. package/stream-api/node_modules/commander/Readme.md +1159 -0
  195. package/stream-api/node_modules/commander/esm.mjs +16 -0
  196. package/stream-api/node_modules/commander/index.js +24 -0
  197. package/stream-api/node_modules/commander/lib/argument.js +150 -0
  198. package/stream-api/node_modules/commander/lib/command.js +2777 -0
  199. package/stream-api/node_modules/commander/lib/error.js +39 -0
  200. package/stream-api/node_modules/commander/lib/help.js +747 -0
  201. package/stream-api/node_modules/commander/lib/option.js +380 -0
  202. package/stream-api/node_modules/commander/lib/suggestSimilar.js +101 -0
  203. package/stream-api/node_modules/commander/package-support.json +16 -0
  204. package/stream-api/node_modules/commander/package.json +82 -0
  205. package/stream-api/node_modules/commander/typings/esm.d.mts +3 -0
  206. package/stream-api/node_modules/commander/typings/index.d.ts +1113 -0
  207. package/stream-api/node_modules/content-disposition/HISTORY.md +72 -0
  208. package/stream-api/node_modules/content-disposition/LICENSE +22 -0
  209. package/stream-api/node_modules/content-disposition/README.md +142 -0
  210. package/stream-api/node_modules/content-disposition/index.js +458 -0
  211. package/stream-api/node_modules/content-disposition/package.json +43 -0
  212. package/stream-api/node_modules/content-type/HISTORY.md +29 -0
  213. package/stream-api/node_modules/content-type/LICENSE +22 -0
  214. package/stream-api/node_modules/content-type/README.md +94 -0
  215. package/stream-api/node_modules/content-type/index.js +225 -0
  216. package/stream-api/node_modules/content-type/package.json +42 -0
  217. package/stream-api/node_modules/cookie/LICENSE +24 -0
  218. package/stream-api/node_modules/cookie/README.md +317 -0
  219. package/stream-api/node_modules/cookie/SECURITY.md +25 -0
  220. package/stream-api/node_modules/cookie/index.js +335 -0
  221. package/stream-api/node_modules/cookie/package.json +44 -0
  222. package/stream-api/node_modules/cookie-signature/History.md +70 -0
  223. package/stream-api/node_modules/cookie-signature/LICENSE +22 -0
  224. package/stream-api/node_modules/cookie-signature/Readme.md +23 -0
  225. package/stream-api/node_modules/cookie-signature/index.js +47 -0
  226. package/stream-api/node_modules/cookie-signature/package.json +24 -0
  227. package/stream-api/node_modules/debug/LICENSE +20 -0
  228. package/stream-api/node_modules/debug/README.md +481 -0
  229. package/stream-api/node_modules/debug/package.json +64 -0
  230. package/stream-api/node_modules/debug/src/browser.js +272 -0
  231. package/stream-api/node_modules/debug/src/common.js +292 -0
  232. package/stream-api/node_modules/debug/src/index.js +10 -0
  233. package/stream-api/node_modules/debug/src/node.js +263 -0
  234. package/stream-api/node_modules/depd/History.md +103 -0
  235. package/stream-api/node_modules/depd/LICENSE +22 -0
  236. package/stream-api/node_modules/depd/Readme.md +280 -0
  237. package/stream-api/node_modules/depd/index.js +538 -0
  238. package/stream-api/node_modules/depd/lib/browser/index.js +77 -0
  239. package/stream-api/node_modules/depd/package.json +45 -0
  240. package/stream-api/node_modules/dunder-proto/.eslintrc +5 -0
  241. package/stream-api/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
  242. package/stream-api/node_modules/dunder-proto/.nycrc +13 -0
  243. package/stream-api/node_modules/dunder-proto/CHANGELOG.md +24 -0
  244. package/stream-api/node_modules/dunder-proto/LICENSE +21 -0
  245. package/stream-api/node_modules/dunder-proto/README.md +54 -0
  246. package/stream-api/node_modules/dunder-proto/get.d.ts +5 -0
  247. package/stream-api/node_modules/dunder-proto/get.js +30 -0
  248. package/stream-api/node_modules/dunder-proto/package.json +76 -0
  249. package/stream-api/node_modules/dunder-proto/set.d.ts +5 -0
  250. package/stream-api/node_modules/dunder-proto/set.js +35 -0
  251. package/stream-api/node_modules/dunder-proto/test/get.js +34 -0
  252. package/stream-api/node_modules/dunder-proto/test/index.js +4 -0
  253. package/stream-api/node_modules/dunder-proto/test/set.js +50 -0
  254. package/stream-api/node_modules/dunder-proto/tsconfig.json +9 -0
  255. package/stream-api/node_modules/ee-first/LICENSE +22 -0
  256. package/stream-api/node_modules/ee-first/README.md +80 -0
  257. package/stream-api/node_modules/ee-first/index.js +95 -0
  258. package/stream-api/node_modules/ee-first/package.json +29 -0
  259. package/stream-api/node_modules/encodeurl/LICENSE +22 -0
  260. package/stream-api/node_modules/encodeurl/README.md +109 -0
  261. package/stream-api/node_modules/encodeurl/index.js +60 -0
  262. package/stream-api/node_modules/encodeurl/package.json +40 -0
  263. package/stream-api/node_modules/es-define-property/.eslintrc +13 -0
  264. package/stream-api/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  265. package/stream-api/node_modules/es-define-property/.nycrc +9 -0
  266. package/stream-api/node_modules/es-define-property/CHANGELOG.md +29 -0
  267. package/stream-api/node_modules/es-define-property/LICENSE +21 -0
  268. package/stream-api/node_modules/es-define-property/README.md +49 -0
  269. package/stream-api/node_modules/es-define-property/index.d.ts +3 -0
  270. package/stream-api/node_modules/es-define-property/index.js +14 -0
  271. package/stream-api/node_modules/es-define-property/package.json +81 -0
  272. package/stream-api/node_modules/es-define-property/test/index.js +56 -0
  273. package/stream-api/node_modules/es-define-property/tsconfig.json +10 -0
  274. package/stream-api/node_modules/es-errors/.eslintrc +5 -0
  275. package/stream-api/node_modules/es-errors/.github/FUNDING.yml +12 -0
  276. package/stream-api/node_modules/es-errors/CHANGELOG.md +40 -0
  277. package/stream-api/node_modules/es-errors/LICENSE +21 -0
  278. package/stream-api/node_modules/es-errors/README.md +55 -0
  279. package/stream-api/node_modules/es-errors/eval.d.ts +3 -0
  280. package/stream-api/node_modules/es-errors/eval.js +4 -0
  281. package/stream-api/node_modules/es-errors/index.d.ts +3 -0
  282. package/stream-api/node_modules/es-errors/index.js +4 -0
  283. package/stream-api/node_modules/es-errors/package.json +80 -0
  284. package/stream-api/node_modules/es-errors/range.d.ts +3 -0
  285. package/stream-api/node_modules/es-errors/range.js +4 -0
  286. package/stream-api/node_modules/es-errors/ref.d.ts +3 -0
  287. package/stream-api/node_modules/es-errors/ref.js +4 -0
  288. package/stream-api/node_modules/es-errors/syntax.d.ts +3 -0
  289. package/stream-api/node_modules/es-errors/syntax.js +4 -0
  290. package/stream-api/node_modules/es-errors/test/index.js +19 -0
  291. package/stream-api/node_modules/es-errors/tsconfig.json +49 -0
  292. package/stream-api/node_modules/es-errors/type.d.ts +3 -0
  293. package/stream-api/node_modules/es-errors/type.js +4 -0
  294. package/stream-api/node_modules/es-errors/uri.d.ts +3 -0
  295. package/stream-api/node_modules/es-errors/uri.js +4 -0
  296. package/stream-api/node_modules/es-object-atoms/.eslintrc +16 -0
  297. package/stream-api/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
  298. package/stream-api/node_modules/es-object-atoms/CHANGELOG.md +37 -0
  299. package/stream-api/node_modules/es-object-atoms/LICENSE +21 -0
  300. package/stream-api/node_modules/es-object-atoms/README.md +63 -0
  301. package/stream-api/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  302. package/stream-api/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  303. package/stream-api/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  304. package/stream-api/node_modules/es-object-atoms/ToObject.js +10 -0
  305. package/stream-api/node_modules/es-object-atoms/index.d.ts +3 -0
  306. package/stream-api/node_modules/es-object-atoms/index.js +4 -0
  307. package/stream-api/node_modules/es-object-atoms/isObject.d.ts +3 -0
  308. package/stream-api/node_modules/es-object-atoms/isObject.js +6 -0
  309. package/stream-api/node_modules/es-object-atoms/package.json +80 -0
  310. package/stream-api/node_modules/es-object-atoms/test/index.js +38 -0
  311. package/stream-api/node_modules/es-object-atoms/tsconfig.json +6 -0
  312. package/stream-api/node_modules/escape-html/LICENSE +24 -0
  313. package/stream-api/node_modules/escape-html/Readme.md +43 -0
  314. package/stream-api/node_modules/escape-html/index.js +78 -0
  315. package/stream-api/node_modules/escape-html/package.json +24 -0
  316. package/stream-api/node_modules/etag/HISTORY.md +83 -0
  317. package/stream-api/node_modules/etag/LICENSE +22 -0
  318. package/stream-api/node_modules/etag/README.md +159 -0
  319. package/stream-api/node_modules/etag/index.js +131 -0
  320. package/stream-api/node_modules/etag/package.json +47 -0
  321. package/stream-api/node_modules/express/History.md +3858 -0
  322. package/stream-api/node_modules/express/LICENSE +24 -0
  323. package/stream-api/node_modules/express/Readme.md +266 -0
  324. package/stream-api/node_modules/express/index.js +11 -0
  325. package/stream-api/node_modules/express/lib/application.js +631 -0
  326. package/stream-api/node_modules/express/lib/express.js +81 -0
  327. package/stream-api/node_modules/express/lib/request.js +515 -0
  328. package/stream-api/node_modules/express/lib/response.js +1039 -0
  329. package/stream-api/node_modules/express/lib/utils.js +269 -0
  330. package/stream-api/node_modules/express/lib/view.js +205 -0
  331. package/stream-api/node_modules/express/package.json +98 -0
  332. package/stream-api/node_modules/finalhandler/HISTORY.md +233 -0
  333. package/stream-api/node_modules/finalhandler/LICENSE +22 -0
  334. package/stream-api/node_modules/finalhandler/README.md +147 -0
  335. package/stream-api/node_modules/finalhandler/index.js +293 -0
  336. package/stream-api/node_modules/finalhandler/package.json +43 -0
  337. package/stream-api/node_modules/forwarded/HISTORY.md +21 -0
  338. package/stream-api/node_modules/forwarded/LICENSE +22 -0
  339. package/stream-api/node_modules/forwarded/README.md +57 -0
  340. package/stream-api/node_modules/forwarded/index.js +90 -0
  341. package/stream-api/node_modules/forwarded/package.json +45 -0
  342. package/stream-api/node_modules/fresh/HISTORY.md +80 -0
  343. package/stream-api/node_modules/fresh/LICENSE +23 -0
  344. package/stream-api/node_modules/fresh/README.md +117 -0
  345. package/stream-api/node_modules/fresh/index.js +136 -0
  346. package/stream-api/node_modules/fresh/package.json +46 -0
  347. package/stream-api/node_modules/function-bind/.eslintrc +21 -0
  348. package/stream-api/node_modules/function-bind/.github/FUNDING.yml +12 -0
  349. package/stream-api/node_modules/function-bind/.github/SECURITY.md +3 -0
  350. package/stream-api/node_modules/function-bind/.nycrc +13 -0
  351. package/stream-api/node_modules/function-bind/CHANGELOG.md +136 -0
  352. package/stream-api/node_modules/function-bind/LICENSE +20 -0
  353. package/stream-api/node_modules/function-bind/README.md +46 -0
  354. package/stream-api/node_modules/function-bind/implementation.js +84 -0
  355. package/stream-api/node_modules/function-bind/index.js +5 -0
  356. package/stream-api/node_modules/function-bind/package.json +87 -0
  357. package/stream-api/node_modules/function-bind/test/.eslintrc +9 -0
  358. package/stream-api/node_modules/function-bind/test/index.js +252 -0
  359. package/stream-api/node_modules/get-intrinsic/.eslintrc +42 -0
  360. package/stream-api/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  361. package/stream-api/node_modules/get-intrinsic/.nycrc +9 -0
  362. package/stream-api/node_modules/get-intrinsic/CHANGELOG.md +186 -0
  363. package/stream-api/node_modules/get-intrinsic/LICENSE +21 -0
  364. package/stream-api/node_modules/get-intrinsic/README.md +71 -0
  365. package/stream-api/node_modules/get-intrinsic/index.js +378 -0
  366. package/stream-api/node_modules/get-intrinsic/package.json +97 -0
  367. package/stream-api/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
  368. package/stream-api/node_modules/get-proto/.eslintrc +10 -0
  369. package/stream-api/node_modules/get-proto/.github/FUNDING.yml +12 -0
  370. package/stream-api/node_modules/get-proto/.nycrc +9 -0
  371. package/stream-api/node_modules/get-proto/CHANGELOG.md +21 -0
  372. package/stream-api/node_modules/get-proto/LICENSE +21 -0
  373. package/stream-api/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
  374. package/stream-api/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
  375. package/stream-api/node_modules/get-proto/README.md +50 -0
  376. package/stream-api/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
  377. package/stream-api/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
  378. package/stream-api/node_modules/get-proto/index.d.ts +5 -0
  379. package/stream-api/node_modules/get-proto/index.js +27 -0
  380. package/stream-api/node_modules/get-proto/package.json +81 -0
  381. package/stream-api/node_modules/get-proto/test/index.js +68 -0
  382. package/stream-api/node_modules/get-proto/tsconfig.json +9 -0
  383. package/stream-api/node_modules/gopd/.eslintrc +16 -0
  384. package/stream-api/node_modules/gopd/.github/FUNDING.yml +12 -0
  385. package/stream-api/node_modules/gopd/CHANGELOG.md +45 -0
  386. package/stream-api/node_modules/gopd/LICENSE +21 -0
  387. package/stream-api/node_modules/gopd/README.md +40 -0
  388. package/stream-api/node_modules/gopd/gOPD.d.ts +1 -0
  389. package/stream-api/node_modules/gopd/gOPD.js +4 -0
  390. package/stream-api/node_modules/gopd/index.d.ts +5 -0
  391. package/stream-api/node_modules/gopd/index.js +15 -0
  392. package/stream-api/node_modules/gopd/package.json +77 -0
  393. package/stream-api/node_modules/gopd/test/index.js +36 -0
  394. package/stream-api/node_modules/gopd/tsconfig.json +9 -0
  395. package/stream-api/node_modules/has-symbols/.eslintrc +11 -0
  396. package/stream-api/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  397. package/stream-api/node_modules/has-symbols/.nycrc +9 -0
  398. package/stream-api/node_modules/has-symbols/CHANGELOG.md +91 -0
  399. package/stream-api/node_modules/has-symbols/LICENSE +21 -0
  400. package/stream-api/node_modules/has-symbols/README.md +46 -0
  401. package/stream-api/node_modules/has-symbols/index.d.ts +3 -0
  402. package/stream-api/node_modules/has-symbols/index.js +14 -0
  403. package/stream-api/node_modules/has-symbols/package.json +111 -0
  404. package/stream-api/node_modules/has-symbols/shams.d.ts +3 -0
  405. package/stream-api/node_modules/has-symbols/shams.js +45 -0
  406. package/stream-api/node_modules/has-symbols/test/index.js +22 -0
  407. package/stream-api/node_modules/has-symbols/test/shams/core-js.js +29 -0
  408. package/stream-api/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
  409. package/stream-api/node_modules/has-symbols/test/tests.js +58 -0
  410. package/stream-api/node_modules/has-symbols/tsconfig.json +10 -0
  411. package/stream-api/node_modules/hasown/.eslintrc +5 -0
  412. package/stream-api/node_modules/hasown/.github/FUNDING.yml +12 -0
  413. package/stream-api/node_modules/hasown/.nycrc +13 -0
  414. package/stream-api/node_modules/hasown/CHANGELOG.md +40 -0
  415. package/stream-api/node_modules/hasown/LICENSE +21 -0
  416. package/stream-api/node_modules/hasown/README.md +40 -0
  417. package/stream-api/node_modules/hasown/index.d.ts +3 -0
  418. package/stream-api/node_modules/hasown/index.js +8 -0
  419. package/stream-api/node_modules/hasown/package.json +92 -0
  420. package/stream-api/node_modules/hasown/tsconfig.json +6 -0
  421. package/stream-api/node_modules/http-errors/HISTORY.md +186 -0
  422. package/stream-api/node_modules/http-errors/LICENSE +23 -0
  423. package/stream-api/node_modules/http-errors/README.md +169 -0
  424. package/stream-api/node_modules/http-errors/index.js +290 -0
  425. package/stream-api/node_modules/http-errors/package.json +54 -0
  426. package/stream-api/node_modules/iconv-lite/Changelog.md +236 -0
  427. package/stream-api/node_modules/iconv-lite/LICENSE +21 -0
  428. package/stream-api/node_modules/iconv-lite/README.md +138 -0
  429. package/stream-api/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
  430. package/stream-api/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
  431. package/stream-api/node_modules/iconv-lite/encodings/index.js +23 -0
  432. package/stream-api/node_modules/iconv-lite/encodings/internal.js +218 -0
  433. package/stream-api/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
  434. package/stream-api/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  435. package/stream-api/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
  436. package/stream-api/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  437. package/stream-api/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  438. package/stream-api/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  439. package/stream-api/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  440. package/stream-api/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  441. package/stream-api/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  442. package/stream-api/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  443. package/stream-api/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  444. package/stream-api/node_modules/iconv-lite/encodings/utf16.js +187 -0
  445. package/stream-api/node_modules/iconv-lite/encodings/utf32.js +307 -0
  446. package/stream-api/node_modules/iconv-lite/encodings/utf7.js +283 -0
  447. package/stream-api/node_modules/iconv-lite/lib/bom-handling.js +48 -0
  448. package/stream-api/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  449. package/stream-api/node_modules/iconv-lite/lib/index.d.ts +41 -0
  450. package/stream-api/node_modules/iconv-lite/lib/index.js +183 -0
  451. package/stream-api/node_modules/iconv-lite/lib/streams.js +105 -0
  452. package/stream-api/node_modules/iconv-lite/package.json +59 -0
  453. package/stream-api/node_modules/inherits/LICENSE +16 -0
  454. package/stream-api/node_modules/inherits/README.md +42 -0
  455. package/stream-api/node_modules/inherits/inherits.js +9 -0
  456. package/stream-api/node_modules/inherits/inherits_browser.js +27 -0
  457. package/stream-api/node_modules/inherits/package.json +29 -0
  458. package/stream-api/node_modules/ipaddr.js/LICENSE +19 -0
  459. package/stream-api/node_modules/ipaddr.js/README.md +233 -0
  460. package/stream-api/node_modules/ipaddr.js/ipaddr.min.js +1 -0
  461. package/stream-api/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
  462. package/stream-api/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
  463. package/stream-api/node_modules/ipaddr.js/package.json +35 -0
  464. package/stream-api/node_modules/is-promise/LICENSE +19 -0
  465. package/stream-api/node_modules/is-promise/index.d.ts +2 -0
  466. package/stream-api/node_modules/is-promise/index.js +6 -0
  467. package/stream-api/node_modules/is-promise/index.mjs +3 -0
  468. package/stream-api/node_modules/is-promise/package.json +30 -0
  469. package/stream-api/node_modules/is-promise/readme.md +33 -0
  470. package/stream-api/node_modules/math-intrinsics/.eslintrc +16 -0
  471. package/stream-api/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
  472. package/stream-api/node_modules/math-intrinsics/CHANGELOG.md +24 -0
  473. package/stream-api/node_modules/math-intrinsics/LICENSE +21 -0
  474. package/stream-api/node_modules/math-intrinsics/README.md +50 -0
  475. package/stream-api/node_modules/math-intrinsics/abs.d.ts +1 -0
  476. package/stream-api/node_modules/math-intrinsics/abs.js +4 -0
  477. package/stream-api/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
  478. package/stream-api/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
  479. package/stream-api/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
  480. package/stream-api/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
  481. package/stream-api/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
  482. package/stream-api/node_modules/math-intrinsics/constants/maxValue.js +5 -0
  483. package/stream-api/node_modules/math-intrinsics/floor.d.ts +1 -0
  484. package/stream-api/node_modules/math-intrinsics/floor.js +4 -0
  485. package/stream-api/node_modules/math-intrinsics/isFinite.d.ts +3 -0
  486. package/stream-api/node_modules/math-intrinsics/isFinite.js +12 -0
  487. package/stream-api/node_modules/math-intrinsics/isInteger.d.ts +3 -0
  488. package/stream-api/node_modules/math-intrinsics/isInteger.js +16 -0
  489. package/stream-api/node_modules/math-intrinsics/isNaN.d.ts +1 -0
  490. package/stream-api/node_modules/math-intrinsics/isNaN.js +6 -0
  491. package/stream-api/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
  492. package/stream-api/node_modules/math-intrinsics/isNegativeZero.js +6 -0
  493. package/stream-api/node_modules/math-intrinsics/max.d.ts +1 -0
  494. package/stream-api/node_modules/math-intrinsics/max.js +4 -0
  495. package/stream-api/node_modules/math-intrinsics/min.d.ts +1 -0
  496. package/stream-api/node_modules/math-intrinsics/min.js +4 -0
  497. package/stream-api/node_modules/math-intrinsics/mod.d.ts +3 -0
  498. package/stream-api/node_modules/math-intrinsics/mod.js +9 -0
  499. package/stream-api/node_modules/math-intrinsics/package.json +86 -0
  500. package/stream-api/node_modules/math-intrinsics/pow.d.ts +1 -0
  501. package/stream-api/node_modules/math-intrinsics/pow.js +4 -0
  502. package/stream-api/node_modules/math-intrinsics/round.d.ts +1 -0
  503. package/stream-api/node_modules/math-intrinsics/round.js +4 -0
  504. package/stream-api/node_modules/math-intrinsics/sign.d.ts +3 -0
  505. package/stream-api/node_modules/math-intrinsics/sign.js +11 -0
  506. package/stream-api/node_modules/math-intrinsics/test/index.js +192 -0
  507. package/stream-api/node_modules/math-intrinsics/tsconfig.json +3 -0
  508. package/stream-api/node_modules/media-typer/HISTORY.md +50 -0
  509. package/stream-api/node_modules/media-typer/LICENSE +22 -0
  510. package/stream-api/node_modules/media-typer/README.md +93 -0
  511. package/stream-api/node_modules/media-typer/index.js +143 -0
  512. package/stream-api/node_modules/media-typer/package.json +33 -0
  513. package/stream-api/node_modules/merge-descriptors/index.d.ts +11 -0
  514. package/stream-api/node_modules/merge-descriptors/index.js +26 -0
  515. package/stream-api/node_modules/merge-descriptors/license +11 -0
  516. package/stream-api/node_modules/merge-descriptors/package.json +50 -0
  517. package/stream-api/node_modules/merge-descriptors/readme.md +55 -0
  518. package/stream-api/node_modules/mime-db/HISTORY.md +541 -0
  519. package/stream-api/node_modules/mime-db/LICENSE +23 -0
  520. package/stream-api/node_modules/mime-db/README.md +109 -0
  521. package/stream-api/node_modules/mime-db/db.json +9342 -0
  522. package/stream-api/node_modules/mime-db/index.js +12 -0
  523. package/stream-api/node_modules/mime-db/package.json +56 -0
  524. package/stream-api/node_modules/mime-types/HISTORY.md +428 -0
  525. package/stream-api/node_modules/mime-types/LICENSE +23 -0
  526. package/stream-api/node_modules/mime-types/README.md +126 -0
  527. package/stream-api/node_modules/mime-types/index.js +211 -0
  528. package/stream-api/node_modules/mime-types/mimeScore.js +57 -0
  529. package/stream-api/node_modules/mime-types/package.json +49 -0
  530. package/stream-api/node_modules/ms/index.js +162 -0
  531. package/stream-api/node_modules/ms/license.md +21 -0
  532. package/stream-api/node_modules/ms/package.json +38 -0
  533. package/stream-api/node_modules/ms/readme.md +59 -0
  534. package/stream-api/node_modules/negotiator/HISTORY.md +114 -0
  535. package/stream-api/node_modules/negotiator/LICENSE +24 -0
  536. package/stream-api/node_modules/negotiator/README.md +212 -0
  537. package/stream-api/node_modules/negotiator/index.js +83 -0
  538. package/stream-api/node_modules/negotiator/lib/charset.js +169 -0
  539. package/stream-api/node_modules/negotiator/lib/encoding.js +205 -0
  540. package/stream-api/node_modules/negotiator/lib/language.js +179 -0
  541. package/stream-api/node_modules/negotiator/lib/mediaType.js +294 -0
  542. package/stream-api/node_modules/negotiator/package.json +43 -0
  543. package/stream-api/node_modules/object-inspect/.eslintrc +53 -0
  544. package/stream-api/node_modules/object-inspect/.github/FUNDING.yml +12 -0
  545. package/stream-api/node_modules/object-inspect/.nycrc +13 -0
  546. package/stream-api/node_modules/object-inspect/CHANGELOG.md +424 -0
  547. package/stream-api/node_modules/object-inspect/LICENSE +21 -0
  548. package/stream-api/node_modules/object-inspect/example/all.js +23 -0
  549. package/stream-api/node_modules/object-inspect/example/circular.js +6 -0
  550. package/stream-api/node_modules/object-inspect/example/fn.js +5 -0
  551. package/stream-api/node_modules/object-inspect/example/inspect.js +10 -0
  552. package/stream-api/node_modules/object-inspect/index.js +544 -0
  553. package/stream-api/node_modules/object-inspect/package-support.json +20 -0
  554. package/stream-api/node_modules/object-inspect/package.json +105 -0
  555. package/stream-api/node_modules/object-inspect/readme.markdown +84 -0
  556. package/stream-api/node_modules/object-inspect/test/bigint.js +58 -0
  557. package/stream-api/node_modules/object-inspect/test/browser/dom.js +15 -0
  558. package/stream-api/node_modules/object-inspect/test/circular.js +16 -0
  559. package/stream-api/node_modules/object-inspect/test/deep.js +12 -0
  560. package/stream-api/node_modules/object-inspect/test/element.js +53 -0
  561. package/stream-api/node_modules/object-inspect/test/err.js +48 -0
  562. package/stream-api/node_modules/object-inspect/test/fakes.js +29 -0
  563. package/stream-api/node_modules/object-inspect/test/fn.js +76 -0
  564. package/stream-api/node_modules/object-inspect/test/global.js +17 -0
  565. package/stream-api/node_modules/object-inspect/test/has.js +15 -0
  566. package/stream-api/node_modules/object-inspect/test/holes.js +15 -0
  567. package/stream-api/node_modules/object-inspect/test/indent-option.js +271 -0
  568. package/stream-api/node_modules/object-inspect/test/inspect.js +139 -0
  569. package/stream-api/node_modules/object-inspect/test/lowbyte.js +12 -0
  570. package/stream-api/node_modules/object-inspect/test/number.js +58 -0
  571. package/stream-api/node_modules/object-inspect/test/quoteStyle.js +26 -0
  572. package/stream-api/node_modules/object-inspect/test/toStringTag.js +40 -0
  573. package/stream-api/node_modules/object-inspect/test/undef.js +12 -0
  574. package/stream-api/node_modules/object-inspect/test/values.js +261 -0
  575. package/stream-api/node_modules/object-inspect/test-core-js.js +26 -0
  576. package/stream-api/node_modules/object-inspect/util.inspect.js +1 -0
  577. package/stream-api/node_modules/on-finished/HISTORY.md +98 -0
  578. package/stream-api/node_modules/on-finished/LICENSE +23 -0
  579. package/stream-api/node_modules/on-finished/README.md +162 -0
  580. package/stream-api/node_modules/on-finished/index.js +234 -0
  581. package/stream-api/node_modules/on-finished/package.json +39 -0
  582. package/stream-api/node_modules/once/LICENSE +15 -0
  583. package/stream-api/node_modules/once/README.md +79 -0
  584. package/stream-api/node_modules/once/once.js +42 -0
  585. package/stream-api/node_modules/once/package.json +33 -0
  586. package/stream-api/node_modules/parseurl/HISTORY.md +58 -0
  587. package/stream-api/node_modules/parseurl/LICENSE +24 -0
  588. package/stream-api/node_modules/parseurl/README.md +133 -0
  589. package/stream-api/node_modules/parseurl/index.js +158 -0
  590. package/stream-api/node_modules/parseurl/package.json +40 -0
  591. package/stream-api/node_modules/path-to-regexp/LICENSE +21 -0
  592. package/stream-api/node_modules/path-to-regexp/Readme.md +224 -0
  593. package/stream-api/node_modules/path-to-regexp/dist/index.d.ts +144 -0
  594. package/stream-api/node_modules/path-to-regexp/dist/index.js +409 -0
  595. package/stream-api/node_modules/path-to-regexp/dist/index.js.map +1 -0
  596. package/stream-api/node_modules/path-to-regexp/package.json +64 -0
  597. package/stream-api/node_modules/proxy-addr/HISTORY.md +161 -0
  598. package/stream-api/node_modules/proxy-addr/LICENSE +22 -0
  599. package/stream-api/node_modules/proxy-addr/README.md +139 -0
  600. package/stream-api/node_modules/proxy-addr/index.js +327 -0
  601. package/stream-api/node_modules/proxy-addr/package.json +47 -0
  602. package/stream-api/node_modules/qs/.editorconfig +46 -0
  603. package/stream-api/node_modules/qs/.eslintrc +39 -0
  604. package/stream-api/node_modules/qs/.github/FUNDING.yml +12 -0
  605. package/stream-api/node_modules/qs/.nycrc +13 -0
  606. package/stream-api/node_modules/qs/CHANGELOG.md +622 -0
  607. package/stream-api/node_modules/qs/LICENSE.md +29 -0
  608. package/stream-api/node_modules/qs/README.md +733 -0
  609. package/stream-api/node_modules/qs/dist/qs.js +141 -0
  610. package/stream-api/node_modules/qs/lib/formats.js +23 -0
  611. package/stream-api/node_modules/qs/lib/index.js +11 -0
  612. package/stream-api/node_modules/qs/lib/parse.js +328 -0
  613. package/stream-api/node_modules/qs/lib/stringify.js +356 -0
  614. package/stream-api/node_modules/qs/lib/utils.js +268 -0
  615. package/stream-api/node_modules/qs/package.json +93 -0
  616. package/stream-api/node_modules/qs/test/empty-keys-cases.js +267 -0
  617. package/stream-api/node_modules/qs/test/parse.js +1276 -0
  618. package/stream-api/node_modules/qs/test/stringify.js +1306 -0
  619. package/stream-api/node_modules/qs/test/utils.js +262 -0
  620. package/stream-api/node_modules/range-parser/HISTORY.md +56 -0
  621. package/stream-api/node_modules/range-parser/LICENSE +23 -0
  622. package/stream-api/node_modules/range-parser/README.md +84 -0
  623. package/stream-api/node_modules/range-parser/index.js +162 -0
  624. package/stream-api/node_modules/range-parser/package.json +44 -0
  625. package/stream-api/node_modules/raw-body/LICENSE +22 -0
  626. package/stream-api/node_modules/raw-body/README.md +223 -0
  627. package/stream-api/node_modules/raw-body/index.d.ts +85 -0
  628. package/stream-api/node_modules/raw-body/index.js +336 -0
  629. package/stream-api/node_modules/raw-body/package.json +46 -0
  630. package/stream-api/node_modules/router/HISTORY.md +228 -0
  631. package/stream-api/node_modules/router/LICENSE +23 -0
  632. package/stream-api/node_modules/router/README.md +416 -0
  633. package/stream-api/node_modules/router/index.js +748 -0
  634. package/stream-api/node_modules/router/lib/layer.js +247 -0
  635. package/stream-api/node_modules/router/lib/route.js +242 -0
  636. package/stream-api/node_modules/router/package.json +44 -0
  637. package/stream-api/node_modules/safer-buffer/LICENSE +21 -0
  638. package/stream-api/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  639. package/stream-api/node_modules/safer-buffer/Readme.md +156 -0
  640. package/stream-api/node_modules/safer-buffer/dangerous.js +58 -0
  641. package/stream-api/node_modules/safer-buffer/package.json +34 -0
  642. package/stream-api/node_modules/safer-buffer/safer.js +77 -0
  643. package/stream-api/node_modules/safer-buffer/tests.js +406 -0
  644. package/stream-api/node_modules/send/HISTORY.md +580 -0
  645. package/stream-api/node_modules/send/LICENSE +23 -0
  646. package/stream-api/node_modules/send/README.md +317 -0
  647. package/stream-api/node_modules/send/index.js +997 -0
  648. package/stream-api/node_modules/send/package.json +60 -0
  649. package/stream-api/node_modules/serve-static/HISTORY.md +516 -0
  650. package/stream-api/node_modules/serve-static/LICENSE +25 -0
  651. package/stream-api/node_modules/serve-static/README.md +253 -0
  652. package/stream-api/node_modules/serve-static/index.js +208 -0
  653. package/stream-api/node_modules/serve-static/package.json +41 -0
  654. package/stream-api/node_modules/setprototypeof/LICENSE +13 -0
  655. package/stream-api/node_modules/setprototypeof/README.md +31 -0
  656. package/stream-api/node_modules/setprototypeof/index.d.ts +2 -0
  657. package/stream-api/node_modules/setprototypeof/index.js +17 -0
  658. package/stream-api/node_modules/setprototypeof/package.json +38 -0
  659. package/stream-api/node_modules/setprototypeof/test/index.js +24 -0
  660. package/stream-api/node_modules/short-uuid/.codeclimate.yml +21 -0
  661. package/stream-api/node_modules/short-uuid/.csslintrc +2 -0
  662. package/stream-api/node_modules/short-uuid/.editorconfig +11 -0
  663. package/stream-api/node_modules/short-uuid/.eslintrc.js +15 -0
  664. package/stream-api/node_modules/short-uuid/.github/workflows/node.js.yml +31 -0
  665. package/stream-api/node_modules/short-uuid/.nyc_output/3a60ecc2-69fc-4d0a-81dd-ad79b6071e14.json +1 -0
  666. package/stream-api/node_modules/short-uuid/.nyc_output/3f261446-c11a-4630-b995-4f5dbc1395ef.json +1 -0
  667. package/stream-api/node_modules/short-uuid/.nyc_output/processinfo/3a60ecc2-69fc-4d0a-81dd-ad79b6071e14.json +1 -0
  668. package/stream-api/node_modules/short-uuid/.nyc_output/processinfo/3f261446-c11a-4630-b995-4f5dbc1395ef.json +1 -0
  669. package/stream-api/node_modules/short-uuid/.nyc_output/processinfo/index.json +1 -0
  670. package/stream-api/node_modules/short-uuid/CHANGELOG.md +237 -0
  671. package/stream-api/node_modules/short-uuid/LICENSE +21 -0
  672. package/stream-api/node_modules/short-uuid/README.md +128 -0
  673. package/stream-api/node_modules/short-uuid/index.d.ts +51 -0
  674. package/stream-api/node_modules/short-uuid/index.js +157 -0
  675. package/stream-api/node_modules/short-uuid/package.json +41 -0
  676. package/stream-api/node_modules/short-uuid/revisions.md +193 -0
  677. package/stream-api/node_modules/short-uuid/test/index.js +339 -0
  678. package/stream-api/node_modules/short-uuid/test/uuid25examples.js +74 -0
  679. package/stream-api/node_modules/side-channel/.editorconfig +9 -0
  680. package/stream-api/node_modules/side-channel/.eslintrc +12 -0
  681. package/stream-api/node_modules/side-channel/.github/FUNDING.yml +12 -0
  682. package/stream-api/node_modules/side-channel/.nycrc +13 -0
  683. package/stream-api/node_modules/side-channel/CHANGELOG.md +110 -0
  684. package/stream-api/node_modules/side-channel/LICENSE +21 -0
  685. package/stream-api/node_modules/side-channel/README.md +61 -0
  686. package/stream-api/node_modules/side-channel/index.d.ts +14 -0
  687. package/stream-api/node_modules/side-channel/index.js +43 -0
  688. package/stream-api/node_modules/side-channel/package.json +85 -0
  689. package/stream-api/node_modules/side-channel/test/index.js +104 -0
  690. package/stream-api/node_modules/side-channel/tsconfig.json +9 -0
  691. package/stream-api/node_modules/side-channel-list/.editorconfig +9 -0
  692. package/stream-api/node_modules/side-channel-list/.eslintrc +11 -0
  693. package/stream-api/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
  694. package/stream-api/node_modules/side-channel-list/.nycrc +13 -0
  695. package/stream-api/node_modules/side-channel-list/CHANGELOG.md +15 -0
  696. package/stream-api/node_modules/side-channel-list/LICENSE +21 -0
  697. package/stream-api/node_modules/side-channel-list/README.md +62 -0
  698. package/stream-api/node_modules/side-channel-list/index.d.ts +13 -0
  699. package/stream-api/node_modules/side-channel-list/index.js +113 -0
  700. package/stream-api/node_modules/side-channel-list/list.d.ts +14 -0
  701. package/stream-api/node_modules/side-channel-list/package.json +77 -0
  702. package/stream-api/node_modules/side-channel-list/test/index.js +104 -0
  703. package/stream-api/node_modules/side-channel-list/tsconfig.json +9 -0
  704. package/stream-api/node_modules/side-channel-map/.editorconfig +9 -0
  705. package/stream-api/node_modules/side-channel-map/.eslintrc +11 -0
  706. package/stream-api/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
  707. package/stream-api/node_modules/side-channel-map/.nycrc +13 -0
  708. package/stream-api/node_modules/side-channel-map/CHANGELOG.md +22 -0
  709. package/stream-api/node_modules/side-channel-map/LICENSE +21 -0
  710. package/stream-api/node_modules/side-channel-map/README.md +62 -0
  711. package/stream-api/node_modules/side-channel-map/index.d.ts +15 -0
  712. package/stream-api/node_modules/side-channel-map/index.js +68 -0
  713. package/stream-api/node_modules/side-channel-map/package.json +80 -0
  714. package/stream-api/node_modules/side-channel-map/test/index.js +114 -0
  715. package/stream-api/node_modules/side-channel-map/tsconfig.json +9 -0
  716. package/stream-api/node_modules/side-channel-weakmap/.editorconfig +9 -0
  717. package/stream-api/node_modules/side-channel-weakmap/.eslintrc +12 -0
  718. package/stream-api/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
  719. package/stream-api/node_modules/side-channel-weakmap/.nycrc +13 -0
  720. package/stream-api/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
  721. package/stream-api/node_modules/side-channel-weakmap/LICENSE +21 -0
  722. package/stream-api/node_modules/side-channel-weakmap/README.md +62 -0
  723. package/stream-api/node_modules/side-channel-weakmap/index.d.ts +15 -0
  724. package/stream-api/node_modules/side-channel-weakmap/index.js +84 -0
  725. package/stream-api/node_modules/side-channel-weakmap/package.json +87 -0
  726. package/stream-api/node_modules/side-channel-weakmap/test/index.js +114 -0
  727. package/stream-api/node_modules/side-channel-weakmap/tsconfig.json +9 -0
  728. package/stream-api/node_modules/statuses/HISTORY.md +87 -0
  729. package/stream-api/node_modules/statuses/LICENSE +23 -0
  730. package/stream-api/node_modules/statuses/README.md +139 -0
  731. package/stream-api/node_modules/statuses/codes.json +65 -0
  732. package/stream-api/node_modules/statuses/index.js +146 -0
  733. package/stream-api/node_modules/statuses/package.json +49 -0
  734. package/stream-api/node_modules/toidentifier/HISTORY.md +9 -0
  735. package/stream-api/node_modules/toidentifier/LICENSE +21 -0
  736. package/stream-api/node_modules/toidentifier/README.md +61 -0
  737. package/stream-api/node_modules/toidentifier/index.js +32 -0
  738. package/stream-api/node_modules/toidentifier/package.json +38 -0
  739. package/stream-api/node_modules/type-is/HISTORY.md +292 -0
  740. package/stream-api/node_modules/type-is/LICENSE +23 -0
  741. package/stream-api/node_modules/type-is/README.md +198 -0
  742. package/stream-api/node_modules/type-is/index.js +250 -0
  743. package/stream-api/node_modules/type-is/package.json +47 -0
  744. package/stream-api/node_modules/undici-types/LICENSE +21 -0
  745. package/stream-api/node_modules/undici-types/README.md +6 -0
  746. package/stream-api/node_modules/undici-types/agent.d.ts +32 -0
  747. package/stream-api/node_modules/undici-types/api.d.ts +43 -0
  748. package/stream-api/node_modules/undici-types/balanced-pool.d.ts +29 -0
  749. package/stream-api/node_modules/undici-types/cache-interceptor.d.ts +172 -0
  750. package/stream-api/node_modules/undici-types/cache.d.ts +36 -0
  751. package/stream-api/node_modules/undici-types/client-stats.d.ts +15 -0
  752. package/stream-api/node_modules/undici-types/client.d.ts +108 -0
  753. package/stream-api/node_modules/undici-types/connector.d.ts +34 -0
  754. package/stream-api/node_modules/undici-types/content-type.d.ts +21 -0
  755. package/stream-api/node_modules/undici-types/cookies.d.ts +30 -0
  756. package/stream-api/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  757. package/stream-api/node_modules/undici-types/dispatcher.d.ts +276 -0
  758. package/stream-api/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  759. package/stream-api/node_modules/undici-types/errors.d.ts +161 -0
  760. package/stream-api/node_modules/undici-types/eventsource.d.ts +66 -0
  761. package/stream-api/node_modules/undici-types/fetch.d.ts +211 -0
  762. package/stream-api/node_modules/undici-types/formdata.d.ts +108 -0
  763. package/stream-api/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  764. package/stream-api/node_modules/undici-types/global-origin.d.ts +7 -0
  765. package/stream-api/node_modules/undici-types/h2c-client.d.ts +73 -0
  766. package/stream-api/node_modules/undici-types/handlers.d.ts +15 -0
  767. package/stream-api/node_modules/undici-types/header.d.ts +160 -0
  768. package/stream-api/node_modules/undici-types/index.d.ts +80 -0
  769. package/stream-api/node_modules/undici-types/interceptors.d.ts +39 -0
  770. package/stream-api/node_modules/undici-types/mock-agent.d.ts +68 -0
  771. package/stream-api/node_modules/undici-types/mock-call-history.d.ts +111 -0
  772. package/stream-api/node_modules/undici-types/mock-client.d.ts +27 -0
  773. package/stream-api/node_modules/undici-types/mock-errors.d.ts +12 -0
  774. package/stream-api/node_modules/undici-types/mock-interceptor.d.ts +94 -0
  775. package/stream-api/node_modules/undici-types/mock-pool.d.ts +27 -0
  776. package/stream-api/node_modules/undici-types/package.json +55 -0
  777. package/stream-api/node_modules/undici-types/patch.d.ts +29 -0
  778. package/stream-api/node_modules/undici-types/pool-stats.d.ts +19 -0
  779. package/stream-api/node_modules/undici-types/pool.d.ts +41 -0
  780. package/stream-api/node_modules/undici-types/proxy-agent.d.ts +29 -0
  781. package/stream-api/node_modules/undici-types/readable.d.ts +68 -0
  782. package/stream-api/node_modules/undici-types/retry-agent.d.ts +8 -0
  783. package/stream-api/node_modules/undici-types/retry-handler.d.ts +125 -0
  784. package/stream-api/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  785. package/stream-api/node_modules/undici-types/util.d.ts +18 -0
  786. package/stream-api/node_modules/undici-types/utility.d.ts +7 -0
  787. package/stream-api/node_modules/undici-types/webidl.d.ts +341 -0
  788. package/stream-api/node_modules/undici-types/websocket.d.ts +186 -0
  789. package/stream-api/node_modules/unpipe/HISTORY.md +4 -0
  790. package/stream-api/node_modules/unpipe/LICENSE +22 -0
  791. package/stream-api/node_modules/unpipe/README.md +43 -0
  792. package/stream-api/node_modules/unpipe/index.js +69 -0
  793. package/stream-api/node_modules/unpipe/package.json +27 -0
  794. package/stream-api/node_modules/uuid/CHANGELOG.md +274 -0
  795. package/stream-api/node_modules/uuid/CONTRIBUTING.md +18 -0
  796. package/stream-api/node_modules/uuid/LICENSE.md +9 -0
  797. package/stream-api/node_modules/uuid/README.md +466 -0
  798. package/stream-api/node_modules/uuid/dist/bin/uuid +2 -0
  799. package/stream-api/node_modules/uuid/dist/commonjs-browser/index.js +79 -0
  800. package/stream-api/node_modules/uuid/dist/commonjs-browser/md5.js +223 -0
  801. package/stream-api/node_modules/uuid/dist/commonjs-browser/native.js +11 -0
  802. package/stream-api/node_modules/uuid/dist/commonjs-browser/nil.js +8 -0
  803. package/stream-api/node_modules/uuid/dist/commonjs-browser/parse.js +45 -0
  804. package/stream-api/node_modules/uuid/dist/commonjs-browser/regex.js +8 -0
  805. package/stream-api/node_modules/uuid/dist/commonjs-browser/rng.js +25 -0
  806. package/stream-api/node_modules/uuid/dist/commonjs-browser/sha1.js +104 -0
  807. package/stream-api/node_modules/uuid/dist/commonjs-browser/stringify.js +44 -0
  808. package/stream-api/node_modules/uuid/dist/commonjs-browser/v1.js +107 -0
  809. package/stream-api/node_modules/uuid/dist/commonjs-browser/v3.js +16 -0
  810. package/stream-api/node_modules/uuid/dist/commonjs-browser/v35.js +80 -0
  811. package/stream-api/node_modules/uuid/dist/commonjs-browser/v4.js +43 -0
  812. package/stream-api/node_modules/uuid/dist/commonjs-browser/v5.js +16 -0
  813. package/stream-api/node_modules/uuid/dist/commonjs-browser/validate.js +17 -0
  814. package/stream-api/node_modules/uuid/dist/commonjs-browser/version.js +21 -0
  815. package/stream-api/node_modules/uuid/dist/esm-browser/index.js +9 -0
  816. package/stream-api/node_modules/uuid/dist/esm-browser/md5.js +215 -0
  817. package/stream-api/node_modules/uuid/dist/esm-browser/native.js +4 -0
  818. package/stream-api/node_modules/uuid/dist/esm-browser/nil.js +1 -0
  819. package/stream-api/node_modules/uuid/dist/esm-browser/parse.js +35 -0
  820. package/stream-api/node_modules/uuid/dist/esm-browser/regex.js +1 -0
  821. package/stream-api/node_modules/uuid/dist/esm-browser/rng.js +18 -0
  822. package/stream-api/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
  823. package/stream-api/node_modules/uuid/dist/esm-browser/stringify.js +33 -0
  824. package/stream-api/node_modules/uuid/dist/esm-browser/v1.js +95 -0
  825. package/stream-api/node_modules/uuid/dist/esm-browser/v3.js +4 -0
  826. package/stream-api/node_modules/uuid/dist/esm-browser/v35.js +66 -0
  827. package/stream-api/node_modules/uuid/dist/esm-browser/v4.js +29 -0
  828. package/stream-api/node_modules/uuid/dist/esm-browser/v5.js +4 -0
  829. package/stream-api/node_modules/uuid/dist/esm-browser/validate.js +7 -0
  830. package/stream-api/node_modules/uuid/dist/esm-browser/version.js +11 -0
  831. package/stream-api/node_modules/uuid/dist/esm-node/index.js +9 -0
  832. package/stream-api/node_modules/uuid/dist/esm-node/md5.js +13 -0
  833. package/stream-api/node_modules/uuid/dist/esm-node/native.js +4 -0
  834. package/stream-api/node_modules/uuid/dist/esm-node/nil.js +1 -0
  835. package/stream-api/node_modules/uuid/dist/esm-node/parse.js +35 -0
  836. package/stream-api/node_modules/uuid/dist/esm-node/regex.js +1 -0
  837. package/stream-api/node_modules/uuid/dist/esm-node/rng.js +12 -0
  838. package/stream-api/node_modules/uuid/dist/esm-node/sha1.js +13 -0
  839. package/stream-api/node_modules/uuid/dist/esm-node/stringify.js +33 -0
  840. package/stream-api/node_modules/uuid/dist/esm-node/v1.js +95 -0
  841. package/stream-api/node_modules/uuid/dist/esm-node/v3.js +4 -0
  842. package/stream-api/node_modules/uuid/dist/esm-node/v35.js +66 -0
  843. package/stream-api/node_modules/uuid/dist/esm-node/v4.js +29 -0
  844. package/stream-api/node_modules/uuid/dist/esm-node/v5.js +4 -0
  845. package/stream-api/node_modules/uuid/dist/esm-node/validate.js +7 -0
  846. package/stream-api/node_modules/uuid/dist/esm-node/version.js +11 -0
  847. package/stream-api/node_modules/uuid/dist/index.js +79 -0
  848. package/stream-api/node_modules/uuid/dist/md5-browser.js +223 -0
  849. package/stream-api/node_modules/uuid/dist/md5.js +23 -0
  850. package/stream-api/node_modules/uuid/dist/native-browser.js +11 -0
  851. package/stream-api/node_modules/uuid/dist/native.js +15 -0
  852. package/stream-api/node_modules/uuid/dist/nil.js +8 -0
  853. package/stream-api/node_modules/uuid/dist/parse.js +45 -0
  854. package/stream-api/node_modules/uuid/dist/regex.js +8 -0
  855. package/stream-api/node_modules/uuid/dist/rng-browser.js +25 -0
  856. package/stream-api/node_modules/uuid/dist/rng.js +24 -0
  857. package/stream-api/node_modules/uuid/dist/sha1-browser.js +104 -0
  858. package/stream-api/node_modules/uuid/dist/sha1.js +23 -0
  859. package/stream-api/node_modules/uuid/dist/stringify.js +44 -0
  860. package/stream-api/node_modules/uuid/dist/uuid-bin.js +85 -0
  861. package/stream-api/node_modules/uuid/dist/v1.js +107 -0
  862. package/stream-api/node_modules/uuid/dist/v3.js +16 -0
  863. package/stream-api/node_modules/uuid/dist/v35.js +80 -0
  864. package/stream-api/node_modules/uuid/dist/v4.js +43 -0
  865. package/stream-api/node_modules/uuid/dist/v5.js +16 -0
  866. package/stream-api/node_modules/uuid/dist/validate.js +17 -0
  867. package/stream-api/node_modules/uuid/dist/version.js +21 -0
  868. package/stream-api/node_modules/uuid/package.json +135 -0
  869. package/stream-api/node_modules/uuid/wrapper.mjs +10 -0
  870. package/stream-api/node_modules/vary/HISTORY.md +39 -0
  871. package/stream-api/node_modules/vary/LICENSE +22 -0
  872. package/stream-api/node_modules/vary/README.md +101 -0
  873. package/stream-api/node_modules/vary/index.js +149 -0
  874. package/stream-api/node_modules/vary/package.json +43 -0
  875. package/stream-api/node_modules/wrappy/LICENSE +15 -0
  876. package/stream-api/node_modules/wrappy/README.md +36 -0
  877. package/stream-api/node_modules/wrappy/package.json +29 -0
  878. package/stream-api/node_modules/wrappy/wrappy.js +33 -0
  879. package/stream-api/package-lock.json +985 -0
  880. package/stream-api/package.json +25 -0
  881. package/stream-api/tsconfig.json +10 -0
@@ -0,0 +1,4714 @@
1
+ /**
2
+ * The `node:fs` module enables interacting with the file system in a
3
+ * way modeled on standard POSIX functions.
4
+ *
5
+ * To use the promise-based APIs:
6
+ *
7
+ * ```js
8
+ * import * as fs from 'node:fs/promises';
9
+ * ```
10
+ *
11
+ * To use the callback and sync APIs:
12
+ *
13
+ * ```js
14
+ * import * as fs from 'node:fs';
15
+ * ```
16
+ *
17
+ * All file system operations have synchronous, callback, and promise-based
18
+ * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
19
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/fs.js)
20
+ */
21
+ declare module "fs" {
22
+ import { NonSharedBuffer } from "node:buffer";
23
+ import * as stream from "node:stream";
24
+ import { Abortable, EventEmitter } from "node:events";
25
+ import { URL } from "node:url";
26
+ import * as promises from "node:fs/promises";
27
+ export { promises };
28
+ /**
29
+ * Valid types for path values in "fs".
30
+ */
31
+ export type PathLike = string | Buffer | URL;
32
+ export type PathOrFileDescriptor = PathLike | number;
33
+ export type TimeLike = string | number | Date;
34
+ export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
35
+ export type BufferEncodingOption =
36
+ | "buffer"
37
+ | {
38
+ encoding: "buffer";
39
+ };
40
+ export interface ObjectEncodingOptions {
41
+ encoding?: BufferEncoding | null | undefined;
42
+ }
43
+ export type EncodingOption = ObjectEncodingOptions | BufferEncoding | undefined | null;
44
+ export type OpenMode = number | string;
45
+ export type Mode = number | string;
46
+ export interface StatsBase<T> {
47
+ isFile(): boolean;
48
+ isDirectory(): boolean;
49
+ isBlockDevice(): boolean;
50
+ isCharacterDevice(): boolean;
51
+ isSymbolicLink(): boolean;
52
+ isFIFO(): boolean;
53
+ isSocket(): boolean;
54
+ dev: T;
55
+ ino: T;
56
+ mode: T;
57
+ nlink: T;
58
+ uid: T;
59
+ gid: T;
60
+ rdev: T;
61
+ size: T;
62
+ blksize: T;
63
+ blocks: T;
64
+ atimeMs: T;
65
+ mtimeMs: T;
66
+ ctimeMs: T;
67
+ birthtimeMs: T;
68
+ atime: Date;
69
+ mtime: Date;
70
+ ctime: Date;
71
+ birthtime: Date;
72
+ }
73
+ export interface Stats extends StatsBase<number> {}
74
+ /**
75
+ * A `fs.Stats` object provides information about a file.
76
+ *
77
+ * Objects returned from {@link stat}, {@link lstat}, {@link fstat}, and
78
+ * their synchronous counterparts are of this type.
79
+ * If `bigint` in the `options` passed to those methods is true, the numeric values
80
+ * will be `bigint` instead of `number`, and the object will contain additional
81
+ * nanosecond-precision properties suffixed with `Ns`. `Stat` objects are not to be created directly using the `new` keyword.
82
+ *
83
+ * ```console
84
+ * Stats {
85
+ * dev: 2114,
86
+ * ino: 48064969,
87
+ * mode: 33188,
88
+ * nlink: 1,
89
+ * uid: 85,
90
+ * gid: 100,
91
+ * rdev: 0,
92
+ * size: 527,
93
+ * blksize: 4096,
94
+ * blocks: 8,
95
+ * atimeMs: 1318289051000.1,
96
+ * mtimeMs: 1318289051000.1,
97
+ * ctimeMs: 1318289051000.1,
98
+ * birthtimeMs: 1318289051000.1,
99
+ * atime: Mon, 10 Oct 2011 23:24:11 GMT,
100
+ * mtime: Mon, 10 Oct 2011 23:24:11 GMT,
101
+ * ctime: Mon, 10 Oct 2011 23:24:11 GMT,
102
+ * birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
103
+ * ```
104
+ *
105
+ * `bigint` version:
106
+ *
107
+ * ```console
108
+ * BigIntStats {
109
+ * dev: 2114n,
110
+ * ino: 48064969n,
111
+ * mode: 33188n,
112
+ * nlink: 1n,
113
+ * uid: 85n,
114
+ * gid: 100n,
115
+ * rdev: 0n,
116
+ * size: 527n,
117
+ * blksize: 4096n,
118
+ * blocks: 8n,
119
+ * atimeMs: 1318289051000n,
120
+ * mtimeMs: 1318289051000n,
121
+ * ctimeMs: 1318289051000n,
122
+ * birthtimeMs: 1318289051000n,
123
+ * atimeNs: 1318289051000000000n,
124
+ * mtimeNs: 1318289051000000000n,
125
+ * ctimeNs: 1318289051000000000n,
126
+ * birthtimeNs: 1318289051000000000n,
127
+ * atime: Mon, 10 Oct 2011 23:24:11 GMT,
128
+ * mtime: Mon, 10 Oct 2011 23:24:11 GMT,
129
+ * ctime: Mon, 10 Oct 2011 23:24:11 GMT,
130
+ * birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
131
+ * ```
132
+ * @since v0.1.21
133
+ */
134
+ export class Stats {
135
+ private constructor();
136
+ }
137
+ export interface StatsFsBase<T> {
138
+ /** Type of file system. */
139
+ type: T;
140
+ /** Optimal transfer block size. */
141
+ bsize: T;
142
+ /** Total data blocks in file system. */
143
+ blocks: T;
144
+ /** Free blocks in file system. */
145
+ bfree: T;
146
+ /** Available blocks for unprivileged users */
147
+ bavail: T;
148
+ /** Total file nodes in file system. */
149
+ files: T;
150
+ /** Free file nodes in file system. */
151
+ ffree: T;
152
+ }
153
+ export interface StatsFs extends StatsFsBase<number> {}
154
+ /**
155
+ * Provides information about a mounted file system.
156
+ *
157
+ * Objects returned from {@link statfs} and its synchronous counterpart are of
158
+ * this type. If `bigint` in the `options` passed to those methods is `true`, the
159
+ * numeric values will be `bigint` instead of `number`.
160
+ *
161
+ * ```console
162
+ * StatFs {
163
+ * type: 1397114950,
164
+ * bsize: 4096,
165
+ * blocks: 121938943,
166
+ * bfree: 61058895,
167
+ * bavail: 61058895,
168
+ * files: 999,
169
+ * ffree: 1000000
170
+ * }
171
+ * ```
172
+ *
173
+ * `bigint` version:
174
+ *
175
+ * ```console
176
+ * StatFs {
177
+ * type: 1397114950n,
178
+ * bsize: 4096n,
179
+ * blocks: 121938943n,
180
+ * bfree: 61058895n,
181
+ * bavail: 61058895n,
182
+ * files: 999n,
183
+ * ffree: 1000000n
184
+ * }
185
+ * ```
186
+ * @since v19.6.0, v18.15.0
187
+ */
188
+ export class StatsFs {}
189
+ export interface BigIntStatsFs extends StatsFsBase<bigint> {}
190
+ export interface StatFsOptions {
191
+ bigint?: boolean | undefined;
192
+ }
193
+ /**
194
+ * A representation of a directory entry, which can be a file or a subdirectory
195
+ * within the directory, as returned by reading from an `fs.Dir`. The
196
+ * directory entry is a combination of the file name and file type pairs.
197
+ *
198
+ * Additionally, when {@link readdir} or {@link readdirSync} is called with
199
+ * the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s.
200
+ * @since v10.10.0
201
+ */
202
+ export class Dirent<Name extends string | Buffer = string> {
203
+ /**
204
+ * Returns `true` if the `fs.Dirent` object describes a regular file.
205
+ * @since v10.10.0
206
+ */
207
+ isFile(): boolean;
208
+ /**
209
+ * Returns `true` if the `fs.Dirent` object describes a file system
210
+ * directory.
211
+ * @since v10.10.0
212
+ */
213
+ isDirectory(): boolean;
214
+ /**
215
+ * Returns `true` if the `fs.Dirent` object describes a block device.
216
+ * @since v10.10.0
217
+ */
218
+ isBlockDevice(): boolean;
219
+ /**
220
+ * Returns `true` if the `fs.Dirent` object describes a character device.
221
+ * @since v10.10.0
222
+ */
223
+ isCharacterDevice(): boolean;
224
+ /**
225
+ * Returns `true` if the `fs.Dirent` object describes a symbolic link.
226
+ * @since v10.10.0
227
+ */
228
+ isSymbolicLink(): boolean;
229
+ /**
230
+ * Returns `true` if the `fs.Dirent` object describes a first-in-first-out
231
+ * (FIFO) pipe.
232
+ * @since v10.10.0
233
+ */
234
+ isFIFO(): boolean;
235
+ /**
236
+ * Returns `true` if the `fs.Dirent` object describes a socket.
237
+ * @since v10.10.0
238
+ */
239
+ isSocket(): boolean;
240
+ /**
241
+ * The file name that this `fs.Dirent` object refers to. The type of this
242
+ * value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}.
243
+ * @since v10.10.0
244
+ */
245
+ name: Name;
246
+ /**
247
+ * The path to the parent directory of the file this `fs.Dirent` object refers to.
248
+ * @since v20.12.0, v18.20.0
249
+ */
250
+ parentPath: string;
251
+ }
252
+ /**
253
+ * A class representing a directory stream.
254
+ *
255
+ * Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`.
256
+ *
257
+ * ```js
258
+ * import { opendir } from 'node:fs/promises';
259
+ *
260
+ * try {
261
+ * const dir = await opendir('./');
262
+ * for await (const dirent of dir)
263
+ * console.log(dirent.name);
264
+ * } catch (err) {
265
+ * console.error(err);
266
+ * }
267
+ * ```
268
+ *
269
+ * When using the async iterator, the `fs.Dir` object will be automatically
270
+ * closed after the iterator exits.
271
+ * @since v12.12.0
272
+ */
273
+ export class Dir implements AsyncIterable<Dirent> {
274
+ /**
275
+ * The read-only path of this directory as was provided to {@link opendir},{@link opendirSync}, or `fsPromises.opendir()`.
276
+ * @since v12.12.0
277
+ */
278
+ readonly path: string;
279
+ /**
280
+ * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
281
+ */
282
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<Dirent>;
283
+ /**
284
+ * Asynchronously close the directory's underlying resource handle.
285
+ * Subsequent reads will result in errors.
286
+ *
287
+ * A promise is returned that will be fulfilled after the resource has been
288
+ * closed.
289
+ * @since v12.12.0
290
+ */
291
+ close(): Promise<void>;
292
+ close(cb: NoParamCallback): void;
293
+ /**
294
+ * Synchronously close the directory's underlying resource handle.
295
+ * Subsequent reads will result in errors.
296
+ * @since v12.12.0
297
+ */
298
+ closeSync(): void;
299
+ /**
300
+ * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`.
301
+ *
302
+ * A promise is returned that will be fulfilled with an `fs.Dirent`, or `null` if there are no more directory entries to read.
303
+ *
304
+ * Directory entries returned by this function are in no particular order as
305
+ * provided by the operating system's underlying directory mechanisms.
306
+ * Entries added or removed while iterating over the directory might not be
307
+ * included in the iteration results.
308
+ * @since v12.12.0
309
+ * @return containing {fs.Dirent|null}
310
+ */
311
+ read(): Promise<Dirent | null>;
312
+ read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void;
313
+ /**
314
+ * Synchronously read the next directory entry as an `fs.Dirent`. See the
315
+ * POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail.
316
+ *
317
+ * If there are no more directory entries to read, `null` will be returned.
318
+ *
319
+ * Directory entries returned by this function are in no particular order as
320
+ * provided by the operating system's underlying directory mechanisms.
321
+ * Entries added or removed while iterating over the directory might not be
322
+ * included in the iteration results.
323
+ * @since v12.12.0
324
+ */
325
+ readSync(): Dirent | null;
326
+ /**
327
+ * Calls `dir.close()` if the directory handle is open, and returns a promise that
328
+ * fulfills when disposal is complete.
329
+ * @since v24.1.0
330
+ */
331
+ [Symbol.asyncDispose](): Promise<void>;
332
+ /**
333
+ * Calls `dir.closeSync()` if the directory handle is open, and returns
334
+ * `undefined`.
335
+ * @since v24.1.0
336
+ */
337
+ [Symbol.dispose](): void;
338
+ }
339
+ /**
340
+ * Class: fs.StatWatcher
341
+ * @since v14.3.0, v12.20.0
342
+ * Extends `EventEmitter`
343
+ * A successful call to {@link watchFile} method will return a new fs.StatWatcher object.
344
+ */
345
+ export interface StatWatcher extends EventEmitter {
346
+ /**
347
+ * When called, requests that the Node.js event loop _not_ exit so long as the `fs.StatWatcher` is active. Calling `watcher.ref()` multiple times will have
348
+ * no effect.
349
+ *
350
+ * By default, all `fs.StatWatcher` objects are "ref'ed", making it normally
351
+ * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been
352
+ * called previously.
353
+ * @since v14.3.0, v12.20.0
354
+ */
355
+ ref(): this;
356
+ /**
357
+ * When called, the active `fs.StatWatcher` object will not require the Node.js
358
+ * event loop to remain active. If there is no other activity keeping the
359
+ * event loop running, the process may exit before the `fs.StatWatcher` object's
360
+ * callback is invoked. Calling `watcher.unref()` multiple times will have
361
+ * no effect.
362
+ * @since v14.3.0, v12.20.0
363
+ */
364
+ unref(): this;
365
+ }
366
+ export interface FSWatcher extends EventEmitter {
367
+ /**
368
+ * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable.
369
+ * @since v0.5.8
370
+ */
371
+ close(): void;
372
+ /**
373
+ * When called, requests that the Node.js event loop _not_ exit so long as the `fs.FSWatcher` is active. Calling `watcher.ref()` multiple times will have
374
+ * no effect.
375
+ *
376
+ * By default, all `fs.FSWatcher` objects are "ref'ed", making it normally
377
+ * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been
378
+ * called previously.
379
+ * @since v14.3.0, v12.20.0
380
+ */
381
+ ref(): this;
382
+ /**
383
+ * When called, the active `fs.FSWatcher` object will not require the Node.js
384
+ * event loop to remain active. If there is no other activity keeping the
385
+ * event loop running, the process may exit before the `fs.FSWatcher` object's
386
+ * callback is invoked. Calling `watcher.unref()` multiple times will have
387
+ * no effect.
388
+ * @since v14.3.0, v12.20.0
389
+ */
390
+ unref(): this;
391
+ /**
392
+ * events.EventEmitter
393
+ * 1. change
394
+ * 2. close
395
+ * 3. error
396
+ */
397
+ addListener(event: string, listener: (...args: any[]) => void): this;
398
+ addListener(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
399
+ addListener(event: "close", listener: () => void): this;
400
+ addListener(event: "error", listener: (error: Error) => void): this;
401
+ on(event: string, listener: (...args: any[]) => void): this;
402
+ on(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
403
+ on(event: "close", listener: () => void): this;
404
+ on(event: "error", listener: (error: Error) => void): this;
405
+ once(event: string, listener: (...args: any[]) => void): this;
406
+ once(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
407
+ once(event: "close", listener: () => void): this;
408
+ once(event: "error", listener: (error: Error) => void): this;
409
+ prependListener(event: string, listener: (...args: any[]) => void): this;
410
+ prependListener(
411
+ event: "change",
412
+ listener: (eventType: string, filename: string | NonSharedBuffer) => void,
413
+ ): this;
414
+ prependListener(event: "close", listener: () => void): this;
415
+ prependListener(event: "error", listener: (error: Error) => void): this;
416
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
417
+ prependOnceListener(
418
+ event: "change",
419
+ listener: (eventType: string, filename: string | NonSharedBuffer) => void,
420
+ ): this;
421
+ prependOnceListener(event: "close", listener: () => void): this;
422
+ prependOnceListener(event: "error", listener: (error: Error) => void): this;
423
+ }
424
+ /**
425
+ * Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.
426
+ * @since v0.1.93
427
+ */
428
+ export class ReadStream extends stream.Readable {
429
+ close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;
430
+ /**
431
+ * The number of bytes that have been read so far.
432
+ * @since v6.4.0
433
+ */
434
+ bytesRead: number;
435
+ /**
436
+ * The path to the file the stream is reading from as specified in the first
437
+ * argument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a
438
+ * `Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.
439
+ * @since v0.1.93
440
+ */
441
+ path: string | Buffer;
442
+ /**
443
+ * This property is `true` if the underlying file has not been opened yet,
444
+ * i.e. before the `'ready'` event is emitted.
445
+ * @since v11.2.0, v10.16.0
446
+ */
447
+ pending: boolean;
448
+ /**
449
+ * events.EventEmitter
450
+ * 1. open
451
+ * 2. close
452
+ * 3. ready
453
+ */
454
+ addListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
455
+ on<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
456
+ once<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
457
+ prependListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
458
+ prependOnceListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
459
+ }
460
+ export interface Utf8StreamOptions {
461
+ /**
462
+ * Appends writes to dest file instead of truncating it.
463
+ * @default true
464
+ */
465
+ append?: boolean | undefined;
466
+ /**
467
+ * Which type of data you can send to the write
468
+ * function, supported values are `'utf8'` or `'buffer'`.
469
+ * @default 'utf8'
470
+ */
471
+ contentMode?: "utf8" | "buffer" | undefined;
472
+ /**
473
+ * A path to a file to be written to (mode controlled by the
474
+ * append option).
475
+ */
476
+ dest?: string | undefined;
477
+ /**
478
+ * A file descriptor, something that is returned by `fs.open()`
479
+ * or `fs.openSync()`.
480
+ */
481
+ fd?: number | undefined;
482
+ /**
483
+ * An object that has the same API as the `fs` module, useful
484
+ * for mocking, testing, or customizing the behavior of the stream.
485
+ */
486
+ fs?: object | undefined;
487
+ /**
488
+ * Perform a `fs.fsyncSync()` every time a write is
489
+ * completed.
490
+ */
491
+ fsync?: boolean | undefined;
492
+ /**
493
+ * The maximum length of the internal buffer. If a write
494
+ * operation would cause the buffer to exceed `maxLength`, the data written is
495
+ * dropped and a drop event is emitted with the dropped data
496
+ */
497
+ maxLength?: number | undefined;
498
+ /**
499
+ * The maximum number of bytes that can be written;
500
+ * @default 16384
501
+ */
502
+ maxWrite?: number | undefined;
503
+ /**
504
+ * The minimum length of the internal buffer that is
505
+ * required to be full before flushing.
506
+ */
507
+ minLength?: number | undefined;
508
+ /**
509
+ * Ensure directory for `dest` file exists when true.
510
+ * @default false
511
+ */
512
+ mkdir?: boolean | undefined;
513
+ /**
514
+ * Specify the creating file mode (see `fs.open()`).
515
+ */
516
+ mode?: number | string | undefined;
517
+ /**
518
+ * Calls flush every `periodicFlush` milliseconds.
519
+ */
520
+ periodicFlush?: number | undefined;
521
+ /**
522
+ * A function that will be called when `write()`,
523
+ * `writeSync()`, or `flushSync()` encounters an `EAGAIN` or `EBUSY` error.
524
+ * If the return value is `true` the operation will be retried, otherwise it
525
+ * will bubble the error. The `err` is the error that caused this function to
526
+ * be called, `writeBufferLen` is the length of the buffer that was written,
527
+ * and `remainingBufferLen` is the length of the remaining buffer that the
528
+ * stream did not try to write.
529
+ */
530
+ retryEAGAIN?: ((err: Error | null, writeBufferLen: number, remainingBufferLen: number) => boolean) | undefined;
531
+ /**
532
+ * Perform writes synchronously.
533
+ */
534
+ sync?: boolean | undefined;
535
+ }
536
+ /**
537
+ * An optimized UTF-8 stream writer that allows for flushing all the internal
538
+ * buffering on demand. It handles `EAGAIN` errors correctly, allowing for
539
+ * customization, for example, by dropping content if the disk is busy.
540
+ * @since v24.6.0
541
+ * @experimental
542
+ */
543
+ export class Utf8Stream extends EventEmitter {
544
+ constructor(options: Utf8StreamOptions);
545
+ /**
546
+ * Whether the stream is appending to the file or truncating it.
547
+ */
548
+ readonly append: boolean;
549
+ /**
550
+ * The type of data that can be written to the stream. Supported
551
+ * values are `'utf8'` or `'buffer'`.
552
+ * @default 'utf8'
553
+ */
554
+ readonly contentMode: "utf8" | "buffer";
555
+ /**
556
+ * Close the stream immediately, without flushing the internal buffer.
557
+ */
558
+ destroy(): void;
559
+ /**
560
+ * Close the stream gracefully, flushing the internal buffer before closing.
561
+ */
562
+ end(): void;
563
+ /**
564
+ * The file descriptor that is being written to.
565
+ */
566
+ readonly fd: number;
567
+ /**
568
+ * The file that is being written to.
569
+ */
570
+ readonly file: string;
571
+ /**
572
+ * Writes the current buffer to the file if a write was not in progress. Do
573
+ * nothing if `minLength` is zero or if it is already writing.
574
+ */
575
+ flush(callback: (err: Error | null) => void): void;
576
+ /**
577
+ * Flushes the buffered data synchronously. This is a costly operation.
578
+ */
579
+ flushSync(): void;
580
+ /**
581
+ * Whether the stream is performing a `fs.fsyncSync()` after every
582
+ * write operation.
583
+ */
584
+ readonly fsync: boolean;
585
+ /**
586
+ * The maximum length of the internal buffer. If a write
587
+ * operation would cause the buffer to exceed `maxLength`, the data written is
588
+ * dropped and a drop event is emitted with the dropped data.
589
+ */
590
+ readonly maxLength: number;
591
+ /**
592
+ * The minimum length of the internal buffer that is required to be
593
+ * full before flushing.
594
+ */
595
+ readonly minLength: number;
596
+ /**
597
+ * Whether the stream should ensure that the directory for the
598
+ * `dest` file exists. If `true`, it will create the directory if it does not
599
+ * exist.
600
+ * @default false
601
+ */
602
+ readonly mkdir: boolean;
603
+ /**
604
+ * The mode of the file that is being written to.
605
+ */
606
+ readonly mode: number | string;
607
+ /**
608
+ * The number of milliseconds between flushes. If set to `0`, no
609
+ * periodic flushes will be performed.
610
+ */
611
+ readonly periodicFlush: number;
612
+ /**
613
+ * Reopen the file in place, useful for log rotation.
614
+ * @param file A path to a file to be written to (mode
615
+ * controlled by the append option).
616
+ */
617
+ reopen(file: PathLike): void;
618
+ /**
619
+ * Whether the stream is writing synchronously or asynchronously.
620
+ */
621
+ readonly sync: boolean;
622
+ /**
623
+ * When the `options.contentMode` is set to `'utf8'` when the stream is created,
624
+ * the `data` argument must be a string. If the `contentMode` is set to `'buffer'`,
625
+ * the `data` argument must be a `Buffer`.
626
+ * @param data The data to write.
627
+ */
628
+ write(data: string | Buffer): boolean;
629
+ /**
630
+ * Whether the stream is currently writing data to the file.
631
+ */
632
+ readonly writing: boolean;
633
+ /**
634
+ * Calls `utf8Stream.destroy()`.
635
+ */
636
+ [Symbol.dispose](): void;
637
+ /**
638
+ * events.EventEmitter
639
+ * 1. change
640
+ * 2. close
641
+ * 3. error
642
+ */
643
+ addListener(event: "close", listener: () => void): this;
644
+ addListener(event: "drain", listener: () => void): this;
645
+ addListener(event: "drop", listener: (data: string | Buffer) => void): this;
646
+ addListener(event: "error", listener: (error: Error) => void): this;
647
+ addListener(event: "finish", listener: () => void): this;
648
+ addListener(event: "ready", listener: () => void): this;
649
+ addListener(event: "write", listener: (n: number) => void): this;
650
+ addListener(event: string, listener: (...args: any[]) => void): this;
651
+ on(event: "close", listener: () => void): this;
652
+ on(event: "drain", listener: () => void): this;
653
+ on(event: "drop", listener: (data: string | Buffer) => void): this;
654
+ on(event: "error", listener: (error: Error) => void): this;
655
+ on(event: "finish", listener: () => void): this;
656
+ on(event: "ready", listener: () => void): this;
657
+ on(event: "write", listener: (n: number) => void): this;
658
+ on(event: string, listener: (...args: any[]) => void): this;
659
+ once(event: "close", listener: () => void): this;
660
+ once(event: "drain", listener: () => void): this;
661
+ once(event: "drop", listener: (data: string | Buffer) => void): this;
662
+ once(event: "error", listener: (error: Error) => void): this;
663
+ once(event: "finish", listener: () => void): this;
664
+ once(event: "ready", listener: () => void): this;
665
+ once(event: "write", listener: (n: number) => void): this;
666
+ once(event: string, listener: (...args: any[]) => void): this;
667
+ prependListener(event: "close", listener: () => void): this;
668
+ prependListener(event: "drain", listener: () => void): this;
669
+ prependListener(event: "drop", listener: (data: string | Buffer) => void): this;
670
+ prependListener(event: "error", listener: (error: Error) => void): this;
671
+ prependListener(event: "finish", listener: () => void): this;
672
+ prependListener(event: "ready", listener: () => void): this;
673
+ prependListener(event: "write", listener: (n: number) => void): this;
674
+ prependListener(event: string, listener: (...args: any[]) => void): this;
675
+ prependOnceListener(event: "close", listener: () => void): this;
676
+ prependOnceListener(event: "drain", listener: () => void): this;
677
+ prependOnceListener(event: "drop", listener: (data: string | Buffer) => void): this;
678
+ prependOnceListener(event: "error", listener: (error: Error) => void): this;
679
+ prependOnceListener(event: "finish", listener: () => void): this;
680
+ prependOnceListener(event: "ready", listener: () => void): this;
681
+ prependOnceListener(event: "write", listener: (n: number) => void): this;
682
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
683
+ }
684
+
685
+ /**
686
+ * The Keys are events of the ReadStream and the values are the functions that are called when the event is emitted.
687
+ */
688
+ type ReadStreamEvents = {
689
+ close: () => void;
690
+ data: (chunk: Buffer | string) => void;
691
+ end: () => void;
692
+ error: (err: Error) => void;
693
+ open: (fd: number) => void;
694
+ pause: () => void;
695
+ readable: () => void;
696
+ ready: () => void;
697
+ resume: () => void;
698
+ } & CustomEvents;
699
+
700
+ /**
701
+ * string & {} allows to allow any kind of strings for the event
702
+ * but still allows to have auto completion for the normal events.
703
+ */
704
+ type CustomEvents = { [Key in string & {} | symbol]: (...args: any[]) => void };
705
+
706
+ /**
707
+ * The Keys are events of the WriteStream and the values are the functions that are called when the event is emitted.
708
+ */
709
+ type WriteStreamEvents = {
710
+ close: () => void;
711
+ drain: () => void;
712
+ error: (err: Error) => void;
713
+ finish: () => void;
714
+ open: (fd: number) => void;
715
+ pipe: (src: stream.Readable) => void;
716
+ ready: () => void;
717
+ unpipe: (src: stream.Readable) => void;
718
+ } & CustomEvents;
719
+ /**
720
+ * * Extends `stream.Writable`
721
+ *
722
+ * Instances of `fs.WriteStream` are created and returned using the {@link createWriteStream} function.
723
+ * @since v0.1.93
724
+ */
725
+ export class WriteStream extends stream.Writable {
726
+ /**
727
+ * Closes `writeStream`. Optionally accepts a
728
+ * callback that will be executed once the `writeStream`is closed.
729
+ * @since v0.9.4
730
+ */
731
+ close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;
732
+ /**
733
+ * The number of bytes written so far. Does not include data that is still queued
734
+ * for writing.
735
+ * @since v0.4.7
736
+ */
737
+ bytesWritten: number;
738
+ /**
739
+ * The path to the file the stream is writing to as specified in the first
740
+ * argument to {@link createWriteStream}. If `path` is passed as a string, then`writeStream.path` will be a string. If `path` is passed as a `Buffer`, then`writeStream.path` will be a
741
+ * `Buffer`.
742
+ * @since v0.1.93
743
+ */
744
+ path: string | Buffer;
745
+ /**
746
+ * This property is `true` if the underlying file has not been opened yet,
747
+ * i.e. before the `'ready'` event is emitted.
748
+ * @since v11.2.0
749
+ */
750
+ pending: boolean;
751
+ /**
752
+ * events.EventEmitter
753
+ * 1. open
754
+ * 2. close
755
+ * 3. ready
756
+ */
757
+ addListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
758
+ on<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
759
+ once<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
760
+ prependListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
761
+ prependOnceListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
762
+ }
763
+ /**
764
+ * Asynchronously rename file at `oldPath` to the pathname provided
765
+ * as `newPath`. In the case that `newPath` already exists, it will
766
+ * be overwritten. If there is a directory at `newPath`, an error will
767
+ * be raised instead. No arguments other than a possible exception are
768
+ * given to the completion callback.
769
+ *
770
+ * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html).
771
+ *
772
+ * ```js
773
+ * import { rename } from 'node:fs';
774
+ *
775
+ * rename('oldFile.txt', 'newFile.txt', (err) => {
776
+ * if (err) throw err;
777
+ * console.log('Rename complete!');
778
+ * });
779
+ * ```
780
+ * @since v0.0.2
781
+ */
782
+ export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
783
+ export namespace rename {
784
+ /**
785
+ * Asynchronous rename(2) - Change the name or location of a file or directory.
786
+ * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
787
+ * URL support is _experimental_.
788
+ * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
789
+ * URL support is _experimental_.
790
+ */
791
+ function __promisify__(oldPath: PathLike, newPath: PathLike): Promise<void>;
792
+ }
793
+ /**
794
+ * Renames the file from `oldPath` to `newPath`. Returns `undefined`.
795
+ *
796
+ * See the POSIX [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html) documentation for more details.
797
+ * @since v0.1.21
798
+ */
799
+ export function renameSync(oldPath: PathLike, newPath: PathLike): void;
800
+ /**
801
+ * Truncates the file. No arguments other than a possible exception are
802
+ * given to the completion callback. A file descriptor can also be passed as the
803
+ * first argument. In this case, `fs.ftruncate()` is called.
804
+ *
805
+ * ```js
806
+ * import { truncate } from 'node:fs';
807
+ * // Assuming that 'path/file.txt' is a regular file.
808
+ * truncate('path/file.txt', (err) => {
809
+ * if (err) throw err;
810
+ * console.log('path/file.txt was truncated');
811
+ * });
812
+ * ```
813
+ *
814
+ * Passing a file descriptor is deprecated and may result in an error being thrown
815
+ * in the future.
816
+ *
817
+ * See the POSIX [`truncate(2)`](http://man7.org/linux/man-pages/man2/truncate.2.html) documentation for more details.
818
+ * @since v0.8.6
819
+ * @param [len=0]
820
+ */
821
+ export function truncate(path: PathLike, len: number | undefined, callback: NoParamCallback): void;
822
+ /**
823
+ * Asynchronous truncate(2) - Truncate a file to a specified length.
824
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
825
+ */
826
+ export function truncate(path: PathLike, callback: NoParamCallback): void;
827
+ export namespace truncate {
828
+ /**
829
+ * Asynchronous truncate(2) - Truncate a file to a specified length.
830
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
831
+ * @param len If not specified, defaults to `0`.
832
+ */
833
+ function __promisify__(path: PathLike, len?: number): Promise<void>;
834
+ }
835
+ /**
836
+ * Truncates the file. Returns `undefined`. A file descriptor can also be
837
+ * passed as the first argument. In this case, `fs.ftruncateSync()` is called.
838
+ *
839
+ * Passing a file descriptor is deprecated and may result in an error being thrown
840
+ * in the future.
841
+ * @since v0.8.6
842
+ * @param [len=0]
843
+ */
844
+ export function truncateSync(path: PathLike, len?: number): void;
845
+ /**
846
+ * Truncates the file descriptor. No arguments other than a possible exception are
847
+ * given to the completion callback.
848
+ *
849
+ * See the POSIX [`ftruncate(2)`](http://man7.org/linux/man-pages/man2/ftruncate.2.html) documentation for more detail.
850
+ *
851
+ * If the file referred to by the file descriptor was larger than `len` bytes, only
852
+ * the first `len` bytes will be retained in the file.
853
+ *
854
+ * For example, the following program retains only the first four bytes of the
855
+ * file:
856
+ *
857
+ * ```js
858
+ * import { open, close, ftruncate } from 'node:fs';
859
+ *
860
+ * function closeFd(fd) {
861
+ * close(fd, (err) => {
862
+ * if (err) throw err;
863
+ * });
864
+ * }
865
+ *
866
+ * open('temp.txt', 'r+', (err, fd) => {
867
+ * if (err) throw err;
868
+ *
869
+ * try {
870
+ * ftruncate(fd, 4, (err) => {
871
+ * closeFd(fd);
872
+ * if (err) throw err;
873
+ * });
874
+ * } catch (err) {
875
+ * closeFd(fd);
876
+ * if (err) throw err;
877
+ * }
878
+ * });
879
+ * ```
880
+ *
881
+ * If the file previously was shorter than `len` bytes, it is extended, and the
882
+ * extended part is filled with null bytes (`'\0'`):
883
+ *
884
+ * If `len` is negative then `0` will be used.
885
+ * @since v0.8.6
886
+ * @param [len=0]
887
+ */
888
+ export function ftruncate(fd: number, len: number | undefined, callback: NoParamCallback): void;
889
+ /**
890
+ * Asynchronous ftruncate(2) - Truncate a file to a specified length.
891
+ * @param fd A file descriptor.
892
+ */
893
+ export function ftruncate(fd: number, callback: NoParamCallback): void;
894
+ export namespace ftruncate {
895
+ /**
896
+ * Asynchronous ftruncate(2) - Truncate a file to a specified length.
897
+ * @param fd A file descriptor.
898
+ * @param len If not specified, defaults to `0`.
899
+ */
900
+ function __promisify__(fd: number, len?: number): Promise<void>;
901
+ }
902
+ /**
903
+ * Truncates the file descriptor. Returns `undefined`.
904
+ *
905
+ * For detailed information, see the documentation of the asynchronous version of
906
+ * this API: {@link ftruncate}.
907
+ * @since v0.8.6
908
+ * @param [len=0]
909
+ */
910
+ export function ftruncateSync(fd: number, len?: number): void;
911
+ /**
912
+ * Asynchronously changes owner and group of a file. No arguments other than a
913
+ * possible exception are given to the completion callback.
914
+ *
915
+ * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.
916
+ * @since v0.1.97
917
+ */
918
+ export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
919
+ export namespace chown {
920
+ /**
921
+ * Asynchronous chown(2) - Change ownership of a file.
922
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
923
+ */
924
+ function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
925
+ }
926
+ /**
927
+ * Synchronously changes owner and group of a file. Returns `undefined`.
928
+ * This is the synchronous version of {@link chown}.
929
+ *
930
+ * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.
931
+ * @since v0.1.97
932
+ */
933
+ export function chownSync(path: PathLike, uid: number, gid: number): void;
934
+ /**
935
+ * Sets the owner of the file. No arguments other than a possible exception are
936
+ * given to the completion callback.
937
+ *
938
+ * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.
939
+ * @since v0.4.7
940
+ */
941
+ export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
942
+ export namespace fchown {
943
+ /**
944
+ * Asynchronous fchown(2) - Change ownership of a file.
945
+ * @param fd A file descriptor.
946
+ */
947
+ function __promisify__(fd: number, uid: number, gid: number): Promise<void>;
948
+ }
949
+ /**
950
+ * Sets the owner of the file. Returns `undefined`.
951
+ *
952
+ * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.
953
+ * @since v0.4.7
954
+ * @param uid The file's new owner's user id.
955
+ * @param gid The file's new group's group id.
956
+ */
957
+ export function fchownSync(fd: number, uid: number, gid: number): void;
958
+ /**
959
+ * Set the owner of the symbolic link. No arguments other than a possible
960
+ * exception are given to the completion callback.
961
+ *
962
+ * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more detail.
963
+ */
964
+ export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
965
+ export namespace lchown {
966
+ /**
967
+ * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
968
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
969
+ */
970
+ function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
971
+ }
972
+ /**
973
+ * Set the owner for the path. Returns `undefined`.
974
+ *
975
+ * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more details.
976
+ * @param uid The file's new owner's user id.
977
+ * @param gid The file's new group's group id.
978
+ */
979
+ export function lchownSync(path: PathLike, uid: number, gid: number): void;
980
+ /**
981
+ * Changes the access and modification times of a file in the same way as {@link utimes}, with the difference that if the path refers to a symbolic
982
+ * link, then the link is not dereferenced: instead, the timestamps of the
983
+ * symbolic link itself are changed.
984
+ *
985
+ * No arguments other than a possible exception are given to the completion
986
+ * callback.
987
+ * @since v14.5.0, v12.19.0
988
+ */
989
+ export function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
990
+ export namespace lutimes {
991
+ /**
992
+ * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`,
993
+ * with the difference that if the path refers to a symbolic link, then the link is not
994
+ * dereferenced: instead, the timestamps of the symbolic link itself are changed.
995
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
996
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
997
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
998
+ */
999
+ function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
1000
+ }
1001
+ /**
1002
+ * Change the file system timestamps of the symbolic link referenced by `path`.
1003
+ * Returns `undefined`, or throws an exception when parameters are incorrect or
1004
+ * the operation fails. This is the synchronous version of {@link lutimes}.
1005
+ * @since v14.5.0, v12.19.0
1006
+ */
1007
+ export function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
1008
+ /**
1009
+ * Asynchronously changes the permissions of a file. No arguments other than a
1010
+ * possible exception are given to the completion callback.
1011
+ *
1012
+ * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.
1013
+ *
1014
+ * ```js
1015
+ * import { chmod } from 'node:fs';
1016
+ *
1017
+ * chmod('my_file.txt', 0o775, (err) => {
1018
+ * if (err) throw err;
1019
+ * console.log('The permissions for file "my_file.txt" have been changed!');
1020
+ * });
1021
+ * ```
1022
+ * @since v0.1.30
1023
+ */
1024
+ export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
1025
+ export namespace chmod {
1026
+ /**
1027
+ * Asynchronous chmod(2) - Change permissions of a file.
1028
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1029
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
1030
+ */
1031
+ function __promisify__(path: PathLike, mode: Mode): Promise<void>;
1032
+ }
1033
+ /**
1034
+ * For detailed information, see the documentation of the asynchronous version of
1035
+ * this API: {@link chmod}.
1036
+ *
1037
+ * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.
1038
+ * @since v0.6.7
1039
+ */
1040
+ export function chmodSync(path: PathLike, mode: Mode): void;
1041
+ /**
1042
+ * Sets the permissions on the file. No arguments other than a possible exception
1043
+ * are given to the completion callback.
1044
+ *
1045
+ * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.
1046
+ * @since v0.4.7
1047
+ */
1048
+ export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void;
1049
+ export namespace fchmod {
1050
+ /**
1051
+ * Asynchronous fchmod(2) - Change permissions of a file.
1052
+ * @param fd A file descriptor.
1053
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
1054
+ */
1055
+ function __promisify__(fd: number, mode: Mode): Promise<void>;
1056
+ }
1057
+ /**
1058
+ * Sets the permissions on the file. Returns `undefined`.
1059
+ *
1060
+ * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.
1061
+ * @since v0.4.7
1062
+ */
1063
+ export function fchmodSync(fd: number, mode: Mode): void;
1064
+ /**
1065
+ * Changes the permissions on a symbolic link. No arguments other than a possible
1066
+ * exception are given to the completion callback.
1067
+ *
1068
+ * This method is only implemented on macOS.
1069
+ *
1070
+ * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.
1071
+ * @deprecated Since v0.4.7
1072
+ */
1073
+ export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
1074
+ /** @deprecated */
1075
+ export namespace lchmod {
1076
+ /**
1077
+ * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
1078
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1079
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
1080
+ */
1081
+ function __promisify__(path: PathLike, mode: Mode): Promise<void>;
1082
+ }
1083
+ /**
1084
+ * Changes the permissions on a symbolic link. Returns `undefined`.
1085
+ *
1086
+ * This method is only implemented on macOS.
1087
+ *
1088
+ * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.
1089
+ * @deprecated Since v0.4.7
1090
+ */
1091
+ export function lchmodSync(path: PathLike, mode: Mode): void;
1092
+ /**
1093
+ * Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `fs.Stats` object.
1094
+ *
1095
+ * In case of an error, the `err.code` will be one of `Common System Errors`.
1096
+ *
1097
+ * {@link stat} follows symbolic links. Use {@link lstat} to look at the
1098
+ * links themselves.
1099
+ *
1100
+ * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended.
1101
+ * Instead, user code should open/read/write the file directly and handle the
1102
+ * error raised if the file is not available.
1103
+ *
1104
+ * To check if a file exists without manipulating it afterwards, {@link access} is recommended.
1105
+ *
1106
+ * For example, given the following directory structure:
1107
+ *
1108
+ * ```text
1109
+ * - txtDir
1110
+ * -- file.txt
1111
+ * - app.js
1112
+ * ```
1113
+ *
1114
+ * The next program will check for the stats of the given paths:
1115
+ *
1116
+ * ```js
1117
+ * import { stat } from 'node:fs';
1118
+ *
1119
+ * const pathsToCheck = ['./txtDir', './txtDir/file.txt'];
1120
+ *
1121
+ * for (let i = 0; i < pathsToCheck.length; i++) {
1122
+ * stat(pathsToCheck[i], (err, stats) => {
1123
+ * console.log(stats.isDirectory());
1124
+ * console.log(stats);
1125
+ * });
1126
+ * }
1127
+ * ```
1128
+ *
1129
+ * The resulting output will resemble:
1130
+ *
1131
+ * ```console
1132
+ * true
1133
+ * Stats {
1134
+ * dev: 16777220,
1135
+ * mode: 16877,
1136
+ * nlink: 3,
1137
+ * uid: 501,
1138
+ * gid: 20,
1139
+ * rdev: 0,
1140
+ * blksize: 4096,
1141
+ * ino: 14214262,
1142
+ * size: 96,
1143
+ * blocks: 0,
1144
+ * atimeMs: 1561174653071.963,
1145
+ * mtimeMs: 1561174614583.3518,
1146
+ * ctimeMs: 1561174626623.5366,
1147
+ * birthtimeMs: 1561174126937.2893,
1148
+ * atime: 2019-06-22T03:37:33.072Z,
1149
+ * mtime: 2019-06-22T03:36:54.583Z,
1150
+ * ctime: 2019-06-22T03:37:06.624Z,
1151
+ * birthtime: 2019-06-22T03:28:46.937Z
1152
+ * }
1153
+ * false
1154
+ * Stats {
1155
+ * dev: 16777220,
1156
+ * mode: 33188,
1157
+ * nlink: 1,
1158
+ * uid: 501,
1159
+ * gid: 20,
1160
+ * rdev: 0,
1161
+ * blksize: 4096,
1162
+ * ino: 14214074,
1163
+ * size: 8,
1164
+ * blocks: 8,
1165
+ * atimeMs: 1561174616618.8555,
1166
+ * mtimeMs: 1561174614584,
1167
+ * ctimeMs: 1561174614583.8145,
1168
+ * birthtimeMs: 1561174007710.7478,
1169
+ * atime: 2019-06-22T03:36:56.619Z,
1170
+ * mtime: 2019-06-22T03:36:54.584Z,
1171
+ * ctime: 2019-06-22T03:36:54.584Z,
1172
+ * birthtime: 2019-06-22T03:26:47.711Z
1173
+ * }
1174
+ * ```
1175
+ * @since v0.0.2
1176
+ */
1177
+ export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
1178
+ export function stat(
1179
+ path: PathLike,
1180
+ options:
1181
+ | (StatOptions & {
1182
+ bigint?: false | undefined;
1183
+ })
1184
+ | undefined,
1185
+ callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void,
1186
+ ): void;
1187
+ export function stat(
1188
+ path: PathLike,
1189
+ options: StatOptions & {
1190
+ bigint: true;
1191
+ },
1192
+ callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void,
1193
+ ): void;
1194
+ export function stat(
1195
+ path: PathLike,
1196
+ options: StatOptions | undefined,
1197
+ callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void,
1198
+ ): void;
1199
+ export namespace stat {
1200
+ /**
1201
+ * Asynchronous stat(2) - Get file status.
1202
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1203
+ */
1204
+ function __promisify__(
1205
+ path: PathLike,
1206
+ options?: StatOptions & {
1207
+ bigint?: false | undefined;
1208
+ },
1209
+ ): Promise<Stats>;
1210
+ function __promisify__(
1211
+ path: PathLike,
1212
+ options: StatOptions & {
1213
+ bigint: true;
1214
+ },
1215
+ ): Promise<BigIntStats>;
1216
+ function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
1217
+ }
1218
+ export interface StatSyncFn extends Function {
1219
+ (path: PathLike, options?: undefined): Stats;
1220
+ (
1221
+ path: PathLike,
1222
+ options?: StatSyncOptions & {
1223
+ bigint?: false | undefined;
1224
+ throwIfNoEntry: false;
1225
+ },
1226
+ ): Stats | undefined;
1227
+ (
1228
+ path: PathLike,
1229
+ options: StatSyncOptions & {
1230
+ bigint: true;
1231
+ throwIfNoEntry: false;
1232
+ },
1233
+ ): BigIntStats | undefined;
1234
+ (
1235
+ path: PathLike,
1236
+ options?: StatSyncOptions & {
1237
+ bigint?: false | undefined;
1238
+ },
1239
+ ): Stats;
1240
+ (
1241
+ path: PathLike,
1242
+ options: StatSyncOptions & {
1243
+ bigint: true;
1244
+ },
1245
+ ): BigIntStats;
1246
+ (
1247
+ path: PathLike,
1248
+ options: StatSyncOptions & {
1249
+ bigint: boolean;
1250
+ throwIfNoEntry?: false | undefined;
1251
+ },
1252
+ ): Stats | BigIntStats;
1253
+ (path: PathLike, options?: StatSyncOptions): Stats | BigIntStats | undefined;
1254
+ }
1255
+ /**
1256
+ * Synchronous stat(2) - Get file status.
1257
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1258
+ */
1259
+ export const statSync: StatSyncFn;
1260
+ /**
1261
+ * Invokes the callback with the `fs.Stats` for the file descriptor.
1262
+ *
1263
+ * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.
1264
+ * @since v0.1.95
1265
+ */
1266
+ export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
1267
+ export function fstat(
1268
+ fd: number,
1269
+ options:
1270
+ | (StatOptions & {
1271
+ bigint?: false | undefined;
1272
+ })
1273
+ | undefined,
1274
+ callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void,
1275
+ ): void;
1276
+ export function fstat(
1277
+ fd: number,
1278
+ options: StatOptions & {
1279
+ bigint: true;
1280
+ },
1281
+ callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void,
1282
+ ): void;
1283
+ export function fstat(
1284
+ fd: number,
1285
+ options: StatOptions | undefined,
1286
+ callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void,
1287
+ ): void;
1288
+ export namespace fstat {
1289
+ /**
1290
+ * Asynchronous fstat(2) - Get file status.
1291
+ * @param fd A file descriptor.
1292
+ */
1293
+ function __promisify__(
1294
+ fd: number,
1295
+ options?: StatOptions & {
1296
+ bigint?: false | undefined;
1297
+ },
1298
+ ): Promise<Stats>;
1299
+ function __promisify__(
1300
+ fd: number,
1301
+ options: StatOptions & {
1302
+ bigint: true;
1303
+ },
1304
+ ): Promise<BigIntStats>;
1305
+ function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
1306
+ }
1307
+ /**
1308
+ * Retrieves the `fs.Stats` for the file descriptor.
1309
+ *
1310
+ * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.
1311
+ * @since v0.1.95
1312
+ */
1313
+ export function fstatSync(
1314
+ fd: number,
1315
+ options?: StatOptions & {
1316
+ bigint?: false | undefined;
1317
+ },
1318
+ ): Stats;
1319
+ export function fstatSync(
1320
+ fd: number,
1321
+ options: StatOptions & {
1322
+ bigint: true;
1323
+ },
1324
+ ): BigIntStats;
1325
+ export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;
1326
+ /**
1327
+ * Retrieves the `fs.Stats` for the symbolic link referred to by the path.
1328
+ * The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic
1329
+ * link, then the link itself is stat-ed, not the file that it refers to.
1330
+ *
1331
+ * See the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details.
1332
+ * @since v0.1.30
1333
+ */
1334
+ export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
1335
+ export function lstat(
1336
+ path: PathLike,
1337
+ options:
1338
+ | (StatOptions & {
1339
+ bigint?: false | undefined;
1340
+ })
1341
+ | undefined,
1342
+ callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void,
1343
+ ): void;
1344
+ export function lstat(
1345
+ path: PathLike,
1346
+ options: StatOptions & {
1347
+ bigint: true;
1348
+ },
1349
+ callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void,
1350
+ ): void;
1351
+ export function lstat(
1352
+ path: PathLike,
1353
+ options: StatOptions | undefined,
1354
+ callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void,
1355
+ ): void;
1356
+ export namespace lstat {
1357
+ /**
1358
+ * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
1359
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1360
+ */
1361
+ function __promisify__(
1362
+ path: PathLike,
1363
+ options?: StatOptions & {
1364
+ bigint?: false | undefined;
1365
+ },
1366
+ ): Promise<Stats>;
1367
+ function __promisify__(
1368
+ path: PathLike,
1369
+ options: StatOptions & {
1370
+ bigint: true;
1371
+ },
1372
+ ): Promise<BigIntStats>;
1373
+ function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
1374
+ }
1375
+ /**
1376
+ * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
1377
+ * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object.
1378
+ *
1379
+ * In case of an error, the `err.code` will be one of `Common System Errors`.
1380
+ * @since v19.6.0, v18.15.0
1381
+ * @param path A path to an existing file or directory on the file system to be queried.
1382
+ */
1383
+ export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void;
1384
+ export function statfs(
1385
+ path: PathLike,
1386
+ options:
1387
+ | (StatFsOptions & {
1388
+ bigint?: false | undefined;
1389
+ })
1390
+ | undefined,
1391
+ callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void,
1392
+ ): void;
1393
+ export function statfs(
1394
+ path: PathLike,
1395
+ options: StatFsOptions & {
1396
+ bigint: true;
1397
+ },
1398
+ callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void,
1399
+ ): void;
1400
+ export function statfs(
1401
+ path: PathLike,
1402
+ options: StatFsOptions | undefined,
1403
+ callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void,
1404
+ ): void;
1405
+ export namespace statfs {
1406
+ /**
1407
+ * Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an <fs.StatFs> object.
1408
+ * @param path A path to an existing file or directory on the file system to be queried.
1409
+ */
1410
+ function __promisify__(
1411
+ path: PathLike,
1412
+ options?: StatFsOptions & {
1413
+ bigint?: false | undefined;
1414
+ },
1415
+ ): Promise<StatsFs>;
1416
+ function __promisify__(
1417
+ path: PathLike,
1418
+ options: StatFsOptions & {
1419
+ bigint: true;
1420
+ },
1421
+ ): Promise<BigIntStatsFs>;
1422
+ function __promisify__(path: PathLike, options?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;
1423
+ }
1424
+ /**
1425
+ * Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
1426
+ * contains `path`.
1427
+ *
1428
+ * In case of an error, the `err.code` will be one of `Common System Errors`.
1429
+ * @since v19.6.0, v18.15.0
1430
+ * @param path A path to an existing file or directory on the file system to be queried.
1431
+ */
1432
+ export function statfsSync(
1433
+ path: PathLike,
1434
+ options?: StatFsOptions & {
1435
+ bigint?: false | undefined;
1436
+ },
1437
+ ): StatsFs;
1438
+ export function statfsSync(
1439
+ path: PathLike,
1440
+ options: StatFsOptions & {
1441
+ bigint: true;
1442
+ },
1443
+ ): BigIntStatsFs;
1444
+ export function statfsSync(path: PathLike, options?: StatFsOptions): StatsFs | BigIntStatsFs;
1445
+ /**
1446
+ * Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
1447
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1448
+ */
1449
+ export const lstatSync: StatSyncFn;
1450
+ /**
1451
+ * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. No arguments other than
1452
+ * a possible
1453
+ * exception are given to the completion callback.
1454
+ * @since v0.1.31
1455
+ */
1456
+ export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
1457
+ export namespace link {
1458
+ /**
1459
+ * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
1460
+ * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
1461
+ * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
1462
+ */
1463
+ function __promisify__(existingPath: PathLike, newPath: PathLike): Promise<void>;
1464
+ }
1465
+ /**
1466
+ * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. Returns `undefined`.
1467
+ * @since v0.1.31
1468
+ */
1469
+ export function linkSync(existingPath: PathLike, newPath: PathLike): void;
1470
+ /**
1471
+ * Creates the link called `path` pointing to `target`. No arguments other than a
1472
+ * possible exception are given to the completion callback.
1473
+ *
1474
+ * See the POSIX [`symlink(2)`](http://man7.org/linux/man-pages/man2/symlink.2.html) documentation for more details.
1475
+ *
1476
+ * The `type` argument is only available on Windows and ignored on other platforms.
1477
+ * It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is
1478
+ * not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`.
1479
+ * If the `target` does not exist, `'file'` will be used. Windows junction points
1480
+ * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path. Junction
1481
+ * points on NTFS volumes can only point to directories.
1482
+ *
1483
+ * Relative targets are relative to the link's parent directory.
1484
+ *
1485
+ * ```js
1486
+ * import { symlink } from 'node:fs';
1487
+ *
1488
+ * symlink('./mew', './mewtwo', callback);
1489
+ * ```
1490
+ *
1491
+ * The above example creates a symbolic link `mewtwo` which points to `mew` in the
1492
+ * same directory:
1493
+ *
1494
+ * ```bash
1495
+ * $ tree .
1496
+ * .
1497
+ * ├── mew
1498
+ * └── mewtwo -> ./mew
1499
+ * ```
1500
+ * @since v0.1.31
1501
+ * @param [type='null']
1502
+ */
1503
+ export function symlink(
1504
+ target: PathLike,
1505
+ path: PathLike,
1506
+ type: symlink.Type | undefined | null,
1507
+ callback: NoParamCallback,
1508
+ ): void;
1509
+ /**
1510
+ * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
1511
+ * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
1512
+ * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
1513
+ */
1514
+ export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
1515
+ export namespace symlink {
1516
+ /**
1517
+ * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
1518
+ * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
1519
+ * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
1520
+ * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
1521
+ * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
1522
+ */
1523
+ function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
1524
+ type Type = "dir" | "file" | "junction";
1525
+ }
1526
+ /**
1527
+ * Returns `undefined`.
1528
+ *
1529
+ * For detailed information, see the documentation of the asynchronous version of
1530
+ * this API: {@link symlink}.
1531
+ * @since v0.1.31
1532
+ * @param [type='null']
1533
+ */
1534
+ export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
1535
+ /**
1536
+ * Reads the contents of the symbolic link referred to by `path`. The callback gets
1537
+ * two arguments `(err, linkString)`.
1538
+ *
1539
+ * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.
1540
+ *
1541
+ * The optional `options` argument can be a string specifying an encoding, or an
1542
+ * object with an `encoding` property specifying the character encoding to use for
1543
+ * the link path passed to the callback. If the `encoding` is set to `'buffer'`,
1544
+ * the link path returned will be passed as a `Buffer` object.
1545
+ * @since v0.1.31
1546
+ */
1547
+ export function readlink(
1548
+ path: PathLike,
1549
+ options: EncodingOption,
1550
+ callback: (err: NodeJS.ErrnoException | null, linkString: string) => void,
1551
+ ): void;
1552
+ /**
1553
+ * Asynchronous readlink(2) - read value of a symbolic link.
1554
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1555
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1556
+ */
1557
+ export function readlink(
1558
+ path: PathLike,
1559
+ options: BufferEncodingOption,
1560
+ callback: (err: NodeJS.ErrnoException | null, linkString: NonSharedBuffer) => void,
1561
+ ): void;
1562
+ /**
1563
+ * Asynchronous readlink(2) - read value of a symbolic link.
1564
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1565
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1566
+ */
1567
+ export function readlink(
1568
+ path: PathLike,
1569
+ options: EncodingOption,
1570
+ callback: (err: NodeJS.ErrnoException | null, linkString: string | NonSharedBuffer) => void,
1571
+ ): void;
1572
+ /**
1573
+ * Asynchronous readlink(2) - read value of a symbolic link.
1574
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1575
+ */
1576
+ export function readlink(
1577
+ path: PathLike,
1578
+ callback: (err: NodeJS.ErrnoException | null, linkString: string) => void,
1579
+ ): void;
1580
+ export namespace readlink {
1581
+ /**
1582
+ * Asynchronous readlink(2) - read value of a symbolic link.
1583
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1584
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1585
+ */
1586
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
1587
+ /**
1588
+ * Asynchronous readlink(2) - read value of a symbolic link.
1589
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1590
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1591
+ */
1592
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1593
+ /**
1594
+ * Asynchronous readlink(2) - read value of a symbolic link.
1595
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1596
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1597
+ */
1598
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | NonSharedBuffer>;
1599
+ }
1600
+ /**
1601
+ * Returns the symbolic link's string value.
1602
+ *
1603
+ * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.
1604
+ *
1605
+ * The optional `options` argument can be a string specifying an encoding, or an
1606
+ * object with an `encoding` property specifying the character encoding to use for
1607
+ * the link path returned. If the `encoding` is set to `'buffer'`,
1608
+ * the link path returned will be passed as a `Buffer` object.
1609
+ * @since v0.1.31
1610
+ */
1611
+ export function readlinkSync(path: PathLike, options?: EncodingOption): string;
1612
+ /**
1613
+ * Synchronous readlink(2) - read value of a symbolic link.
1614
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1615
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1616
+ */
1617
+ export function readlinkSync(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1618
+ /**
1619
+ * Synchronous readlink(2) - read value of a symbolic link.
1620
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1621
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1622
+ */
1623
+ export function readlinkSync(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1624
+ /**
1625
+ * Asynchronously computes the canonical pathname by resolving `.`, `..`, and
1626
+ * symbolic links.
1627
+ *
1628
+ * A canonical pathname is not necessarily unique. Hard links and bind mounts can
1629
+ * expose a file system entity through many pathnames.
1630
+ *
1631
+ * This function behaves like [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html), with some exceptions:
1632
+ *
1633
+ * 1. No case conversion is performed on case-insensitive file systems.
1634
+ * 2. The maximum number of symbolic links is platform-independent and generally
1635
+ * (much) higher than what the native [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html) implementation supports.
1636
+ *
1637
+ * The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
1638
+ *
1639
+ * Only paths that can be converted to UTF8 strings are supported.
1640
+ *
1641
+ * The optional `options` argument can be a string specifying an encoding, or an
1642
+ * object with an `encoding` property specifying the character encoding to use for
1643
+ * the path passed to the callback. If the `encoding` is set to `'buffer'`,
1644
+ * the path returned will be passed as a `Buffer` object.
1645
+ *
1646
+ * If `path` resolves to a socket or a pipe, the function will return a system
1647
+ * dependent name for that object.
1648
+ * @since v0.1.31
1649
+ */
1650
+ export function realpath(
1651
+ path: PathLike,
1652
+ options: EncodingOption,
1653
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void,
1654
+ ): void;
1655
+ /**
1656
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1657
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1658
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1659
+ */
1660
+ export function realpath(
1661
+ path: PathLike,
1662
+ options: BufferEncodingOption,
1663
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: NonSharedBuffer) => void,
1664
+ ): void;
1665
+ /**
1666
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1667
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1668
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1669
+ */
1670
+ export function realpath(
1671
+ path: PathLike,
1672
+ options: EncodingOption,
1673
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | NonSharedBuffer) => void,
1674
+ ): void;
1675
+ /**
1676
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1677
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1678
+ */
1679
+ export function realpath(
1680
+ path: PathLike,
1681
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void,
1682
+ ): void;
1683
+ export namespace realpath {
1684
+ /**
1685
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1686
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1687
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1688
+ */
1689
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
1690
+ /**
1691
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1692
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1693
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1694
+ */
1695
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1696
+ /**
1697
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1698
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1699
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1700
+ */
1701
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | NonSharedBuffer>;
1702
+ /**
1703
+ * Asynchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html).
1704
+ *
1705
+ * The `callback` gets two arguments `(err, resolvedPath)`.
1706
+ *
1707
+ * Only paths that can be converted to UTF8 strings are supported.
1708
+ *
1709
+ * The optional `options` argument can be a string specifying an encoding, or an
1710
+ * object with an `encoding` property specifying the character encoding to use for
1711
+ * the path passed to the callback. If the `encoding` is set to `'buffer'`,
1712
+ * the path returned will be passed as a `Buffer` object.
1713
+ *
1714
+ * On Linux, when Node.js is linked against musl libc, the procfs file system must
1715
+ * be mounted on `/proc` in order for this function to work. Glibc does not have
1716
+ * this restriction.
1717
+ * @since v9.2.0
1718
+ */
1719
+ function native(
1720
+ path: PathLike,
1721
+ options: EncodingOption,
1722
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void,
1723
+ ): void;
1724
+ function native(
1725
+ path: PathLike,
1726
+ options: BufferEncodingOption,
1727
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: NonSharedBuffer) => void,
1728
+ ): void;
1729
+ function native(
1730
+ path: PathLike,
1731
+ options: EncodingOption,
1732
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | NonSharedBuffer) => void,
1733
+ ): void;
1734
+ function native(
1735
+ path: PathLike,
1736
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void,
1737
+ ): void;
1738
+ }
1739
+ /**
1740
+ * Returns the resolved pathname.
1741
+ *
1742
+ * For detailed information, see the documentation of the asynchronous version of
1743
+ * this API: {@link realpath}.
1744
+ * @since v0.1.31
1745
+ */
1746
+ export function realpathSync(path: PathLike, options?: EncodingOption): string;
1747
+ /**
1748
+ * Synchronous realpath(3) - return the canonicalized absolute pathname.
1749
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1750
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1751
+ */
1752
+ export function realpathSync(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1753
+ /**
1754
+ * Synchronous realpath(3) - return the canonicalized absolute pathname.
1755
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1756
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1757
+ */
1758
+ export function realpathSync(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1759
+ export namespace realpathSync {
1760
+ function native(path: PathLike, options?: EncodingOption): string;
1761
+ function native(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1762
+ function native(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1763
+ }
1764
+ /**
1765
+ * Asynchronously removes a file or symbolic link. No arguments other than a
1766
+ * possible exception are given to the completion callback.
1767
+ *
1768
+ * ```js
1769
+ * import { unlink } from 'node:fs';
1770
+ * // Assuming that 'path/file.txt' is a regular file.
1771
+ * unlink('path/file.txt', (err) => {
1772
+ * if (err) throw err;
1773
+ * console.log('path/file.txt was deleted');
1774
+ * });
1775
+ * ```
1776
+ *
1777
+ * `fs.unlink()` will not work on a directory, empty or otherwise. To remove a
1778
+ * directory, use {@link rmdir}.
1779
+ *
1780
+ * See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more details.
1781
+ * @since v0.0.2
1782
+ */
1783
+ export function unlink(path: PathLike, callback: NoParamCallback): void;
1784
+ export namespace unlink {
1785
+ /**
1786
+ * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
1787
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1788
+ */
1789
+ function __promisify__(path: PathLike): Promise<void>;
1790
+ }
1791
+ /**
1792
+ * Synchronous [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html). Returns `undefined`.
1793
+ * @since v0.1.21
1794
+ */
1795
+ export function unlinkSync(path: PathLike): void;
1796
+ export interface RmDirOptions {
1797
+ /**
1798
+ * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
1799
+ * `EPERM` error is encountered, Node.js will retry the operation with a linear
1800
+ * backoff wait of `retryDelay` ms longer on each try. This option represents the
1801
+ * number of retries. This option is ignored if the `recursive` option is not
1802
+ * `true`.
1803
+ * @default 0
1804
+ */
1805
+ maxRetries?: number | undefined;
1806
+ /**
1807
+ * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning
1808
+ * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file.
1809
+ * Use `fs.rm(path, { recursive: true, force: true })` instead.
1810
+ *
1811
+ * If `true`, perform a recursive directory removal. In
1812
+ * recursive mode, operations are retried on failure.
1813
+ * @default false
1814
+ */
1815
+ recursive?: boolean | undefined;
1816
+ /**
1817
+ * The amount of time in milliseconds to wait between retries.
1818
+ * This option is ignored if the `recursive` option is not `true`.
1819
+ * @default 100
1820
+ */
1821
+ retryDelay?: number | undefined;
1822
+ }
1823
+ /**
1824
+ * Asynchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). No arguments other than a possible exception are given
1825
+ * to the completion callback.
1826
+ *
1827
+ * Using `fs.rmdir()` on a file (not a directory) results in an `ENOENT` error on
1828
+ * Windows and an `ENOTDIR` error on POSIX.
1829
+ *
1830
+ * To get a behavior similar to the `rm -rf` Unix command, use {@link rm} with options `{ recursive: true, force: true }`.
1831
+ * @since v0.0.2
1832
+ */
1833
+ export function rmdir(path: PathLike, callback: NoParamCallback): void;
1834
+ export function rmdir(path: PathLike, options: RmDirOptions, callback: NoParamCallback): void;
1835
+ export namespace rmdir {
1836
+ /**
1837
+ * Asynchronous rmdir(2) - delete a directory.
1838
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1839
+ */
1840
+ function __promisify__(path: PathLike, options?: RmDirOptions): Promise<void>;
1841
+ }
1842
+ /**
1843
+ * Synchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). Returns `undefined`.
1844
+ *
1845
+ * Using `fs.rmdirSync()` on a file (not a directory) results in an `ENOENT` error
1846
+ * on Windows and an `ENOTDIR` error on POSIX.
1847
+ *
1848
+ * To get a behavior similar to the `rm -rf` Unix command, use {@link rmSync} with options `{ recursive: true, force: true }`.
1849
+ * @since v0.1.21
1850
+ */
1851
+ export function rmdirSync(path: PathLike, options?: RmDirOptions): void;
1852
+ export interface RmOptions {
1853
+ /**
1854
+ * When `true`, exceptions will be ignored if `path` does not exist.
1855
+ * @default false
1856
+ */
1857
+ force?: boolean | undefined;
1858
+ /**
1859
+ * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
1860
+ * `EPERM` error is encountered, Node.js will retry the operation with a linear
1861
+ * backoff wait of `retryDelay` ms longer on each try. This option represents the
1862
+ * number of retries. This option is ignored if the `recursive` option is not
1863
+ * `true`.
1864
+ * @default 0
1865
+ */
1866
+ maxRetries?: number | undefined;
1867
+ /**
1868
+ * If `true`, perform a recursive directory removal. In
1869
+ * recursive mode, operations are retried on failure.
1870
+ * @default false
1871
+ */
1872
+ recursive?: boolean | undefined;
1873
+ /**
1874
+ * The amount of time in milliseconds to wait between retries.
1875
+ * This option is ignored if the `recursive` option is not `true`.
1876
+ * @default 100
1877
+ */
1878
+ retryDelay?: number | undefined;
1879
+ }
1880
+ /**
1881
+ * Asynchronously removes files and directories (modeled on the standard POSIX `rm` utility). No arguments other than a possible exception are given to the
1882
+ * completion callback.
1883
+ * @since v14.14.0
1884
+ */
1885
+ export function rm(path: PathLike, callback: NoParamCallback): void;
1886
+ export function rm(path: PathLike, options: RmOptions, callback: NoParamCallback): void;
1887
+ export namespace rm {
1888
+ /**
1889
+ * Asynchronously removes files and directories (modeled on the standard POSIX `rm` utility).
1890
+ */
1891
+ function __promisify__(path: PathLike, options?: RmOptions): Promise<void>;
1892
+ }
1893
+ /**
1894
+ * Synchronously removes files and directories (modeled on the standard POSIX `rm` utility). Returns `undefined`.
1895
+ * @since v14.14.0
1896
+ */
1897
+ export function rmSync(path: PathLike, options?: RmOptions): void;
1898
+ export interface MakeDirectoryOptions {
1899
+ /**
1900
+ * Indicates whether parent folders should be created.
1901
+ * If a folder was created, the path to the first created folder will be returned.
1902
+ * @default false
1903
+ */
1904
+ recursive?: boolean | undefined;
1905
+ /**
1906
+ * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
1907
+ * @default 0o777
1908
+ */
1909
+ mode?: Mode | undefined;
1910
+ }
1911
+ /**
1912
+ * Asynchronously creates a directory.
1913
+ *
1914
+ * The callback is given a possible exception and, if `recursive` is `true`, the
1915
+ * first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was
1916
+ * created (for instance, if it was previously created).
1917
+ *
1918
+ * The optional `options` argument can be an integer specifying `mode` (permission
1919
+ * and sticky bits), or an object with a `mode` property and a `recursive` property indicating whether parent directories should be created. Calling `fs.mkdir()` when `path` is a directory that
1920
+ * exists results in an error only
1921
+ * when `recursive` is false. If `recursive` is false and the directory exists,
1922
+ * an `EEXIST` error occurs.
1923
+ *
1924
+ * ```js
1925
+ * import { mkdir } from 'node:fs';
1926
+ *
1927
+ * // Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.
1928
+ * mkdir('./tmp/a/apple', { recursive: true }, (err) => {
1929
+ * if (err) throw err;
1930
+ * });
1931
+ * ```
1932
+ *
1933
+ * On Windows, using `fs.mkdir()` on the root directory even with recursion will
1934
+ * result in an error:
1935
+ *
1936
+ * ```js
1937
+ * import { mkdir } from 'node:fs';
1938
+ *
1939
+ * mkdir('/', { recursive: true }, (err) => {
1940
+ * // => [Error: EPERM: operation not permitted, mkdir 'C:\']
1941
+ * });
1942
+ * ```
1943
+ *
1944
+ * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
1945
+ * @since v0.1.8
1946
+ */
1947
+ export function mkdir(
1948
+ path: PathLike,
1949
+ options: MakeDirectoryOptions & {
1950
+ recursive: true;
1951
+ },
1952
+ callback: (err: NodeJS.ErrnoException | null, path?: string) => void,
1953
+ ): void;
1954
+ /**
1955
+ * Asynchronous mkdir(2) - create a directory.
1956
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1957
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1958
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1959
+ */
1960
+ export function mkdir(
1961
+ path: PathLike,
1962
+ options:
1963
+ | Mode
1964
+ | (MakeDirectoryOptions & {
1965
+ recursive?: false | undefined;
1966
+ })
1967
+ | null
1968
+ | undefined,
1969
+ callback: NoParamCallback,
1970
+ ): void;
1971
+ /**
1972
+ * Asynchronous mkdir(2) - create a directory.
1973
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1974
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1975
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1976
+ */
1977
+ export function mkdir(
1978
+ path: PathLike,
1979
+ options: Mode | MakeDirectoryOptions | null | undefined,
1980
+ callback: (err: NodeJS.ErrnoException | null, path?: string) => void,
1981
+ ): void;
1982
+ /**
1983
+ * Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
1984
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1985
+ */
1986
+ export function mkdir(path: PathLike, callback: NoParamCallback): void;
1987
+ export namespace mkdir {
1988
+ /**
1989
+ * Asynchronous mkdir(2) - create a directory.
1990
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1991
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1992
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1993
+ */
1994
+ function __promisify__(
1995
+ path: PathLike,
1996
+ options: MakeDirectoryOptions & {
1997
+ recursive: true;
1998
+ },
1999
+ ): Promise<string | undefined>;
2000
+ /**
2001
+ * Asynchronous mkdir(2) - create a directory.
2002
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2003
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
2004
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
2005
+ */
2006
+ function __promisify__(
2007
+ path: PathLike,
2008
+ options?:
2009
+ | Mode
2010
+ | (MakeDirectoryOptions & {
2011
+ recursive?: false | undefined;
2012
+ })
2013
+ | null,
2014
+ ): Promise<void>;
2015
+ /**
2016
+ * Asynchronous mkdir(2) - create a directory.
2017
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2018
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
2019
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
2020
+ */
2021
+ function __promisify__(
2022
+ path: PathLike,
2023
+ options?: Mode | MakeDirectoryOptions | null,
2024
+ ): Promise<string | undefined>;
2025
+ }
2026
+ /**
2027
+ * Synchronously creates a directory. Returns `undefined`, or if `recursive` is `true`, the first directory path created.
2028
+ * This is the synchronous version of {@link mkdir}.
2029
+ *
2030
+ * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
2031
+ * @since v0.1.21
2032
+ */
2033
+ export function mkdirSync(
2034
+ path: PathLike,
2035
+ options: MakeDirectoryOptions & {
2036
+ recursive: true;
2037
+ },
2038
+ ): string | undefined;
2039
+ /**
2040
+ * Synchronous mkdir(2) - create a directory.
2041
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2042
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
2043
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
2044
+ */
2045
+ export function mkdirSync(
2046
+ path: PathLike,
2047
+ options?:
2048
+ | Mode
2049
+ | (MakeDirectoryOptions & {
2050
+ recursive?: false | undefined;
2051
+ })
2052
+ | null,
2053
+ ): void;
2054
+ /**
2055
+ * Synchronous mkdir(2) - create a directory.
2056
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2057
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
2058
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
2059
+ */
2060
+ export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined;
2061
+ /**
2062
+ * Creates a unique temporary directory.
2063
+ *
2064
+ * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory. Due to platform
2065
+ * inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms,
2066
+ * notably the BSDs, can return more than six random characters, and replace
2067
+ * trailing `X` characters in `prefix` with random characters.
2068
+ *
2069
+ * The created directory path is passed as a string to the callback's second
2070
+ * parameter.
2071
+ *
2072
+ * The optional `options` argument can be a string specifying an encoding, or an
2073
+ * object with an `encoding` property specifying the character encoding to use.
2074
+ *
2075
+ * ```js
2076
+ * import { mkdtemp } from 'node:fs';
2077
+ * import { join } from 'node:path';
2078
+ * import { tmpdir } from 'node:os';
2079
+ *
2080
+ * mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => {
2081
+ * if (err) throw err;
2082
+ * console.log(directory);
2083
+ * // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2
2084
+ * });
2085
+ * ```
2086
+ *
2087
+ * The `fs.mkdtemp()` method will append the six randomly selected characters
2088
+ * directly to the `prefix` string. For instance, given a directory `/tmp`, if the
2089
+ * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
2090
+ * (`import { sep } from 'node:path'`).
2091
+ *
2092
+ * ```js
2093
+ * import { tmpdir } from 'node:os';
2094
+ * import { mkdtemp } from 'node:fs';
2095
+ *
2096
+ * // The parent directory for the new temporary directory
2097
+ * const tmpDir = tmpdir();
2098
+ *
2099
+ * // This method is *INCORRECT*:
2100
+ * mkdtemp(tmpDir, (err, directory) => {
2101
+ * if (err) throw err;
2102
+ * console.log(directory);
2103
+ * // Will print something similar to `/tmpabc123`.
2104
+ * // A new temporary directory is created at the file system root
2105
+ * // rather than *within* the /tmp directory.
2106
+ * });
2107
+ *
2108
+ * // This method is *CORRECT*:
2109
+ * import { sep } from 'node:path';
2110
+ * mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
2111
+ * if (err) throw err;
2112
+ * console.log(directory);
2113
+ * // Will print something similar to `/tmp/abc123`.
2114
+ * // A new temporary directory is created within
2115
+ * // the /tmp directory.
2116
+ * });
2117
+ * ```
2118
+ * @since v5.10.0
2119
+ */
2120
+ export function mkdtemp(
2121
+ prefix: string,
2122
+ options: EncodingOption,
2123
+ callback: (err: NodeJS.ErrnoException | null, folder: string) => void,
2124
+ ): void;
2125
+ /**
2126
+ * Asynchronously creates a unique temporary directory.
2127
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2128
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2129
+ */
2130
+ export function mkdtemp(
2131
+ prefix: string,
2132
+ options: BufferEncodingOption,
2133
+ callback: (err: NodeJS.ErrnoException | null, folder: NonSharedBuffer) => void,
2134
+ ): void;
2135
+ /**
2136
+ * Asynchronously creates a unique temporary directory.
2137
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2138
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2139
+ */
2140
+ export function mkdtemp(
2141
+ prefix: string,
2142
+ options: EncodingOption,
2143
+ callback: (err: NodeJS.ErrnoException | null, folder: string | NonSharedBuffer) => void,
2144
+ ): void;
2145
+ /**
2146
+ * Asynchronously creates a unique temporary directory.
2147
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2148
+ */
2149
+ export function mkdtemp(
2150
+ prefix: string,
2151
+ callback: (err: NodeJS.ErrnoException | null, folder: string) => void,
2152
+ ): void;
2153
+ export namespace mkdtemp {
2154
+ /**
2155
+ * Asynchronously creates a unique temporary directory.
2156
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2157
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2158
+ */
2159
+ function __promisify__(prefix: string, options?: EncodingOption): Promise<string>;
2160
+ /**
2161
+ * Asynchronously creates a unique temporary directory.
2162
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2163
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2164
+ */
2165
+ function __promisify__(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
2166
+ /**
2167
+ * Asynchronously creates a unique temporary directory.
2168
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2169
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2170
+ */
2171
+ function __promisify__(prefix: string, options?: EncodingOption): Promise<string | NonSharedBuffer>;
2172
+ }
2173
+ /**
2174
+ * Returns the created directory path.
2175
+ *
2176
+ * For detailed information, see the documentation of the asynchronous version of
2177
+ * this API: {@link mkdtemp}.
2178
+ *
2179
+ * The optional `options` argument can be a string specifying an encoding, or an
2180
+ * object with an `encoding` property specifying the character encoding to use.
2181
+ * @since v5.10.0
2182
+ */
2183
+ export function mkdtempSync(prefix: string, options?: EncodingOption): string;
2184
+ /**
2185
+ * Synchronously creates a unique temporary directory.
2186
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2187
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2188
+ */
2189
+ export function mkdtempSync(prefix: string, options: BufferEncodingOption): NonSharedBuffer;
2190
+ /**
2191
+ * Synchronously creates a unique temporary directory.
2192
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2193
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2194
+ */
2195
+ export function mkdtempSync(prefix: string, options?: EncodingOption): string | NonSharedBuffer;
2196
+ export interface DisposableTempDir extends AsyncDisposable {
2197
+ /**
2198
+ * The path of the created directory.
2199
+ */
2200
+ path: string;
2201
+ /**
2202
+ * A function which removes the created directory.
2203
+ */
2204
+ remove(): Promise<void>;
2205
+ /**
2206
+ * The same as `remove`.
2207
+ */
2208
+ [Symbol.asyncDispose](): Promise<void>;
2209
+ }
2210
+ /**
2211
+ * Returns a disposable object whose `path` property holds the created directory
2212
+ * path. When the object is disposed, the directory and its contents will be
2213
+ * removed if it still exists. If the directory cannot be deleted, disposal will
2214
+ * throw an error. The object has a `remove()` method which will perform the same
2215
+ * task.
2216
+ *
2217
+ * <!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
2218
+ *
2219
+ * For detailed information, see the documentation of `fs.mkdtemp()`.
2220
+ *
2221
+ * There is no callback-based version of this API because it is designed for use
2222
+ * with the `using` syntax.
2223
+ *
2224
+ * The optional `options` argument can be a string specifying an encoding, or an
2225
+ * object with an `encoding` property specifying the character encoding to use.
2226
+ * @since v24.4.0
2227
+ */
2228
+ export function mkdtempDisposableSync(prefix: string, options?: EncodingOption): DisposableTempDir;
2229
+ /**
2230
+ * Reads the contents of a directory. The callback gets two arguments `(err, files)` where `files` is an array of the names of the files in the directory excluding `'.'` and `'..'`.
2231
+ *
2232
+ * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.
2233
+ *
2234
+ * The optional `options` argument can be a string specifying an encoding, or an
2235
+ * object with an `encoding` property specifying the character encoding to use for
2236
+ * the filenames passed to the callback. If the `encoding` is set to `'buffer'`,
2237
+ * the filenames returned will be passed as `Buffer` objects.
2238
+ *
2239
+ * If `options.withFileTypes` is set to `true`, the `files` array will contain `fs.Dirent` objects.
2240
+ * @since v0.1.8
2241
+ */
2242
+ export function readdir(
2243
+ path: PathLike,
2244
+ options:
2245
+ | {
2246
+ encoding: BufferEncoding | null;
2247
+ withFileTypes?: false | undefined;
2248
+ recursive?: boolean | undefined;
2249
+ }
2250
+ | BufferEncoding
2251
+ | undefined
2252
+ | null,
2253
+ callback: (err: NodeJS.ErrnoException | null, files: string[]) => void,
2254
+ ): void;
2255
+ /**
2256
+ * Asynchronous readdir(3) - read a directory.
2257
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2258
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2259
+ */
2260
+ export function readdir(
2261
+ path: PathLike,
2262
+ options:
2263
+ | {
2264
+ encoding: "buffer";
2265
+ withFileTypes?: false | undefined;
2266
+ recursive?: boolean | undefined;
2267
+ }
2268
+ | "buffer",
2269
+ callback: (err: NodeJS.ErrnoException | null, files: NonSharedBuffer[]) => void,
2270
+ ): void;
2271
+ /**
2272
+ * Asynchronous readdir(3) - read a directory.
2273
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2274
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2275
+ */
2276
+ export function readdir(
2277
+ path: PathLike,
2278
+ options:
2279
+ | (ObjectEncodingOptions & {
2280
+ withFileTypes?: false | undefined;
2281
+ recursive?: boolean | undefined;
2282
+ })
2283
+ | BufferEncoding
2284
+ | undefined
2285
+ | null,
2286
+ callback: (err: NodeJS.ErrnoException | null, files: string[] | NonSharedBuffer[]) => void,
2287
+ ): void;
2288
+ /**
2289
+ * Asynchronous readdir(3) - read a directory.
2290
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2291
+ */
2292
+ export function readdir(
2293
+ path: PathLike,
2294
+ callback: (err: NodeJS.ErrnoException | null, files: string[]) => void,
2295
+ ): void;
2296
+ /**
2297
+ * Asynchronous readdir(3) - read a directory.
2298
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2299
+ * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
2300
+ */
2301
+ export function readdir(
2302
+ path: PathLike,
2303
+ options: ObjectEncodingOptions & {
2304
+ withFileTypes: true;
2305
+ recursive?: boolean | undefined;
2306
+ },
2307
+ callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void,
2308
+ ): void;
2309
+ /**
2310
+ * Asynchronous readdir(3) - read a directory.
2311
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2312
+ * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
2313
+ */
2314
+ export function readdir(
2315
+ path: PathLike,
2316
+ options: {
2317
+ encoding: "buffer";
2318
+ withFileTypes: true;
2319
+ recursive?: boolean | undefined;
2320
+ },
2321
+ callback: (err: NodeJS.ErrnoException | null, files: Dirent<NonSharedBuffer>[]) => void,
2322
+ ): void;
2323
+ export namespace readdir {
2324
+ /**
2325
+ * Asynchronous readdir(3) - read a directory.
2326
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2327
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2328
+ */
2329
+ function __promisify__(
2330
+ path: PathLike,
2331
+ options?:
2332
+ | {
2333
+ encoding: BufferEncoding | null;
2334
+ withFileTypes?: false | undefined;
2335
+ recursive?: boolean | undefined;
2336
+ }
2337
+ | BufferEncoding
2338
+ | null,
2339
+ ): Promise<string[]>;
2340
+ /**
2341
+ * Asynchronous readdir(3) - read a directory.
2342
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2343
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2344
+ */
2345
+ function __promisify__(
2346
+ path: PathLike,
2347
+ options:
2348
+ | "buffer"
2349
+ | {
2350
+ encoding: "buffer";
2351
+ withFileTypes?: false | undefined;
2352
+ recursive?: boolean | undefined;
2353
+ },
2354
+ ): Promise<NonSharedBuffer[]>;
2355
+ /**
2356
+ * Asynchronous readdir(3) - read a directory.
2357
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2358
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2359
+ */
2360
+ function __promisify__(
2361
+ path: PathLike,
2362
+ options?:
2363
+ | (ObjectEncodingOptions & {
2364
+ withFileTypes?: false | undefined;
2365
+ recursive?: boolean | undefined;
2366
+ })
2367
+ | BufferEncoding
2368
+ | null,
2369
+ ): Promise<string[] | NonSharedBuffer[]>;
2370
+ /**
2371
+ * Asynchronous readdir(3) - read a directory.
2372
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2373
+ * @param options If called with `withFileTypes: true` the result data will be an array of Dirent
2374
+ */
2375
+ function __promisify__(
2376
+ path: PathLike,
2377
+ options: ObjectEncodingOptions & {
2378
+ withFileTypes: true;
2379
+ recursive?: boolean | undefined;
2380
+ },
2381
+ ): Promise<Dirent[]>;
2382
+ /**
2383
+ * Asynchronous readdir(3) - read a directory.
2384
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2385
+ * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
2386
+ */
2387
+ function __promisify__(
2388
+ path: PathLike,
2389
+ options: {
2390
+ encoding: "buffer";
2391
+ withFileTypes: true;
2392
+ recursive?: boolean | undefined;
2393
+ },
2394
+ ): Promise<Dirent<NonSharedBuffer>[]>;
2395
+ }
2396
+ /**
2397
+ * Reads the contents of the directory.
2398
+ *
2399
+ * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.
2400
+ *
2401
+ * The optional `options` argument can be a string specifying an encoding, or an
2402
+ * object with an `encoding` property specifying the character encoding to use for
2403
+ * the filenames returned. If the `encoding` is set to `'buffer'`,
2404
+ * the filenames returned will be passed as `Buffer` objects.
2405
+ *
2406
+ * If `options.withFileTypes` is set to `true`, the result will contain `fs.Dirent` objects.
2407
+ * @since v0.1.21
2408
+ */
2409
+ export function readdirSync(
2410
+ path: PathLike,
2411
+ options?:
2412
+ | {
2413
+ encoding: BufferEncoding | null;
2414
+ withFileTypes?: false | undefined;
2415
+ recursive?: boolean | undefined;
2416
+ }
2417
+ | BufferEncoding
2418
+ | null,
2419
+ ): string[];
2420
+ /**
2421
+ * Synchronous readdir(3) - read a directory.
2422
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2423
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2424
+ */
2425
+ export function readdirSync(
2426
+ path: PathLike,
2427
+ options:
2428
+ | {
2429
+ encoding: "buffer";
2430
+ withFileTypes?: false | undefined;
2431
+ recursive?: boolean | undefined;
2432
+ }
2433
+ | "buffer",
2434
+ ): NonSharedBuffer[];
2435
+ /**
2436
+ * Synchronous readdir(3) - read a directory.
2437
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2438
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2439
+ */
2440
+ export function readdirSync(
2441
+ path: PathLike,
2442
+ options?:
2443
+ | (ObjectEncodingOptions & {
2444
+ withFileTypes?: false | undefined;
2445
+ recursive?: boolean | undefined;
2446
+ })
2447
+ | BufferEncoding
2448
+ | null,
2449
+ ): string[] | NonSharedBuffer[];
2450
+ /**
2451
+ * Synchronous readdir(3) - read a directory.
2452
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2453
+ * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
2454
+ */
2455
+ export function readdirSync(
2456
+ path: PathLike,
2457
+ options: ObjectEncodingOptions & {
2458
+ withFileTypes: true;
2459
+ recursive?: boolean | undefined;
2460
+ },
2461
+ ): Dirent[];
2462
+ /**
2463
+ * Synchronous readdir(3) - read a directory.
2464
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2465
+ * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
2466
+ */
2467
+ export function readdirSync(
2468
+ path: PathLike,
2469
+ options: {
2470
+ encoding: "buffer";
2471
+ withFileTypes: true;
2472
+ recursive?: boolean | undefined;
2473
+ },
2474
+ ): Dirent<NonSharedBuffer>[];
2475
+ /**
2476
+ * Closes the file descriptor. No arguments other than a possible exception are
2477
+ * given to the completion callback.
2478
+ *
2479
+ * Calling `fs.close()` on any file descriptor (`fd`) that is currently in use
2480
+ * through any other `fs` operation may lead to undefined behavior.
2481
+ *
2482
+ * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.
2483
+ * @since v0.0.2
2484
+ */
2485
+ export function close(fd: number, callback?: NoParamCallback): void;
2486
+ export namespace close {
2487
+ /**
2488
+ * Asynchronous close(2) - close a file descriptor.
2489
+ * @param fd A file descriptor.
2490
+ */
2491
+ function __promisify__(fd: number): Promise<void>;
2492
+ }
2493
+ /**
2494
+ * Closes the file descriptor. Returns `undefined`.
2495
+ *
2496
+ * Calling `fs.closeSync()` on any file descriptor (`fd`) that is currently in use
2497
+ * through any other `fs` operation may lead to undefined behavior.
2498
+ *
2499
+ * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.
2500
+ * @since v0.1.21
2501
+ */
2502
+ export function closeSync(fd: number): void;
2503
+ /**
2504
+ * Asynchronous file open. See the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more details.
2505
+ *
2506
+ * `mode` sets the file mode (permission and sticky bits), but only if the file was
2507
+ * created. On Windows, only the write permission can be manipulated; see {@link chmod}.
2508
+ *
2509
+ * The callback gets two arguments `(err, fd)`.
2510
+ *
2511
+ * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
2512
+ * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
2513
+ * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
2514
+ *
2515
+ * Functions based on `fs.open()` exhibit this behavior as well:`fs.writeFile()`, `fs.readFile()`, etc.
2516
+ * @since v0.0.2
2517
+ * @param [flags='r'] See `support of file system `flags``.
2518
+ * @param [mode=0o666]
2519
+ */
2520
+ export function open(
2521
+ path: PathLike,
2522
+ flags: OpenMode | undefined,
2523
+ mode: Mode | undefined | null,
2524
+ callback: (err: NodeJS.ErrnoException | null, fd: number) => void,
2525
+ ): void;
2526
+ /**
2527
+ * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
2528
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2529
+ * @param [flags='r'] See `support of file system `flags``.
2530
+ */
2531
+ export function open(
2532
+ path: PathLike,
2533
+ flags: OpenMode | undefined,
2534
+ callback: (err: NodeJS.ErrnoException | null, fd: number) => void,
2535
+ ): void;
2536
+ /**
2537
+ * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
2538
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2539
+ */
2540
+ export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
2541
+ export namespace open {
2542
+ /**
2543
+ * Asynchronous open(2) - open and possibly create a file.
2544
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2545
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
2546
+ */
2547
+ function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise<number>;
2548
+ }
2549
+ /**
2550
+ * Returns an integer representing the file descriptor.
2551
+ *
2552
+ * For detailed information, see the documentation of the asynchronous version of
2553
+ * this API: {@link open}.
2554
+ * @since v0.1.21
2555
+ * @param [flags='r']
2556
+ * @param [mode=0o666]
2557
+ */
2558
+ export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number;
2559
+ /**
2560
+ * Change the file system timestamps of the object referenced by `path`.
2561
+ *
2562
+ * The `atime` and `mtime` arguments follow these rules:
2563
+ *
2564
+ * * Values can be either numbers representing Unix epoch time in seconds, `Date`s, or a numeric string like `'123456789.0'`.
2565
+ * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or `-Infinity`, an `Error` will be thrown.
2566
+ * @since v0.4.2
2567
+ */
2568
+ export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
2569
+ export namespace utimes {
2570
+ /**
2571
+ * Asynchronously change file timestamps of the file referenced by the supplied path.
2572
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2573
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
2574
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
2575
+ */
2576
+ function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
2577
+ }
2578
+ /**
2579
+ * Returns `undefined`.
2580
+ *
2581
+ * For detailed information, see the documentation of the asynchronous version of
2582
+ * this API: {@link utimes}.
2583
+ * @since v0.4.2
2584
+ */
2585
+ export function utimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
2586
+ /**
2587
+ * Change the file system timestamps of the object referenced by the supplied file
2588
+ * descriptor. See {@link utimes}.
2589
+ * @since v0.4.2
2590
+ */
2591
+ export function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
2592
+ export namespace futimes {
2593
+ /**
2594
+ * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
2595
+ * @param fd A file descriptor.
2596
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
2597
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
2598
+ */
2599
+ function __promisify__(fd: number, atime: TimeLike, mtime: TimeLike): Promise<void>;
2600
+ }
2601
+ /**
2602
+ * Synchronous version of {@link futimes}. Returns `undefined`.
2603
+ * @since v0.4.2
2604
+ */
2605
+ export function futimesSync(fd: number, atime: TimeLike, mtime: TimeLike): void;
2606
+ /**
2607
+ * Request that all data for the open file descriptor is flushed to the storage
2608
+ * device. The specific implementation is operating system and device specific.
2609
+ * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. No arguments other
2610
+ * than a possible exception are given to the completion callback.
2611
+ * @since v0.1.96
2612
+ */
2613
+ export function fsync(fd: number, callback: NoParamCallback): void;
2614
+ export namespace fsync {
2615
+ /**
2616
+ * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
2617
+ * @param fd A file descriptor.
2618
+ */
2619
+ function __promisify__(fd: number): Promise<void>;
2620
+ }
2621
+ /**
2622
+ * Request that all data for the open file descriptor is flushed to the storage
2623
+ * device. The specific implementation is operating system and device specific.
2624
+ * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. Returns `undefined`.
2625
+ * @since v0.1.96
2626
+ */
2627
+ export function fsyncSync(fd: number): void;
2628
+ export interface WriteOptions {
2629
+ /**
2630
+ * @default 0
2631
+ */
2632
+ offset?: number | undefined;
2633
+ /**
2634
+ * @default `buffer.byteLength - offset`
2635
+ */
2636
+ length?: number | undefined;
2637
+ /**
2638
+ * @default null
2639
+ */
2640
+ position?: number | null | undefined;
2641
+ }
2642
+ /**
2643
+ * Write `buffer` to the file specified by `fd`.
2644
+ *
2645
+ * `offset` determines the part of the buffer to be written, and `length` is
2646
+ * an integer specifying the number of bytes to write.
2647
+ *
2648
+ * `position` refers to the offset from the beginning of the file where this data
2649
+ * should be written. If `typeof position !== 'number'`, the data will be written
2650
+ * at the current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html).
2651
+ *
2652
+ * The callback will be given three arguments `(err, bytesWritten, buffer)` where `bytesWritten` specifies how many _bytes_ were written from `buffer`.
2653
+ *
2654
+ * If this method is invoked as its `util.promisify()` ed version, it returns
2655
+ * a promise for an `Object` with `bytesWritten` and `buffer` properties.
2656
+ *
2657
+ * It is unsafe to use `fs.write()` multiple times on the same file without waiting
2658
+ * for the callback. For this scenario, {@link createWriteStream} is
2659
+ * recommended.
2660
+ *
2661
+ * On Linux, positional writes don't work when the file is opened in append mode.
2662
+ * The kernel ignores the position argument and always appends the data to
2663
+ * the end of the file.
2664
+ * @since v0.0.2
2665
+ * @param [offset=0]
2666
+ * @param [length=buffer.byteLength - offset]
2667
+ * @param [position='null']
2668
+ */
2669
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(
2670
+ fd: number,
2671
+ buffer: TBuffer,
2672
+ offset: number | undefined | null,
2673
+ length: number | undefined | null,
2674
+ position: number | undefined | null,
2675
+ callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
2676
+ ): void;
2677
+ /**
2678
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2679
+ * @param fd A file descriptor.
2680
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
2681
+ * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
2682
+ */
2683
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(
2684
+ fd: number,
2685
+ buffer: TBuffer,
2686
+ offset: number | undefined | null,
2687
+ length: number | undefined | null,
2688
+ callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
2689
+ ): void;
2690
+ /**
2691
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2692
+ * @param fd A file descriptor.
2693
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
2694
+ */
2695
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(
2696
+ fd: number,
2697
+ buffer: TBuffer,
2698
+ offset: number | undefined | null,
2699
+ callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
2700
+ ): void;
2701
+ /**
2702
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2703
+ * @param fd A file descriptor.
2704
+ */
2705
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(
2706
+ fd: number,
2707
+ buffer: TBuffer,
2708
+ callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
2709
+ ): void;
2710
+ /**
2711
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2712
+ * @param fd A file descriptor.
2713
+ * @param options An object with the following properties:
2714
+ * * `offset` The part of the buffer to be written. If not supplied, defaults to `0`.
2715
+ * * `length` The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
2716
+ * * `position` The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2717
+ */
2718
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(
2719
+ fd: number,
2720
+ buffer: TBuffer,
2721
+ options: WriteOptions,
2722
+ callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
2723
+ ): void;
2724
+ /**
2725
+ * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
2726
+ * @param fd A file descriptor.
2727
+ * @param string A string to write.
2728
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2729
+ * @param encoding The expected string encoding.
2730
+ */
2731
+ export function write(
2732
+ fd: number,
2733
+ string: string,
2734
+ position: number | undefined | null,
2735
+ encoding: BufferEncoding | undefined | null,
2736
+ callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void,
2737
+ ): void;
2738
+ /**
2739
+ * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
2740
+ * @param fd A file descriptor.
2741
+ * @param string A string to write.
2742
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2743
+ */
2744
+ export function write(
2745
+ fd: number,
2746
+ string: string,
2747
+ position: number | undefined | null,
2748
+ callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void,
2749
+ ): void;
2750
+ /**
2751
+ * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
2752
+ * @param fd A file descriptor.
2753
+ * @param string A string to write.
2754
+ */
2755
+ export function write(
2756
+ fd: number,
2757
+ string: string,
2758
+ callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void,
2759
+ ): void;
2760
+ export namespace write {
2761
+ /**
2762
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2763
+ * @param fd A file descriptor.
2764
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
2765
+ * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
2766
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2767
+ */
2768
+ function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
2769
+ fd: number,
2770
+ buffer?: TBuffer,
2771
+ offset?: number,
2772
+ length?: number,
2773
+ position?: number | null,
2774
+ ): Promise<{
2775
+ bytesWritten: number;
2776
+ buffer: TBuffer;
2777
+ }>;
2778
+ /**
2779
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2780
+ * @param fd A file descriptor.
2781
+ * @param options An object with the following properties:
2782
+ * * `offset` The part of the buffer to be written. If not supplied, defaults to `0`.
2783
+ * * `length` The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
2784
+ * * `position` The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2785
+ */
2786
+ function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
2787
+ fd: number,
2788
+ buffer?: TBuffer,
2789
+ options?: WriteOptions,
2790
+ ): Promise<{
2791
+ bytesWritten: number;
2792
+ buffer: TBuffer;
2793
+ }>;
2794
+ /**
2795
+ * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
2796
+ * @param fd A file descriptor.
2797
+ * @param string A string to write.
2798
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2799
+ * @param encoding The expected string encoding.
2800
+ */
2801
+ function __promisify__(
2802
+ fd: number,
2803
+ string: string,
2804
+ position?: number | null,
2805
+ encoding?: BufferEncoding | null,
2806
+ ): Promise<{
2807
+ bytesWritten: number;
2808
+ buffer: string;
2809
+ }>;
2810
+ }
2811
+ /**
2812
+ * For detailed information, see the documentation of the asynchronous version of
2813
+ * this API: {@link write}.
2814
+ * @since v0.1.21
2815
+ * @param [offset=0]
2816
+ * @param [length=buffer.byteLength - offset]
2817
+ * @param [position='null']
2818
+ * @return The number of bytes written.
2819
+ */
2820
+ export function writeSync(
2821
+ fd: number,
2822
+ buffer: NodeJS.ArrayBufferView,
2823
+ offset?: number | null,
2824
+ length?: number | null,
2825
+ position?: number | null,
2826
+ ): number;
2827
+ /**
2828
+ * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
2829
+ * @param fd A file descriptor.
2830
+ * @param string A string to write.
2831
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2832
+ * @param encoding The expected string encoding.
2833
+ */
2834
+ export function writeSync(
2835
+ fd: number,
2836
+ string: string,
2837
+ position?: number | null,
2838
+ encoding?: BufferEncoding | null,
2839
+ ): number;
2840
+ export type ReadPosition = number | bigint;
2841
+ export interface ReadOptions {
2842
+ /**
2843
+ * @default 0
2844
+ */
2845
+ offset?: number | undefined;
2846
+ /**
2847
+ * @default `length of buffer`
2848
+ */
2849
+ length?: number | undefined;
2850
+ /**
2851
+ * @default null
2852
+ */
2853
+ position?: ReadPosition | null | undefined;
2854
+ }
2855
+ export interface ReadOptionsWithBuffer<T extends NodeJS.ArrayBufferView> extends ReadOptions {
2856
+ buffer?: T | undefined;
2857
+ }
2858
+ /** @deprecated Use `ReadOptions` instead. */
2859
+ // TODO: remove in future major
2860
+ export interface ReadSyncOptions extends ReadOptions {}
2861
+ /** @deprecated Use `ReadOptionsWithBuffer` instead. */
2862
+ // TODO: remove in future major
2863
+ export interface ReadAsyncOptions<T extends NodeJS.ArrayBufferView> extends ReadOptionsWithBuffer<T> {}
2864
+ /**
2865
+ * Read data from the file specified by `fd`.
2866
+ *
2867
+ * The callback is given the three arguments, `(err, bytesRead, buffer)`.
2868
+ *
2869
+ * If the file is not modified concurrently, the end-of-file is reached when the
2870
+ * number of bytes read is zero.
2871
+ *
2872
+ * If this method is invoked as its `util.promisify()` ed version, it returns
2873
+ * a promise for an `Object` with `bytesRead` and `buffer` properties.
2874
+ * @since v0.0.2
2875
+ * @param buffer The buffer that the data will be written to.
2876
+ * @param offset The position in `buffer` to write the data to.
2877
+ * @param length The number of bytes to read.
2878
+ * @param position Specifies where to begin reading from in the file. If `position` is `null` or `-1 `, data will be read from the current file position, and the file position will be updated. If
2879
+ * `position` is an integer, the file position will be unchanged.
2880
+ */
2881
+ export function read<TBuffer extends NodeJS.ArrayBufferView>(
2882
+ fd: number,
2883
+ buffer: TBuffer,
2884
+ offset: number,
2885
+ length: number,
2886
+ position: ReadPosition | null,
2887
+ callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
2888
+ ): void;
2889
+ /**
2890
+ * Similar to the above `fs.read` function, this version takes an optional `options` object.
2891
+ * If not otherwise specified in an `options` object,
2892
+ * `buffer` defaults to `Buffer.alloc(16384)`,
2893
+ * `offset` defaults to `0`,
2894
+ * `length` defaults to `buffer.byteLength`, `- offset` as of Node 17.6.0
2895
+ * `position` defaults to `null`
2896
+ * @since v12.17.0, 13.11.0
2897
+ */
2898
+ export function read<TBuffer extends NodeJS.ArrayBufferView = NonSharedBuffer>(
2899
+ fd: number,
2900
+ options: ReadOptionsWithBuffer<TBuffer>,
2901
+ callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
2902
+ ): void;
2903
+ export function read<TBuffer extends NodeJS.ArrayBufferView>(
2904
+ fd: number,
2905
+ buffer: TBuffer,
2906
+ options: ReadOptions,
2907
+ callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
2908
+ ): void;
2909
+ export function read<TBuffer extends NodeJS.ArrayBufferView>(
2910
+ fd: number,
2911
+ buffer: TBuffer,
2912
+ callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
2913
+ ): void;
2914
+ export function read(
2915
+ fd: number,
2916
+ callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NonSharedBuffer) => void,
2917
+ ): void;
2918
+ export namespace read {
2919
+ /**
2920
+ * @param fd A file descriptor.
2921
+ * @param buffer The buffer that the data will be written to.
2922
+ * @param offset The offset in the buffer at which to start writing.
2923
+ * @param length The number of bytes to read.
2924
+ * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
2925
+ */
2926
+ function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
2927
+ fd: number,
2928
+ buffer: TBuffer,
2929
+ offset: number,
2930
+ length: number,
2931
+ position: ReadPosition | null,
2932
+ ): Promise<{
2933
+ bytesRead: number;
2934
+ buffer: TBuffer;
2935
+ }>;
2936
+ function __promisify__<TBuffer extends NodeJS.ArrayBufferView = NonSharedBuffer>(
2937
+ fd: number,
2938
+ options: ReadOptionsWithBuffer<TBuffer>,
2939
+ ): Promise<{
2940
+ bytesRead: number;
2941
+ buffer: TBuffer;
2942
+ }>;
2943
+ function __promisify__(fd: number): Promise<{
2944
+ bytesRead: number;
2945
+ buffer: NonSharedBuffer;
2946
+ }>;
2947
+ }
2948
+ /**
2949
+ * Returns the number of `bytesRead`.
2950
+ *
2951
+ * For detailed information, see the documentation of the asynchronous version of
2952
+ * this API: {@link read}.
2953
+ * @since v0.1.21
2954
+ * @param [position='null']
2955
+ */
2956
+ export function readSync(
2957
+ fd: number,
2958
+ buffer: NodeJS.ArrayBufferView,
2959
+ offset: number,
2960
+ length: number,
2961
+ position: ReadPosition | null,
2962
+ ): number;
2963
+ /**
2964
+ * Similar to the above `fs.readSync` function, this version takes an optional `options` object.
2965
+ * If no `options` object is specified, it will default with the above values.
2966
+ */
2967
+ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadOptions): number;
2968
+ /**
2969
+ * Asynchronously reads the entire contents of a file.
2970
+ *
2971
+ * ```js
2972
+ * import { readFile } from 'node:fs';
2973
+ *
2974
+ * readFile('/etc/passwd', (err, data) => {
2975
+ * if (err) throw err;
2976
+ * console.log(data);
2977
+ * });
2978
+ * ```
2979
+ *
2980
+ * The callback is passed two arguments `(err, data)`, where `data` is the
2981
+ * contents of the file.
2982
+ *
2983
+ * If no encoding is specified, then the raw buffer is returned.
2984
+ *
2985
+ * If `options` is a string, then it specifies the encoding:
2986
+ *
2987
+ * ```js
2988
+ * import { readFile } from 'node:fs';
2989
+ *
2990
+ * readFile('/etc/passwd', 'utf8', callback);
2991
+ * ```
2992
+ *
2993
+ * When the path is a directory, the behavior of `fs.readFile()` and {@link readFileSync} is platform-specific. On macOS, Linux, and Windows, an
2994
+ * error will be returned. On FreeBSD, a representation of the directory's contents
2995
+ * will be returned.
2996
+ *
2997
+ * ```js
2998
+ * import { readFile } from 'node:fs';
2999
+ *
3000
+ * // macOS, Linux, and Windows
3001
+ * readFile('<directory>', (err, data) => {
3002
+ * // => [Error: EISDIR: illegal operation on a directory, read <directory>]
3003
+ * });
3004
+ *
3005
+ * // FreeBSD
3006
+ * readFile('<directory>', (err, data) => {
3007
+ * // => null, <data>
3008
+ * });
3009
+ * ```
3010
+ *
3011
+ * It is possible to abort an ongoing request using an `AbortSignal`. If a
3012
+ * request is aborted the callback is called with an `AbortError`:
3013
+ *
3014
+ * ```js
3015
+ * import { readFile } from 'node:fs';
3016
+ *
3017
+ * const controller = new AbortController();
3018
+ * const signal = controller.signal;
3019
+ * readFile(fileInfo[0].name, { signal }, (err, buf) => {
3020
+ * // ...
3021
+ * });
3022
+ * // When you want to abort the request
3023
+ * controller.abort();
3024
+ * ```
3025
+ *
3026
+ * The `fs.readFile()` function buffers the entire file. To minimize memory costs,
3027
+ * when possible prefer streaming via `fs.createReadStream()`.
3028
+ *
3029
+ * Aborting an ongoing request does not abort individual operating
3030
+ * system requests but rather the internal buffering `fs.readFile` performs.
3031
+ * @since v0.1.29
3032
+ * @param path filename or file descriptor
3033
+ */
3034
+ export function readFile(
3035
+ path: PathOrFileDescriptor,
3036
+ options:
3037
+ | ({
3038
+ encoding?: null | undefined;
3039
+ flag?: string | undefined;
3040
+ } & Abortable)
3041
+ | undefined
3042
+ | null,
3043
+ callback: (err: NodeJS.ErrnoException | null, data: NonSharedBuffer) => void,
3044
+ ): void;
3045
+ /**
3046
+ * Asynchronously reads the entire contents of a file.
3047
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3048
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3049
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
3050
+ * If a flag is not provided, it defaults to `'r'`.
3051
+ */
3052
+ export function readFile(
3053
+ path: PathOrFileDescriptor,
3054
+ options:
3055
+ | ({
3056
+ encoding: BufferEncoding;
3057
+ flag?: string | undefined;
3058
+ } & Abortable)
3059
+ | BufferEncoding,
3060
+ callback: (err: NodeJS.ErrnoException | null, data: string) => void,
3061
+ ): void;
3062
+ /**
3063
+ * Asynchronously reads the entire contents of a file.
3064
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3065
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3066
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
3067
+ * If a flag is not provided, it defaults to `'r'`.
3068
+ */
3069
+ export function readFile(
3070
+ path: PathOrFileDescriptor,
3071
+ options:
3072
+ | (ObjectEncodingOptions & {
3073
+ flag?: string | undefined;
3074
+ } & Abortable)
3075
+ | BufferEncoding
3076
+ | undefined
3077
+ | null,
3078
+ callback: (err: NodeJS.ErrnoException | null, data: string | NonSharedBuffer) => void,
3079
+ ): void;
3080
+ /**
3081
+ * Asynchronously reads the entire contents of a file.
3082
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3083
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3084
+ */
3085
+ export function readFile(
3086
+ path: PathOrFileDescriptor,
3087
+ callback: (err: NodeJS.ErrnoException | null, data: NonSharedBuffer) => void,
3088
+ ): void;
3089
+ export namespace readFile {
3090
+ /**
3091
+ * Asynchronously reads the entire contents of a file.
3092
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3093
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3094
+ * @param options An object that may contain an optional flag.
3095
+ * If a flag is not provided, it defaults to `'r'`.
3096
+ */
3097
+ function __promisify__(
3098
+ path: PathOrFileDescriptor,
3099
+ options?: {
3100
+ encoding?: null | undefined;
3101
+ flag?: string | undefined;
3102
+ } | null,
3103
+ ): Promise<NonSharedBuffer>;
3104
+ /**
3105
+ * Asynchronously reads the entire contents of a file.
3106
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3107
+ * URL support is _experimental_.
3108
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3109
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
3110
+ * If a flag is not provided, it defaults to `'r'`.
3111
+ */
3112
+ function __promisify__(
3113
+ path: PathOrFileDescriptor,
3114
+ options:
3115
+ | {
3116
+ encoding: BufferEncoding;
3117
+ flag?: string | undefined;
3118
+ }
3119
+ | BufferEncoding,
3120
+ ): Promise<string>;
3121
+ /**
3122
+ * Asynchronously reads the entire contents of a file.
3123
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3124
+ * URL support is _experimental_.
3125
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3126
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
3127
+ * If a flag is not provided, it defaults to `'r'`.
3128
+ */
3129
+ function __promisify__(
3130
+ path: PathOrFileDescriptor,
3131
+ options?:
3132
+ | (ObjectEncodingOptions & {
3133
+ flag?: string | undefined;
3134
+ })
3135
+ | BufferEncoding
3136
+ | null,
3137
+ ): Promise<string | NonSharedBuffer>;
3138
+ }
3139
+ /**
3140
+ * Returns the contents of the `path`.
3141
+ *
3142
+ * For detailed information, see the documentation of the asynchronous version of
3143
+ * this API: {@link readFile}.
3144
+ *
3145
+ * If the `encoding` option is specified then this function returns a
3146
+ * string. Otherwise it returns a buffer.
3147
+ *
3148
+ * Similar to {@link readFile}, when the path is a directory, the behavior of `fs.readFileSync()` is platform-specific.
3149
+ *
3150
+ * ```js
3151
+ * import { readFileSync } from 'node:fs';
3152
+ *
3153
+ * // macOS, Linux, and Windows
3154
+ * readFileSync('<directory>');
3155
+ * // => [Error: EISDIR: illegal operation on a directory, read <directory>]
3156
+ *
3157
+ * // FreeBSD
3158
+ * readFileSync('<directory>'); // => <data>
3159
+ * ```
3160
+ * @since v0.1.8
3161
+ * @param path filename or file descriptor
3162
+ */
3163
+ export function readFileSync(
3164
+ path: PathOrFileDescriptor,
3165
+ options?: {
3166
+ encoding?: null | undefined;
3167
+ flag?: string | undefined;
3168
+ } | null,
3169
+ ): NonSharedBuffer;
3170
+ /**
3171
+ * Synchronously reads the entire contents of a file.
3172
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3173
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3174
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
3175
+ * If a flag is not provided, it defaults to `'r'`.
3176
+ */
3177
+ export function readFileSync(
3178
+ path: PathOrFileDescriptor,
3179
+ options:
3180
+ | {
3181
+ encoding: BufferEncoding;
3182
+ flag?: string | undefined;
3183
+ }
3184
+ | BufferEncoding,
3185
+ ): string;
3186
+ /**
3187
+ * Synchronously reads the entire contents of a file.
3188
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3189
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3190
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
3191
+ * If a flag is not provided, it defaults to `'r'`.
3192
+ */
3193
+ export function readFileSync(
3194
+ path: PathOrFileDescriptor,
3195
+ options?:
3196
+ | (ObjectEncodingOptions & {
3197
+ flag?: string | undefined;
3198
+ })
3199
+ | BufferEncoding
3200
+ | null,
3201
+ ): string | NonSharedBuffer;
3202
+ export type WriteFileOptions =
3203
+ | (
3204
+ & ObjectEncodingOptions
3205
+ & Abortable
3206
+ & {
3207
+ mode?: Mode | undefined;
3208
+ flag?: string | undefined;
3209
+ flush?: boolean | undefined;
3210
+ }
3211
+ )
3212
+ | BufferEncoding
3213
+ | null;
3214
+ /**
3215
+ * When `file` is a filename, asynchronously writes data to the file, replacing the
3216
+ * file if it already exists. `data` can be a string or a buffer.
3217
+ *
3218
+ * When `file` is a file descriptor, the behavior is similar to calling `fs.write()` directly (which is recommended). See the notes below on using
3219
+ * a file descriptor.
3220
+ *
3221
+ * The `encoding` option is ignored if `data` is a buffer.
3222
+ *
3223
+ * The `mode` option only affects the newly created file. See {@link open} for more details.
3224
+ *
3225
+ * ```js
3226
+ * import { writeFile } from 'node:fs';
3227
+ * import { Buffer } from 'node:buffer';
3228
+ *
3229
+ * const data = new Uint8Array(Buffer.from('Hello Node.js'));
3230
+ * writeFile('message.txt', data, (err) => {
3231
+ * if (err) throw err;
3232
+ * console.log('The file has been saved!');
3233
+ * });
3234
+ * ```
3235
+ *
3236
+ * If `options` is a string, then it specifies the encoding:
3237
+ *
3238
+ * ```js
3239
+ * import { writeFile } from 'node:fs';
3240
+ *
3241
+ * writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
3242
+ * ```
3243
+ *
3244
+ * It is unsafe to use `fs.writeFile()` multiple times on the same file without
3245
+ * waiting for the callback. For this scenario, {@link createWriteStream} is
3246
+ * recommended.
3247
+ *
3248
+ * Similarly to `fs.readFile` \- `fs.writeFile` is a convenience method that
3249
+ * performs multiple `write` calls internally to write the buffer passed to it.
3250
+ * For performance sensitive code consider using {@link createWriteStream}.
3251
+ *
3252
+ * It is possible to use an `AbortSignal` to cancel an `fs.writeFile()`.
3253
+ * Cancelation is "best effort", and some amount of data is likely still
3254
+ * to be written.
3255
+ *
3256
+ * ```js
3257
+ * import { writeFile } from 'node:fs';
3258
+ * import { Buffer } from 'node:buffer';
3259
+ *
3260
+ * const controller = new AbortController();
3261
+ * const { signal } = controller;
3262
+ * const data = new Uint8Array(Buffer.from('Hello Node.js'));
3263
+ * writeFile('message.txt', data, { signal }, (err) => {
3264
+ * // When a request is aborted - the callback is called with an AbortError
3265
+ * });
3266
+ * // When the request should be aborted
3267
+ * controller.abort();
3268
+ * ```
3269
+ *
3270
+ * Aborting an ongoing request does not abort individual operating
3271
+ * system requests but rather the internal buffering `fs.writeFile` performs.
3272
+ * @since v0.1.29
3273
+ * @param file filename or file descriptor
3274
+ */
3275
+ export function writeFile(
3276
+ file: PathOrFileDescriptor,
3277
+ data: string | NodeJS.ArrayBufferView,
3278
+ options: WriteFileOptions,
3279
+ callback: NoParamCallback,
3280
+ ): void;
3281
+ /**
3282
+ * Asynchronously writes data to a file, replacing the file if it already exists.
3283
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3284
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3285
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
3286
+ */
3287
+ export function writeFile(
3288
+ path: PathOrFileDescriptor,
3289
+ data: string | NodeJS.ArrayBufferView,
3290
+ callback: NoParamCallback,
3291
+ ): void;
3292
+ export namespace writeFile {
3293
+ /**
3294
+ * Asynchronously writes data to a file, replacing the file if it already exists.
3295
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3296
+ * URL support is _experimental_.
3297
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3298
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
3299
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
3300
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
3301
+ * If `mode` is not supplied, the default of `0o666` is used.
3302
+ * If `mode` is a string, it is parsed as an octal integer.
3303
+ * If `flag` is not supplied, the default of `'w'` is used.
3304
+ */
3305
+ function __promisify__(
3306
+ path: PathOrFileDescriptor,
3307
+ data: string | NodeJS.ArrayBufferView,
3308
+ options?: WriteFileOptions,
3309
+ ): Promise<void>;
3310
+ }
3311
+ /**
3312
+ * Returns `undefined`.
3313
+ *
3314
+ * The `mode` option only affects the newly created file. See {@link open} for more details.
3315
+ *
3316
+ * For detailed information, see the documentation of the asynchronous version of
3317
+ * this API: {@link writeFile}.
3318
+ * @since v0.1.29
3319
+ * @param file filename or file descriptor
3320
+ */
3321
+ export function writeFileSync(
3322
+ file: PathOrFileDescriptor,
3323
+ data: string | NodeJS.ArrayBufferView,
3324
+ options?: WriteFileOptions,
3325
+ ): void;
3326
+ /**
3327
+ * Asynchronously append data to a file, creating the file if it does not yet
3328
+ * exist. `data` can be a string or a `Buffer`.
3329
+ *
3330
+ * The `mode` option only affects the newly created file. See {@link open} for more details.
3331
+ *
3332
+ * ```js
3333
+ * import { appendFile } from 'node:fs';
3334
+ *
3335
+ * appendFile('message.txt', 'data to append', (err) => {
3336
+ * if (err) throw err;
3337
+ * console.log('The "data to append" was appended to file!');
3338
+ * });
3339
+ * ```
3340
+ *
3341
+ * If `options` is a string, then it specifies the encoding:
3342
+ *
3343
+ * ```js
3344
+ * import { appendFile } from 'node:fs';
3345
+ *
3346
+ * appendFile('message.txt', 'data to append', 'utf8', callback);
3347
+ * ```
3348
+ *
3349
+ * The `path` may be specified as a numeric file descriptor that has been opened
3350
+ * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
3351
+ * not be closed automatically.
3352
+ *
3353
+ * ```js
3354
+ * import { open, close, appendFile } from 'node:fs';
3355
+ *
3356
+ * function closeFd(fd) {
3357
+ * close(fd, (err) => {
3358
+ * if (err) throw err;
3359
+ * });
3360
+ * }
3361
+ *
3362
+ * open('message.txt', 'a', (err, fd) => {
3363
+ * if (err) throw err;
3364
+ *
3365
+ * try {
3366
+ * appendFile(fd, 'data to append', 'utf8', (err) => {
3367
+ * closeFd(fd);
3368
+ * if (err) throw err;
3369
+ * });
3370
+ * } catch (err) {
3371
+ * closeFd(fd);
3372
+ * throw err;
3373
+ * }
3374
+ * });
3375
+ * ```
3376
+ * @since v0.6.7
3377
+ * @param path filename or file descriptor
3378
+ */
3379
+ export function appendFile(
3380
+ path: PathOrFileDescriptor,
3381
+ data: string | Uint8Array,
3382
+ options: WriteFileOptions,
3383
+ callback: NoParamCallback,
3384
+ ): void;
3385
+ /**
3386
+ * Asynchronously append data to a file, creating the file if it does not exist.
3387
+ * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
3388
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3389
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
3390
+ */
3391
+ export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void;
3392
+ export namespace appendFile {
3393
+ /**
3394
+ * Asynchronously append data to a file, creating the file if it does not exist.
3395
+ * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
3396
+ * URL support is _experimental_.
3397
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
3398
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
3399
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
3400
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
3401
+ * If `mode` is not supplied, the default of `0o666` is used.
3402
+ * If `mode` is a string, it is parsed as an octal integer.
3403
+ * If `flag` is not supplied, the default of `'a'` is used.
3404
+ */
3405
+ function __promisify__(
3406
+ file: PathOrFileDescriptor,
3407
+ data: string | Uint8Array,
3408
+ options?: WriteFileOptions,
3409
+ ): Promise<void>;
3410
+ }
3411
+ /**
3412
+ * Synchronously append data to a file, creating the file if it does not yet
3413
+ * exist. `data` can be a string or a `Buffer`.
3414
+ *
3415
+ * The `mode` option only affects the newly created file. See {@link open} for more details.
3416
+ *
3417
+ * ```js
3418
+ * import { appendFileSync } from 'node:fs';
3419
+ *
3420
+ * try {
3421
+ * appendFileSync('message.txt', 'data to append');
3422
+ * console.log('The "data to append" was appended to file!');
3423
+ * } catch (err) {
3424
+ * // Handle the error
3425
+ * }
3426
+ * ```
3427
+ *
3428
+ * If `options` is a string, then it specifies the encoding:
3429
+ *
3430
+ * ```js
3431
+ * import { appendFileSync } from 'node:fs';
3432
+ *
3433
+ * appendFileSync('message.txt', 'data to append', 'utf8');
3434
+ * ```
3435
+ *
3436
+ * The `path` may be specified as a numeric file descriptor that has been opened
3437
+ * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
3438
+ * not be closed automatically.
3439
+ *
3440
+ * ```js
3441
+ * import { openSync, closeSync, appendFileSync } from 'node:fs';
3442
+ *
3443
+ * let fd;
3444
+ *
3445
+ * try {
3446
+ * fd = openSync('message.txt', 'a');
3447
+ * appendFileSync(fd, 'data to append', 'utf8');
3448
+ * } catch (err) {
3449
+ * // Handle the error
3450
+ * } finally {
3451
+ * if (fd !== undefined)
3452
+ * closeSync(fd);
3453
+ * }
3454
+ * ```
3455
+ * @since v0.6.7
3456
+ * @param path filename or file descriptor
3457
+ */
3458
+ export function appendFileSync(
3459
+ path: PathOrFileDescriptor,
3460
+ data: string | Uint8Array,
3461
+ options?: WriteFileOptions,
3462
+ ): void;
3463
+ /**
3464
+ * Watch for changes on `filename`. The callback `listener` will be called each
3465
+ * time the file is accessed.
3466
+ *
3467
+ * The `options` argument may be omitted. If provided, it should be an object. The `options` object may contain a boolean named `persistent` that indicates
3468
+ * whether the process should continue to run as long as files are being watched.
3469
+ * The `options` object may specify an `interval` property indicating how often the
3470
+ * target should be polled in milliseconds.
3471
+ *
3472
+ * The `listener` gets two arguments the current stat object and the previous
3473
+ * stat object:
3474
+ *
3475
+ * ```js
3476
+ * import { watchFile } from 'node:fs';
3477
+ *
3478
+ * watchFile('message.text', (curr, prev) => {
3479
+ * console.log(`the current mtime is: ${curr.mtime}`);
3480
+ * console.log(`the previous mtime was: ${prev.mtime}`);
3481
+ * });
3482
+ * ```
3483
+ *
3484
+ * These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`,
3485
+ * the numeric values in these objects are specified as `BigInt`s.
3486
+ *
3487
+ * To be notified when the file was modified, not just accessed, it is necessary
3488
+ * to compare `curr.mtimeMs` and `prev.mtimeMs`.
3489
+ *
3490
+ * When an `fs.watchFile` operation results in an `ENOENT` error, it
3491
+ * will invoke the listener once, with all the fields zeroed (or, for dates, the
3492
+ * Unix Epoch). If the file is created later on, the listener will be called
3493
+ * again, with the latest stat objects. This is a change in functionality since
3494
+ * v0.10.
3495
+ *
3496
+ * Using {@link watch} is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible.
3497
+ *
3498
+ * When a file being watched by `fs.watchFile()` disappears and reappears,
3499
+ * then the contents of `previous` in the second callback event (the file's
3500
+ * reappearance) will be the same as the contents of `previous` in the first
3501
+ * callback event (its disappearance).
3502
+ *
3503
+ * This happens when:
3504
+ *
3505
+ * * the file is deleted, followed by a restore
3506
+ * * the file is renamed and then renamed a second time back to its original name
3507
+ * @since v0.1.31
3508
+ */
3509
+ export interface WatchFileOptions {
3510
+ bigint?: boolean | undefined;
3511
+ persistent?: boolean | undefined;
3512
+ interval?: number | undefined;
3513
+ }
3514
+ /**
3515
+ * Watch for changes on `filename`. The callback `listener` will be called each
3516
+ * time the file is accessed.
3517
+ *
3518
+ * The `options` argument may be omitted. If provided, it should be an object. The `options` object may contain a boolean named `persistent` that indicates
3519
+ * whether the process should continue to run as long as files are being watched.
3520
+ * The `options` object may specify an `interval` property indicating how often the
3521
+ * target should be polled in milliseconds.
3522
+ *
3523
+ * The `listener` gets two arguments the current stat object and the previous
3524
+ * stat object:
3525
+ *
3526
+ * ```js
3527
+ * import { watchFile } from 'node:fs';
3528
+ *
3529
+ * watchFile('message.text', (curr, prev) => {
3530
+ * console.log(`the current mtime is: ${curr.mtime}`);
3531
+ * console.log(`the previous mtime was: ${prev.mtime}`);
3532
+ * });
3533
+ * ```
3534
+ *
3535
+ * These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`,
3536
+ * the numeric values in these objects are specified as `BigInt`s.
3537
+ *
3538
+ * To be notified when the file was modified, not just accessed, it is necessary
3539
+ * to compare `curr.mtimeMs` and `prev.mtimeMs`.
3540
+ *
3541
+ * When an `fs.watchFile` operation results in an `ENOENT` error, it
3542
+ * will invoke the listener once, with all the fields zeroed (or, for dates, the
3543
+ * Unix Epoch). If the file is created later on, the listener will be called
3544
+ * again, with the latest stat objects. This is a change in functionality since
3545
+ * v0.10.
3546
+ *
3547
+ * Using {@link watch} is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible.
3548
+ *
3549
+ * When a file being watched by `fs.watchFile()` disappears and reappears,
3550
+ * then the contents of `previous` in the second callback event (the file's
3551
+ * reappearance) will be the same as the contents of `previous` in the first
3552
+ * callback event (its disappearance).
3553
+ *
3554
+ * This happens when:
3555
+ *
3556
+ * * the file is deleted, followed by a restore
3557
+ * * the file is renamed and then renamed a second time back to its original name
3558
+ * @since v0.1.31
3559
+ */
3560
+ export function watchFile(
3561
+ filename: PathLike,
3562
+ options:
3563
+ | (WatchFileOptions & {
3564
+ bigint?: false | undefined;
3565
+ })
3566
+ | undefined,
3567
+ listener: StatsListener,
3568
+ ): StatWatcher;
3569
+ export function watchFile(
3570
+ filename: PathLike,
3571
+ options:
3572
+ | (WatchFileOptions & {
3573
+ bigint: true;
3574
+ })
3575
+ | undefined,
3576
+ listener: BigIntStatsListener,
3577
+ ): StatWatcher;
3578
+ /**
3579
+ * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
3580
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3581
+ */
3582
+ export function watchFile(filename: PathLike, listener: StatsListener): StatWatcher;
3583
+ /**
3584
+ * Stop watching for changes on `filename`. If `listener` is specified, only that
3585
+ * particular listener is removed. Otherwise, _all_ listeners are removed,
3586
+ * effectively stopping watching of `filename`.
3587
+ *
3588
+ * Calling `fs.unwatchFile()` with a filename that is not being watched is a
3589
+ * no-op, not an error.
3590
+ *
3591
+ * Using {@link watch} is more efficient than `fs.watchFile()` and `fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()` and `fs.unwatchFile()` when possible.
3592
+ * @since v0.1.31
3593
+ * @param listener Optional, a listener previously attached using `fs.watchFile()`
3594
+ */
3595
+ export function unwatchFile(filename: PathLike, listener?: StatsListener): void;
3596
+ export function unwatchFile(filename: PathLike, listener?: BigIntStatsListener): void;
3597
+ export interface WatchOptions extends Abortable {
3598
+ encoding?: BufferEncoding | "buffer" | undefined;
3599
+ persistent?: boolean | undefined;
3600
+ recursive?: boolean | undefined;
3601
+ }
3602
+ export interface WatchOptionsWithBufferEncoding extends WatchOptions {
3603
+ encoding: "buffer";
3604
+ }
3605
+ export interface WatchOptionsWithStringEncoding extends WatchOptions {
3606
+ encoding?: BufferEncoding | undefined;
3607
+ }
3608
+ export type WatchEventType = "rename" | "change";
3609
+ export type WatchListener<T> = (event: WatchEventType, filename: T | null) => void;
3610
+ export type StatsListener = (curr: Stats, prev: Stats) => void;
3611
+ export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void;
3612
+ /**
3613
+ * Watch for changes on `filename`, where `filename` is either a file or a
3614
+ * directory.
3615
+ *
3616
+ * The second argument is optional. If `options` is provided as a string, it
3617
+ * specifies the `encoding`. Otherwise `options` should be passed as an object.
3618
+ *
3619
+ * The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'` or `'change'`, and `filename` is the name of the file
3620
+ * which triggered the event.
3621
+ *
3622
+ * On most platforms, `'rename'` is emitted whenever a filename appears or
3623
+ * disappears in the directory.
3624
+ *
3625
+ * The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of `eventType`.
3626
+ *
3627
+ * If a `signal` is passed, aborting the corresponding AbortController will close
3628
+ * the returned `fs.FSWatcher`.
3629
+ * @since v0.5.10
3630
+ * @param listener
3631
+ */
3632
+ export function watch(
3633
+ filename: PathLike,
3634
+ options?: WatchOptionsWithStringEncoding | BufferEncoding | null,
3635
+ listener?: WatchListener<string>,
3636
+ ): FSWatcher;
3637
+ export function watch(
3638
+ filename: PathLike,
3639
+ options: WatchOptionsWithBufferEncoding | "buffer",
3640
+ listener: WatchListener<NonSharedBuffer>,
3641
+ ): FSWatcher;
3642
+ export function watch(
3643
+ filename: PathLike,
3644
+ options: WatchOptions | BufferEncoding | "buffer" | null,
3645
+ listener: WatchListener<string | NonSharedBuffer>,
3646
+ ): FSWatcher;
3647
+ export function watch(filename: PathLike, listener: WatchListener<string>): FSWatcher;
3648
+ /**
3649
+ * Test whether or not the given path exists by checking with the file system.
3650
+ * Then call the `callback` argument with either true or false:
3651
+ *
3652
+ * ```js
3653
+ * import { exists } from 'node:fs';
3654
+ *
3655
+ * exists('/etc/passwd', (e) => {
3656
+ * console.log(e ? 'it exists' : 'no passwd!');
3657
+ * });
3658
+ * ```
3659
+ *
3660
+ * **The parameters for this callback are not consistent with other Node.js**
3661
+ * **callbacks.** Normally, the first parameter to a Node.js callback is an `err` parameter, optionally followed by other parameters. The `fs.exists()` callback
3662
+ * has only one boolean parameter. This is one reason `fs.access()` is recommended
3663
+ * instead of `fs.exists()`.
3664
+ *
3665
+ * Using `fs.exists()` to check for the existence of a file before calling `fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing
3666
+ * so introduces a race condition, since other processes may change the file's
3667
+ * state between the two calls. Instead, user code should open/read/write the
3668
+ * file directly and handle the error raised if the file does not exist.
3669
+ *
3670
+ * **write (NOT RECOMMENDED)**
3671
+ *
3672
+ * ```js
3673
+ * import { exists, open, close } from 'node:fs';
3674
+ *
3675
+ * exists('myfile', (e) => {
3676
+ * if (e) {
3677
+ * console.error('myfile already exists');
3678
+ * } else {
3679
+ * open('myfile', 'wx', (err, fd) => {
3680
+ * if (err) throw err;
3681
+ *
3682
+ * try {
3683
+ * writeMyData(fd);
3684
+ * } finally {
3685
+ * close(fd, (err) => {
3686
+ * if (err) throw err;
3687
+ * });
3688
+ * }
3689
+ * });
3690
+ * }
3691
+ * });
3692
+ * ```
3693
+ *
3694
+ * **write (RECOMMENDED)**
3695
+ *
3696
+ * ```js
3697
+ * import { open, close } from 'node:fs';
3698
+ * open('myfile', 'wx', (err, fd) => {
3699
+ * if (err) {
3700
+ * if (err.code === 'EEXIST') {
3701
+ * console.error('myfile already exists');
3702
+ * return;
3703
+ * }
3704
+ *
3705
+ * throw err;
3706
+ * }
3707
+ *
3708
+ * try {
3709
+ * writeMyData(fd);
3710
+ * } finally {
3711
+ * close(fd, (err) => {
3712
+ * if (err) throw err;
3713
+ * });
3714
+ * }
3715
+ * });
3716
+ * ```
3717
+ *
3718
+ * **read (NOT RECOMMENDED)**
3719
+ *
3720
+ * ```js
3721
+ * import { open, close, exists } from 'node:fs';
3722
+ *
3723
+ * exists('myfile', (e) => {
3724
+ * if (e) {
3725
+ * open('myfile', 'r', (err, fd) => {
3726
+ * if (err) throw err;
3727
+ *
3728
+ * try {
3729
+ * readMyData(fd);
3730
+ * } finally {
3731
+ * close(fd, (err) => {
3732
+ * if (err) throw err;
3733
+ * });
3734
+ * }
3735
+ * });
3736
+ * } else {
3737
+ * console.error('myfile does not exist');
3738
+ * }
3739
+ * });
3740
+ * ```
3741
+ *
3742
+ * **read (RECOMMENDED)**
3743
+ *
3744
+ * ```js
3745
+ * import { open, close } from 'node:fs';
3746
+ *
3747
+ * open('myfile', 'r', (err, fd) => {
3748
+ * if (err) {
3749
+ * if (err.code === 'ENOENT') {
3750
+ * console.error('myfile does not exist');
3751
+ * return;
3752
+ * }
3753
+ *
3754
+ * throw err;
3755
+ * }
3756
+ *
3757
+ * try {
3758
+ * readMyData(fd);
3759
+ * } finally {
3760
+ * close(fd, (err) => {
3761
+ * if (err) throw err;
3762
+ * });
3763
+ * }
3764
+ * });
3765
+ * ```
3766
+ *
3767
+ * The "not recommended" examples above check for existence and then use the
3768
+ * file; the "recommended" examples are better because they use the file directly
3769
+ * and handle the error, if any.
3770
+ *
3771
+ * In general, check for the existence of a file only if the file won't be
3772
+ * used directly, for example when its existence is a signal from another
3773
+ * process.
3774
+ * @since v0.0.2
3775
+ * @deprecated Since v1.0.0 - Use {@link stat} or {@link access} instead.
3776
+ */
3777
+ export function exists(path: PathLike, callback: (exists: boolean) => void): void;
3778
+ /** @deprecated */
3779
+ export namespace exists {
3780
+ /**
3781
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3782
+ * URL support is _experimental_.
3783
+ */
3784
+ function __promisify__(path: PathLike): Promise<boolean>;
3785
+ }
3786
+ /**
3787
+ * Returns `true` if the path exists, `false` otherwise.
3788
+ *
3789
+ * For detailed information, see the documentation of the asynchronous version of
3790
+ * this API: {@link exists}.
3791
+ *
3792
+ * `fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback` parameter to `fs.exists()` accepts parameters that are inconsistent with other
3793
+ * Node.js callbacks. `fs.existsSync()` does not use a callback.
3794
+ *
3795
+ * ```js
3796
+ * import { existsSync } from 'node:fs';
3797
+ *
3798
+ * if (existsSync('/etc/passwd'))
3799
+ * console.log('The path exists.');
3800
+ * ```
3801
+ * @since v0.1.21
3802
+ */
3803
+ export function existsSync(path: PathLike): boolean;
3804
+ export namespace constants {
3805
+ // File Access Constants
3806
+ /** Constant for fs.access(). File is visible to the calling process. */
3807
+ const F_OK: number;
3808
+ /** Constant for fs.access(). File can be read by the calling process. */
3809
+ const R_OK: number;
3810
+ /** Constant for fs.access(). File can be written by the calling process. */
3811
+ const W_OK: number;
3812
+ /** Constant for fs.access(). File can be executed by the calling process. */
3813
+ const X_OK: number;
3814
+ // File Copy Constants
3815
+ /** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
3816
+ const COPYFILE_EXCL: number;
3817
+ /**
3818
+ * Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink.
3819
+ * If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
3820
+ */
3821
+ const COPYFILE_FICLONE: number;
3822
+ /**
3823
+ * Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
3824
+ * If the underlying platform does not support copy-on-write, then the operation will fail with an error.
3825
+ */
3826
+ const COPYFILE_FICLONE_FORCE: number;
3827
+ // File Open Constants
3828
+ /** Constant for fs.open(). Flag indicating to open a file for read-only access. */
3829
+ const O_RDONLY: number;
3830
+ /** Constant for fs.open(). Flag indicating to open a file for write-only access. */
3831
+ const O_WRONLY: number;
3832
+ /** Constant for fs.open(). Flag indicating to open a file for read-write access. */
3833
+ const O_RDWR: number;
3834
+ /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
3835
+ const O_CREAT: number;
3836
+ /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
3837
+ const O_EXCL: number;
3838
+ /**
3839
+ * Constant for fs.open(). Flag indicating that if path identifies a terminal device,
3840
+ * opening the path shall not cause that terminal to become the controlling terminal for the process
3841
+ * (if the process does not already have one).
3842
+ */
3843
+ const O_NOCTTY: number;
3844
+ /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */
3845
+ const O_TRUNC: number;
3846
+ /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
3847
+ const O_APPEND: number;
3848
+ /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
3849
+ const O_DIRECTORY: number;
3850
+ /**
3851
+ * constant for fs.open().
3852
+ * Flag indicating reading accesses to the file system will no longer result in
3853
+ * an update to the atime information associated with the file.
3854
+ * This flag is available on Linux operating systems only.
3855
+ */
3856
+ const O_NOATIME: number;
3857
+ /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
3858
+ const O_NOFOLLOW: number;
3859
+ /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
3860
+ const O_SYNC: number;
3861
+ /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
3862
+ const O_DSYNC: number;
3863
+ /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
3864
+ const O_SYMLINK: number;
3865
+ /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
3866
+ const O_DIRECT: number;
3867
+ /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
3868
+ const O_NONBLOCK: number;
3869
+ // File Type Constants
3870
+ /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
3871
+ const S_IFMT: number;
3872
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
3873
+ const S_IFREG: number;
3874
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
3875
+ const S_IFDIR: number;
3876
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
3877
+ const S_IFCHR: number;
3878
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
3879
+ const S_IFBLK: number;
3880
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
3881
+ const S_IFIFO: number;
3882
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
3883
+ const S_IFLNK: number;
3884
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
3885
+ const S_IFSOCK: number;
3886
+ // File Mode Constants
3887
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
3888
+ const S_IRWXU: number;
3889
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
3890
+ const S_IRUSR: number;
3891
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
3892
+ const S_IWUSR: number;
3893
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
3894
+ const S_IXUSR: number;
3895
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
3896
+ const S_IRWXG: number;
3897
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
3898
+ const S_IRGRP: number;
3899
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
3900
+ const S_IWGRP: number;
3901
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
3902
+ const S_IXGRP: number;
3903
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
3904
+ const S_IRWXO: number;
3905
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
3906
+ const S_IROTH: number;
3907
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
3908
+ const S_IWOTH: number;
3909
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
3910
+ const S_IXOTH: number;
3911
+ /**
3912
+ * When set, a memory file mapping is used to access the file. This flag
3913
+ * is available on Windows operating systems only. On other operating systems,
3914
+ * this flag is ignored.
3915
+ */
3916
+ const UV_FS_O_FILEMAP: number;
3917
+ }
3918
+ /**
3919
+ * Tests a user's permissions for the file or directory specified by `path`.
3920
+ * The `mode` argument is an optional integer that specifies the accessibility
3921
+ * checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and `fs.constants.X_OK`
3922
+ * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
3923
+ * possible values of `mode`.
3924
+ *
3925
+ * The final argument, `callback`, is a callback function that is invoked with
3926
+ * a possible error argument. If any of the accessibility checks fail, the error
3927
+ * argument will be an `Error` object. The following examples check if `package.json` exists, and if it is readable or writable.
3928
+ *
3929
+ * ```js
3930
+ * import { access, constants } from 'node:fs';
3931
+ *
3932
+ * const file = 'package.json';
3933
+ *
3934
+ * // Check if the file exists in the current directory.
3935
+ * access(file, constants.F_OK, (err) => {
3936
+ * console.log(`${file} ${err ? 'does not exist' : 'exists'}`);
3937
+ * });
3938
+ *
3939
+ * // Check if the file is readable.
3940
+ * access(file, constants.R_OK, (err) => {
3941
+ * console.log(`${file} ${err ? 'is not readable' : 'is readable'}`);
3942
+ * });
3943
+ *
3944
+ * // Check if the file is writable.
3945
+ * access(file, constants.W_OK, (err) => {
3946
+ * console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);
3947
+ * });
3948
+ *
3949
+ * // Check if the file is readable and writable.
3950
+ * access(file, constants.R_OK | constants.W_OK, (err) => {
3951
+ * console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);
3952
+ * });
3953
+ * ```
3954
+ *
3955
+ * Do not use `fs.access()` to check for the accessibility of a file before calling `fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing
3956
+ * so introduces a race condition, since other processes may change the file's
3957
+ * state between the two calls. Instead, user code should open/read/write the
3958
+ * file directly and handle the error raised if the file is not accessible.
3959
+ *
3960
+ * **write (NOT RECOMMENDED)**
3961
+ *
3962
+ * ```js
3963
+ * import { access, open, close } from 'node:fs';
3964
+ *
3965
+ * access('myfile', (err) => {
3966
+ * if (!err) {
3967
+ * console.error('myfile already exists');
3968
+ * return;
3969
+ * }
3970
+ *
3971
+ * open('myfile', 'wx', (err, fd) => {
3972
+ * if (err) throw err;
3973
+ *
3974
+ * try {
3975
+ * writeMyData(fd);
3976
+ * } finally {
3977
+ * close(fd, (err) => {
3978
+ * if (err) throw err;
3979
+ * });
3980
+ * }
3981
+ * });
3982
+ * });
3983
+ * ```
3984
+ *
3985
+ * **write (RECOMMENDED)**
3986
+ *
3987
+ * ```js
3988
+ * import { open, close } from 'node:fs';
3989
+ *
3990
+ * open('myfile', 'wx', (err, fd) => {
3991
+ * if (err) {
3992
+ * if (err.code === 'EEXIST') {
3993
+ * console.error('myfile already exists');
3994
+ * return;
3995
+ * }
3996
+ *
3997
+ * throw err;
3998
+ * }
3999
+ *
4000
+ * try {
4001
+ * writeMyData(fd);
4002
+ * } finally {
4003
+ * close(fd, (err) => {
4004
+ * if (err) throw err;
4005
+ * });
4006
+ * }
4007
+ * });
4008
+ * ```
4009
+ *
4010
+ * **read (NOT RECOMMENDED)**
4011
+ *
4012
+ * ```js
4013
+ * import { access, open, close } from 'node:fs';
4014
+ * access('myfile', (err) => {
4015
+ * if (err) {
4016
+ * if (err.code === 'ENOENT') {
4017
+ * console.error('myfile does not exist');
4018
+ * return;
4019
+ * }
4020
+ *
4021
+ * throw err;
4022
+ * }
4023
+ *
4024
+ * open('myfile', 'r', (err, fd) => {
4025
+ * if (err) throw err;
4026
+ *
4027
+ * try {
4028
+ * readMyData(fd);
4029
+ * } finally {
4030
+ * close(fd, (err) => {
4031
+ * if (err) throw err;
4032
+ * });
4033
+ * }
4034
+ * });
4035
+ * });
4036
+ * ```
4037
+ *
4038
+ * **read (RECOMMENDED)**
4039
+ *
4040
+ * ```js
4041
+ * import { open, close } from 'node:fs';
4042
+ *
4043
+ * open('myfile', 'r', (err, fd) => {
4044
+ * if (err) {
4045
+ * if (err.code === 'ENOENT') {
4046
+ * console.error('myfile does not exist');
4047
+ * return;
4048
+ * }
4049
+ *
4050
+ * throw err;
4051
+ * }
4052
+ *
4053
+ * try {
4054
+ * readMyData(fd);
4055
+ * } finally {
4056
+ * close(fd, (err) => {
4057
+ * if (err) throw err;
4058
+ * });
4059
+ * }
4060
+ * });
4061
+ * ```
4062
+ *
4063
+ * The "not recommended" examples above check for accessibility and then use the
4064
+ * file; the "recommended" examples are better because they use the file directly
4065
+ * and handle the error, if any.
4066
+ *
4067
+ * In general, check for the accessibility of a file only if the file will not be
4068
+ * used directly, for example when its accessibility is a signal from another
4069
+ * process.
4070
+ *
4071
+ * On Windows, access-control policies (ACLs) on a directory may limit access to
4072
+ * a file or directory. The `fs.access()` function, however, does not check the
4073
+ * ACL and therefore may report that a path is accessible even if the ACL restricts
4074
+ * the user from reading or writing to it.
4075
+ * @since v0.11.15
4076
+ * @param [mode=fs.constants.F_OK]
4077
+ */
4078
+ export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
4079
+ /**
4080
+ * Asynchronously tests a user's permissions for the file specified by path.
4081
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4082
+ */
4083
+ export function access(path: PathLike, callback: NoParamCallback): void;
4084
+ export namespace access {
4085
+ /**
4086
+ * Asynchronously tests a user's permissions for the file specified by path.
4087
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4088
+ * URL support is _experimental_.
4089
+ */
4090
+ function __promisify__(path: PathLike, mode?: number): Promise<void>;
4091
+ }
4092
+ /**
4093
+ * Synchronously tests a user's permissions for the file or directory specified
4094
+ * by `path`. The `mode` argument is an optional integer that specifies the
4095
+ * accessibility checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and
4096
+ * `fs.constants.X_OK` (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
4097
+ * possible values of `mode`.
4098
+ *
4099
+ * If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
4100
+ * the method will return `undefined`.
4101
+ *
4102
+ * ```js
4103
+ * import { accessSync, constants } from 'node:fs';
4104
+ *
4105
+ * try {
4106
+ * accessSync('etc/passwd', constants.R_OK | constants.W_OK);
4107
+ * console.log('can read/write');
4108
+ * } catch (err) {
4109
+ * console.error('no access!');
4110
+ * }
4111
+ * ```
4112
+ * @since v0.11.15
4113
+ * @param [mode=fs.constants.F_OK]
4114
+ */
4115
+ export function accessSync(path: PathLike, mode?: number): void;
4116
+ interface StreamOptions {
4117
+ flags?: string | undefined;
4118
+ encoding?: BufferEncoding | undefined;
4119
+ fd?: number | promises.FileHandle | undefined;
4120
+ mode?: number | undefined;
4121
+ autoClose?: boolean | undefined;
4122
+ emitClose?: boolean | undefined;
4123
+ start?: number | undefined;
4124
+ signal?: AbortSignal | null | undefined;
4125
+ highWaterMark?: number | undefined;
4126
+ }
4127
+ interface FSImplementation {
4128
+ open?: (...args: any[]) => any;
4129
+ close?: (...args: any[]) => any;
4130
+ }
4131
+ interface CreateReadStreamFSImplementation extends FSImplementation {
4132
+ read: (...args: any[]) => any;
4133
+ }
4134
+ interface CreateWriteStreamFSImplementation extends FSImplementation {
4135
+ write: (...args: any[]) => any;
4136
+ writev?: (...args: any[]) => any;
4137
+ }
4138
+ interface ReadStreamOptions extends StreamOptions {
4139
+ fs?: CreateReadStreamFSImplementation | null | undefined;
4140
+ end?: number | undefined;
4141
+ }
4142
+ interface WriteStreamOptions extends StreamOptions {
4143
+ fs?: CreateWriteStreamFSImplementation | null | undefined;
4144
+ flush?: boolean | undefined;
4145
+ }
4146
+ /**
4147
+ * `options` can include `start` and `end` values to read a range of bytes from
4148
+ * the file instead of the entire file. Both `start` and `end` are inclusive and
4149
+ * start counting at 0, allowed values are in the
4150
+ * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `fd` is specified and `start` is
4151
+ * omitted or `undefined`, `fs.createReadStream()` reads sequentially from the
4152
+ * current file position. The `encoding` can be any one of those accepted by `Buffer`.
4153
+ *
4154
+ * If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
4155
+ * the specified file descriptor. This means that no `'open'` event will be
4156
+ * emitted. `fd` should be blocking; non-blocking `fd`s should be passed to `net.Socket`.
4157
+ *
4158
+ * If `fd` points to a character device that only supports blocking reads
4159
+ * (such as keyboard or sound card), read operations do not finish until data is
4160
+ * available. This can prevent the process from exiting and the stream from
4161
+ * closing naturally.
4162
+ *
4163
+ * By default, the stream will emit a `'close'` event after it has been
4164
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
4165
+ *
4166
+ * By providing the `fs` option, it is possible to override the corresponding `fs` implementations for `open`, `read`, and `close`. When providing the `fs` option,
4167
+ * an override for `read` is required. If no `fd` is provided, an override for `open` is also required. If `autoClose` is `true`, an override for `close` is
4168
+ * also required.
4169
+ *
4170
+ * ```js
4171
+ * import { createReadStream } from 'node:fs';
4172
+ *
4173
+ * // Create a stream from some character device.
4174
+ * const stream = createReadStream('/dev/input/event0');
4175
+ * setTimeout(() => {
4176
+ * stream.close(); // This may not close the stream.
4177
+ * // Artificially marking end-of-stream, as if the underlying resource had
4178
+ * // indicated end-of-file by itself, allows the stream to close.
4179
+ * // This does not cancel pending read operations, and if there is such an
4180
+ * // operation, the process may still not be able to exit successfully
4181
+ * // until it finishes.
4182
+ * stream.push(null);
4183
+ * stream.read(0);
4184
+ * }, 100);
4185
+ * ```
4186
+ *
4187
+ * If `autoClose` is false, then the file descriptor won't be closed, even if
4188
+ * there's an error. It is the application's responsibility to close it and make
4189
+ * sure there's no file descriptor leak. If `autoClose` is set to true (default
4190
+ * behavior), on `'error'` or `'end'` the file descriptor will be closed
4191
+ * automatically.
4192
+ *
4193
+ * `mode` sets the file mode (permission and sticky bits), but only if the
4194
+ * file was created.
4195
+ *
4196
+ * An example to read the last 10 bytes of a file which is 100 bytes long:
4197
+ *
4198
+ * ```js
4199
+ * import { createReadStream } from 'node:fs';
4200
+ *
4201
+ * createReadStream('sample.txt', { start: 90, end: 99 });
4202
+ * ```
4203
+ *
4204
+ * If `options` is a string, then it specifies the encoding.
4205
+ * @since v0.1.31
4206
+ */
4207
+ export function createReadStream(path: PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
4208
+ /**
4209
+ * `options` may also include a `start` option to allow writing data at some
4210
+ * position past the beginning of the file, allowed values are in the
4211
+ * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
4212
+ * replacing it may require the `flags` option to be set to `r+` rather than the
4213
+ * default `w`. The `encoding` can be any one of those accepted by `Buffer`.
4214
+ *
4215
+ * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'` the file descriptor will be closed automatically. If `autoClose` is false,
4216
+ * then the file descriptor won't be closed, even if there's an error.
4217
+ * It is the application's responsibility to close it and make sure there's no
4218
+ * file descriptor leak.
4219
+ *
4220
+ * By default, the stream will emit a `'close'` event after it has been
4221
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
4222
+ *
4223
+ * By providing the `fs` option it is possible to override the corresponding `fs` implementations for `open`, `write`, `writev`, and `close`. Overriding `write()` without `writev()` can reduce
4224
+ * performance as some optimizations (`_writev()`)
4225
+ * will be disabled. When providing the `fs` option, overrides for at least one of `write` and `writev` are required. If no `fd` option is supplied, an override
4226
+ * for `open` is also required. If `autoClose` is `true`, an override for `close` is also required.
4227
+ *
4228
+ * Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the `path` argument and will use the specified file descriptor. This means that no `'open'` event will be
4229
+ * emitted. `fd` should be blocking; non-blocking `fd`s
4230
+ * should be passed to `net.Socket`.
4231
+ *
4232
+ * If `options` is a string, then it specifies the encoding.
4233
+ * @since v0.1.31
4234
+ */
4235
+ export function createWriteStream(path: PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
4236
+ /**
4237
+ * Forces all currently queued I/O operations associated with the file to the
4238
+ * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. No arguments other
4239
+ * than a possible
4240
+ * exception are given to the completion callback.
4241
+ * @since v0.1.96
4242
+ */
4243
+ export function fdatasync(fd: number, callback: NoParamCallback): void;
4244
+ export namespace fdatasync {
4245
+ /**
4246
+ * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
4247
+ * @param fd A file descriptor.
4248
+ */
4249
+ function __promisify__(fd: number): Promise<void>;
4250
+ }
4251
+ /**
4252
+ * Forces all currently queued I/O operations associated with the file to the
4253
+ * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. Returns `undefined`.
4254
+ * @since v0.1.96
4255
+ */
4256
+ export function fdatasyncSync(fd: number): void;
4257
+ /**
4258
+ * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
4259
+ * already exists. No arguments other than a possible exception are given to the
4260
+ * callback function. Node.js makes no guarantees about the atomicity of the copy
4261
+ * operation. If an error occurs after the destination file has been opened for
4262
+ * writing, Node.js will attempt to remove the destination.
4263
+ *
4264
+ * `mode` is an optional integer that specifies the behavior
4265
+ * of the copy operation. It is possible to create a mask consisting of the bitwise
4266
+ * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
4267
+ *
4268
+ * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already
4269
+ * exists.
4270
+ * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a
4271
+ * copy-on-write reflink. If the platform does not support copy-on-write, then a
4272
+ * fallback copy mechanism is used.
4273
+ * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to
4274
+ * create a copy-on-write reflink. If the platform does not support
4275
+ * copy-on-write, then the operation will fail.
4276
+ *
4277
+ * ```js
4278
+ * import { copyFile, constants } from 'node:fs';
4279
+ *
4280
+ * function callback(err) {
4281
+ * if (err) throw err;
4282
+ * console.log('source.txt was copied to destination.txt');
4283
+ * }
4284
+ *
4285
+ * // destination.txt will be created or overwritten by default.
4286
+ * copyFile('source.txt', 'destination.txt', callback);
4287
+ *
4288
+ * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
4289
+ * copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback);
4290
+ * ```
4291
+ * @since v8.5.0
4292
+ * @param src source filename to copy
4293
+ * @param dest destination filename of the copy operation
4294
+ * @param [mode=0] modifiers for copy operation.
4295
+ */
4296
+ export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
4297
+ export function copyFile(src: PathLike, dest: PathLike, mode: number, callback: NoParamCallback): void;
4298
+ export namespace copyFile {
4299
+ function __promisify__(src: PathLike, dst: PathLike, mode?: number): Promise<void>;
4300
+ }
4301
+ /**
4302
+ * Synchronously copies `src` to `dest`. By default, `dest` is overwritten if it
4303
+ * already exists. Returns `undefined`. Node.js makes no guarantees about the
4304
+ * atomicity of the copy operation. If an error occurs after the destination file
4305
+ * has been opened for writing, Node.js will attempt to remove the destination.
4306
+ *
4307
+ * `mode` is an optional integer that specifies the behavior
4308
+ * of the copy operation. It is possible to create a mask consisting of the bitwise
4309
+ * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
4310
+ *
4311
+ * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already
4312
+ * exists.
4313
+ * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a
4314
+ * copy-on-write reflink. If the platform does not support copy-on-write, then a
4315
+ * fallback copy mechanism is used.
4316
+ * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to
4317
+ * create a copy-on-write reflink. If the platform does not support
4318
+ * copy-on-write, then the operation will fail.
4319
+ *
4320
+ * ```js
4321
+ * import { copyFileSync, constants } from 'node:fs';
4322
+ *
4323
+ * // destination.txt will be created or overwritten by default.
4324
+ * copyFileSync('source.txt', 'destination.txt');
4325
+ * console.log('source.txt was copied to destination.txt');
4326
+ *
4327
+ * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
4328
+ * copyFileSync('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
4329
+ * ```
4330
+ * @since v8.5.0
4331
+ * @param src source filename to copy
4332
+ * @param dest destination filename of the copy operation
4333
+ * @param [mode=0] modifiers for copy operation.
4334
+ */
4335
+ export function copyFileSync(src: PathLike, dest: PathLike, mode?: number): void;
4336
+ /**
4337
+ * Write an array of `ArrayBufferView`s to the file specified by `fd` using `writev()`.
4338
+ *
4339
+ * `position` is the offset from the beginning of the file where this data
4340
+ * should be written. If `typeof position !== 'number'`, the data will be written
4341
+ * at the current position.
4342
+ *
4343
+ * The callback will be given three arguments: `err`, `bytesWritten`, and `buffers`. `bytesWritten` is how many bytes were written from `buffers`.
4344
+ *
4345
+ * If this method is `util.promisify()` ed, it returns a promise for an `Object` with `bytesWritten` and `buffers` properties.
4346
+ *
4347
+ * It is unsafe to use `fs.writev()` multiple times on the same file without
4348
+ * waiting for the callback. For this scenario, use {@link createWriteStream}.
4349
+ *
4350
+ * On Linux, positional writes don't work when the file is opened in append mode.
4351
+ * The kernel ignores the position argument and always appends the data to
4352
+ * the end of the file.
4353
+ * @since v12.9.0
4354
+ * @param [position='null']
4355
+ */
4356
+ export function writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4357
+ fd: number,
4358
+ buffers: TBuffers,
4359
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: TBuffers) => void,
4360
+ ): void;
4361
+ export function writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4362
+ fd: number,
4363
+ buffers: TBuffers,
4364
+ position: number | null,
4365
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: TBuffers) => void,
4366
+ ): void;
4367
+ // Providing a default type parameter doesn't provide true BC for userland consumers, but at least suppresses TS2314
4368
+ // TODO: remove default in future major version
4369
+ export interface WriteVResult<T extends readonly NodeJS.ArrayBufferView[] = NodeJS.ArrayBufferView[]> {
4370
+ bytesWritten: number;
4371
+ buffers: T;
4372
+ }
4373
+ export namespace writev {
4374
+ function __promisify__<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4375
+ fd: number,
4376
+ buffers: TBuffers,
4377
+ position?: number,
4378
+ ): Promise<WriteVResult<TBuffers>>;
4379
+ }
4380
+ /**
4381
+ * For detailed information, see the documentation of the asynchronous version of
4382
+ * this API: {@link writev}.
4383
+ * @since v12.9.0
4384
+ * @param [position='null']
4385
+ * @return The number of bytes written.
4386
+ */
4387
+ export function writevSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number;
4388
+ /**
4389
+ * Read from a file specified by `fd` and write to an array of `ArrayBufferView`s
4390
+ * using `readv()`.
4391
+ *
4392
+ * `position` is the offset from the beginning of the file from where data
4393
+ * should be read. If `typeof position !== 'number'`, the data will be read
4394
+ * from the current position.
4395
+ *
4396
+ * The callback will be given three arguments: `err`, `bytesRead`, and `buffers`. `bytesRead` is how many bytes were read from the file.
4397
+ *
4398
+ * If this method is invoked as its `util.promisify()` ed version, it returns
4399
+ * a promise for an `Object` with `bytesRead` and `buffers` properties.
4400
+ * @since v13.13.0, v12.17.0
4401
+ * @param [position='null']
4402
+ */
4403
+ export function readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4404
+ fd: number,
4405
+ buffers: TBuffers,
4406
+ cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: TBuffers) => void,
4407
+ ): void;
4408
+ export function readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4409
+ fd: number,
4410
+ buffers: TBuffers,
4411
+ position: number | null,
4412
+ cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: TBuffers) => void,
4413
+ ): void;
4414
+ // Providing a default type parameter doesn't provide true BC for userland consumers, but at least suppresses TS2314
4415
+ // TODO: remove default in future major version
4416
+ export interface ReadVResult<T extends readonly NodeJS.ArrayBufferView[] = NodeJS.ArrayBufferView[]> {
4417
+ bytesRead: number;
4418
+ buffers: T;
4419
+ }
4420
+ export namespace readv {
4421
+ function __promisify__<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4422
+ fd: number,
4423
+ buffers: TBuffers,
4424
+ position?: number,
4425
+ ): Promise<ReadVResult<TBuffers>>;
4426
+ }
4427
+ /**
4428
+ * For detailed information, see the documentation of the asynchronous version of
4429
+ * this API: {@link readv}.
4430
+ * @since v13.13.0, v12.17.0
4431
+ * @param [position='null']
4432
+ * @return The number of bytes read.
4433
+ */
4434
+ export function readvSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number;
4435
+
4436
+ export interface OpenAsBlobOptions {
4437
+ /**
4438
+ * An optional mime type for the blob.
4439
+ *
4440
+ * @default 'undefined'
4441
+ */
4442
+ type?: string | undefined;
4443
+ }
4444
+
4445
+ /**
4446
+ * Returns a `Blob` whose data is backed by the given file.
4447
+ *
4448
+ * The file must not be modified after the `Blob` is created. Any modifications
4449
+ * will cause reading the `Blob` data to fail with a `DOMException` error.
4450
+ * Synchronous stat operations on the file when the `Blob` is created, and before
4451
+ * each read in order to detect whether the file data has been modified on disk.
4452
+ *
4453
+ * ```js
4454
+ * import { openAsBlob } from 'node:fs';
4455
+ *
4456
+ * const blob = await openAsBlob('the.file.txt');
4457
+ * const ab = await blob.arrayBuffer();
4458
+ * blob.stream();
4459
+ * ```
4460
+ * @since v19.8.0
4461
+ */
4462
+ export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
4463
+
4464
+ export interface OpenDirOptions {
4465
+ /**
4466
+ * @default 'utf8'
4467
+ */
4468
+ encoding?: BufferEncoding | undefined;
4469
+ /**
4470
+ * Number of directory entries that are buffered
4471
+ * internally when reading from the directory. Higher values lead to better
4472
+ * performance but higher memory usage.
4473
+ * @default 32
4474
+ */
4475
+ bufferSize?: number | undefined;
4476
+ /**
4477
+ * @default false
4478
+ */
4479
+ recursive?: boolean | undefined;
4480
+ }
4481
+ /**
4482
+ * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
4483
+ *
4484
+ * Creates an `fs.Dir`, which contains all further functions for reading from
4485
+ * and cleaning up the directory.
4486
+ *
4487
+ * The `encoding` option sets the encoding for the `path` while opening the
4488
+ * directory and subsequent read operations.
4489
+ * @since v12.12.0
4490
+ */
4491
+ export function opendirSync(path: PathLike, options?: OpenDirOptions): Dir;
4492
+ /**
4493
+ * Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for
4494
+ * more details.
4495
+ *
4496
+ * Creates an `fs.Dir`, which contains all further functions for reading from
4497
+ * and cleaning up the directory.
4498
+ *
4499
+ * The `encoding` option sets the encoding for the `path` while opening the
4500
+ * directory and subsequent read operations.
4501
+ * @since v12.12.0
4502
+ */
4503
+ export function opendir(path: PathLike, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
4504
+ export function opendir(
4505
+ path: PathLike,
4506
+ options: OpenDirOptions,
4507
+ cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void,
4508
+ ): void;
4509
+ export namespace opendir {
4510
+ function __promisify__(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
4511
+ }
4512
+ export interface BigIntStats extends StatsBase<bigint> {
4513
+ atimeNs: bigint;
4514
+ mtimeNs: bigint;
4515
+ ctimeNs: bigint;
4516
+ birthtimeNs: bigint;
4517
+ }
4518
+ export interface BigIntOptions {
4519
+ bigint: true;
4520
+ }
4521
+ export interface StatOptions {
4522
+ bigint?: boolean | undefined;
4523
+ }
4524
+ export interface StatSyncOptions extends StatOptions {
4525
+ throwIfNoEntry?: boolean | undefined;
4526
+ }
4527
+ interface CopyOptionsBase {
4528
+ /**
4529
+ * Dereference symlinks
4530
+ * @default false
4531
+ */
4532
+ dereference?: boolean | undefined;
4533
+ /**
4534
+ * When `force` is `false`, and the destination
4535
+ * exists, throw an error.
4536
+ * @default false
4537
+ */
4538
+ errorOnExist?: boolean | undefined;
4539
+ /**
4540
+ * Overwrite existing file or directory. _The copy
4541
+ * operation will ignore errors if you set this to false and the destination
4542
+ * exists. Use the `errorOnExist` option to change this behavior.
4543
+ * @default true
4544
+ */
4545
+ force?: boolean | undefined;
4546
+ /**
4547
+ * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()}
4548
+ */
4549
+ mode?: number | undefined;
4550
+ /**
4551
+ * When `true` timestamps from `src` will
4552
+ * be preserved.
4553
+ * @default false
4554
+ */
4555
+ preserveTimestamps?: boolean | undefined;
4556
+ /**
4557
+ * Copy directories recursively.
4558
+ * @default false
4559
+ */
4560
+ recursive?: boolean | undefined;
4561
+ /**
4562
+ * When true, path resolution for symlinks will be skipped
4563
+ * @default false
4564
+ */
4565
+ verbatimSymlinks?: boolean | undefined;
4566
+ }
4567
+ export interface CopyOptions extends CopyOptionsBase {
4568
+ /**
4569
+ * Function to filter copied files/directories. Return
4570
+ * `true` to copy the item, `false` to ignore it.
4571
+ */
4572
+ filter?: ((source: string, destination: string) => boolean | Promise<boolean>) | undefined;
4573
+ }
4574
+ export interface CopySyncOptions extends CopyOptionsBase {
4575
+ /**
4576
+ * Function to filter copied files/directories. Return
4577
+ * `true` to copy the item, `false` to ignore it.
4578
+ */
4579
+ filter?: ((source: string, destination: string) => boolean) | undefined;
4580
+ }
4581
+ /**
4582
+ * Asynchronously copies the entire directory structure from `src` to `dest`,
4583
+ * including subdirectories and files.
4584
+ *
4585
+ * When copying a directory to another directory, globs are not supported and
4586
+ * behavior is similar to `cp dir1/ dir2/`.
4587
+ * @since v16.7.0
4588
+ * @experimental
4589
+ * @param src source path to copy.
4590
+ * @param dest destination path to copy to.
4591
+ */
4592
+ export function cp(
4593
+ source: string | URL,
4594
+ destination: string | URL,
4595
+ callback: (err: NodeJS.ErrnoException | null) => void,
4596
+ ): void;
4597
+ export function cp(
4598
+ source: string | URL,
4599
+ destination: string | URL,
4600
+ opts: CopyOptions,
4601
+ callback: (err: NodeJS.ErrnoException | null) => void,
4602
+ ): void;
4603
+ /**
4604
+ * Synchronously copies the entire directory structure from `src` to `dest`,
4605
+ * including subdirectories and files.
4606
+ *
4607
+ * When copying a directory to another directory, globs are not supported and
4608
+ * behavior is similar to `cp dir1/ dir2/`.
4609
+ * @since v16.7.0
4610
+ * @experimental
4611
+ * @param src source path to copy.
4612
+ * @param dest destination path to copy to.
4613
+ */
4614
+ export function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void;
4615
+
4616
+ // TODO: collapse
4617
+ interface _GlobOptions<T extends Dirent | string> {
4618
+ /**
4619
+ * Current working directory.
4620
+ * @default process.cwd()
4621
+ */
4622
+ cwd?: string | URL | undefined;
4623
+ /**
4624
+ * `true` if the glob should return paths as `Dirent`s, `false` otherwise.
4625
+ * @default false
4626
+ * @since v22.2.0
4627
+ */
4628
+ withFileTypes?: boolean | undefined;
4629
+ /**
4630
+ * Function to filter out files/directories or a
4631
+ * list of glob patterns to be excluded. If a function is provided, return
4632
+ * `true` to exclude the item, `false` to include it.
4633
+ * If a string array is provided, each string should be a glob pattern that
4634
+ * specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are
4635
+ * not supported.
4636
+ * @default undefined
4637
+ */
4638
+ exclude?: ((fileName: T) => boolean) | readonly string[] | undefined;
4639
+ }
4640
+ export interface GlobOptions extends _GlobOptions<Dirent | string> {}
4641
+ export interface GlobOptionsWithFileTypes extends _GlobOptions<Dirent> {
4642
+ withFileTypes: true;
4643
+ }
4644
+ export interface GlobOptionsWithoutFileTypes extends _GlobOptions<string> {
4645
+ withFileTypes?: false | undefined;
4646
+ }
4647
+
4648
+ /**
4649
+ * Retrieves the files matching the specified pattern.
4650
+ *
4651
+ * ```js
4652
+ * import { glob } from 'node:fs';
4653
+ *
4654
+ * glob('*.js', (err, matches) => {
4655
+ * if (err) throw err;
4656
+ * console.log(matches);
4657
+ * });
4658
+ * ```
4659
+ * @since v22.0.0
4660
+ */
4661
+ export function glob(
4662
+ pattern: string | readonly string[],
4663
+ callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
4664
+ ): void;
4665
+ export function glob(
4666
+ pattern: string | readonly string[],
4667
+ options: GlobOptionsWithFileTypes,
4668
+ callback: (
4669
+ err: NodeJS.ErrnoException | null,
4670
+ matches: Dirent[],
4671
+ ) => void,
4672
+ ): void;
4673
+ export function glob(
4674
+ pattern: string | readonly string[],
4675
+ options: GlobOptionsWithoutFileTypes,
4676
+ callback: (
4677
+ err: NodeJS.ErrnoException | null,
4678
+ matches: string[],
4679
+ ) => void,
4680
+ ): void;
4681
+ export function glob(
4682
+ pattern: string | readonly string[],
4683
+ options: GlobOptions,
4684
+ callback: (
4685
+ err: NodeJS.ErrnoException | null,
4686
+ matches: Dirent[] | string[],
4687
+ ) => void,
4688
+ ): void;
4689
+ /**
4690
+ * ```js
4691
+ * import { globSync } from 'node:fs';
4692
+ *
4693
+ * console.log(globSync('*.js'));
4694
+ * ```
4695
+ * @since v22.0.0
4696
+ * @returns paths of files that match the pattern.
4697
+ */
4698
+ export function globSync(pattern: string | readonly string[]): string[];
4699
+ export function globSync(
4700
+ pattern: string | readonly string[],
4701
+ options: GlobOptionsWithFileTypes,
4702
+ ): Dirent[];
4703
+ export function globSync(
4704
+ pattern: string | readonly string[],
4705
+ options: GlobOptionsWithoutFileTypes,
4706
+ ): string[];
4707
+ export function globSync(
4708
+ pattern: string | readonly string[],
4709
+ options: GlobOptions,
4710
+ ): Dirent[] | string[];
4711
+ }
4712
+ declare module "node:fs" {
4713
+ export * from "fs";
4714
+ }