create-jen-app 0.1.0

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