rahad-media-downloader 2.1.12 → 2.1.13

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