imran-dl 2.3.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of imran-dl might be problematic. Click here for more details.

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