alicezetion 1.8.6 → 1.8.8

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