@openclaw/slack 2026.10.1 → 2026.10.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/dist/.setup/account-configured-zcR9TJJN.mjs +35 -0
  2. package/dist/.setup/{account-inspect-Cs-7DXXW.mjs → account-inspect-D58VVDjk.mjs} +15 -35
  3. package/dist/.setup/{accounts-CDgkV7Cm.mjs → accounts-BMg9YLIv.mjs} +44 -53
  4. package/dist/.setup/{action-runtime-DJ1daRAZ.mjs → action-runtime-BiRZNsIG.mjs} +20 -22
  5. package/dist/.setup/action-runtime.runtime-C5xceJoS.mjs +2 -0
  6. package/dist/.setup/{actions-DDoAJnrH.mjs → actions-KGKwTAKO.mjs} +34 -43
  7. package/dist/.setup/{approval-handler.runtime-BcE_shWc.mjs → approval-handler.runtime-DYrsG2Ox.mjs} +44 -70
  8. package/dist/.setup/{approval-message-updates-EgKGmFXx.mjs → approval-message-updates-CwdDew9i.mjs} +1 -1
  9. package/dist/.setup/{channel-DgKSu8Iv.mjs → channel-C7MY-Hhg.mjs} +138 -97
  10. package/dist/.setup/{channel-type-B9zYYzBU.mjs → channel-type-NjX2SwvS.mjs} +3 -3
  11. package/dist/.setup/{channel.setup-BYIlwbQ7.mjs → channel.setup-BFpQowO3.mjs} +7 -14
  12. package/dist/.setup/{directory-config-B_by7zrc.mjs → directory-config-BEDZPfDn.mjs} +1 -1
  13. package/dist/.setup/{directory-live-C48wazJt.mjs → directory-live-FipfeCwt.mjs} +33 -36
  14. package/dist/.setup/{message-tool-api-CcjLPN3v.mjs → message-tool-api-C7im5ETh.mjs} +2 -2
  15. package/dist/.setup/{monitor-BuYBDmm7.mjs → monitor-BnN2px0N.mjs} +609 -801
  16. package/dist/.setup/{outbound-adapter-BZFkK-mw.mjs → outbound-adapter-4HdGq-8r.mjs} +4 -4
  17. package/dist/.setup/{pipeline.runtime-CIepKmZt.mjs → pipeline.runtime-ByPbC6MN.mjs} +287 -365
  18. package/dist/.setup/{policy-KKTqEiDv.mjs → policy-BaY9_eh1.mjs} +2 -2
  19. package/dist/.setup/{probe-BVlJ3dp0.mjs → probe-CyX52GtD.mjs} +54 -61
  20. package/dist/.setup/{relay-source-CC3h6M7y.mjs → relay-source-CVfH-fBO.mjs} +28 -45
  21. package/dist/.setup/{replies-DHbuthIR.mjs → replies-WmfwvQxc.mjs} +38 -49
  22. package/dist/.setup/{reply-blocks-CKnO4BSG.mjs → reply-blocks-rqHQ_3pr.mjs} +87 -138
  23. package/dist/.setup/{resolve-channels-HR0TgArR.mjs → resolve-channels-B96cgprw.mjs} +17 -41
  24. package/dist/.setup/{resolve-users-BNYBhF0q.mjs → resolve-users-Xz9aPdns.mjs} +22 -58
  25. package/dist/.setup/{scopes-DrDbyUH2.mjs → scopes-aMcMHhXk.mjs} +1 -1
  26. package/dist/.setup/{send-CgPI3Zj8.mjs → send-CLmsR42r.mjs} +157 -284
  27. package/dist/.setup/{session-status-D46GHwOV.mjs → session-status-CcXe10zN.mjs} +181 -238
  28. package/dist/.setup/{setup-plugin-api-ZrHs0N4U.mjs → setup-plugin-api-D92P5p51.mjs} +1 -1
  29. package/dist/.setup/{setup-surface-83lxvE2y.mjs → setup-surface-368jx6Uc.mjs} +6 -6
  30. package/dist/.setup/{shared-VtmYNj-v.mjs → shared-CtprVh_G.mjs} +5 -5
  31. package/dist/.setup/{slash-dispatch.runtime-gBj_uaLM.mjs → slash-dispatch.runtime-Dzwj6TPI.mjs} +1 -1
  32. package/dist/account-inspect-api.js +1 -1
  33. package/dist/api.js +12 -12
  34. package/dist/channel-plugin-api.js +1 -1
  35. package/dist/configured-state.js +6 -13
  36. package/dist/directory-contract-api.js +1 -1
  37. package/dist/message-tool-api.js +1 -1
  38. package/dist/runtime-api.js +10 -10
  39. package/dist/setup-entry.js +1 -1
  40. package/dist/setup-plugin-api.js +1 -1
  41. package/node_modules/@slack/types/dist/block-kit/block-elements.d.ts +1 -1
  42. package/node_modules/@slack/types/dist/block-kit/block-elements.d.ts.map +1 -1
  43. package/node_modules/@slack/types/dist/block-kit/blocks.d.ts +79 -4
  44. package/node_modules/@slack/types/dist/block-kit/blocks.d.ts.map +1 -1
  45. package/node_modules/@slack/types/dist/block-kit/composition-objects.d.ts +17 -0
  46. package/node_modules/@slack/types/dist/block-kit/composition-objects.d.ts.map +1 -1
  47. package/node_modules/@slack/types/package.json +1 -1
  48. package/node_modules/@slack/web-api/dist/methods.d.ts +49 -2
  49. package/node_modules/@slack/web-api/dist/methods.d.ts.map +1 -1
  50. package/node_modules/@slack/web-api/dist/methods.js +47 -0
  51. package/node_modules/@slack/web-api/dist/methods.js.map +1 -1
  52. package/node_modules/@slack/web-api/dist/types/request/agents.d.ts +186 -0
  53. package/node_modules/@slack/web-api/dist/types/request/agents.d.ts.map +1 -1
  54. package/node_modules/@slack/web-api/dist/types/request/index.d.ts +1 -1
  55. package/node_modules/@slack/web-api/dist/types/request/index.d.ts.map +1 -1
  56. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsArchiveResponse.d.ts +9 -0
  57. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsArchiveResponse.d.ts.map +1 -0
  58. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsArchiveResponse.js +11 -0
  59. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsArchiveResponse.js.map +1 -0
  60. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsCreateResponse.d.ts +10 -0
  61. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsCreateResponse.d.ts.map +1 -0
  62. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsCreateResponse.js +11 -0
  63. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsCreateResponse.js.map +1 -0
  64. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsGetCanvasResponse.d.ts +29 -0
  65. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsGetCanvasResponse.d.ts.map +1 -0
  66. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsGetCanvasResponse.js +11 -0
  67. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsGetCanvasResponse.js.map +1 -0
  68. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsListViewsResponse.d.ts +18 -0
  69. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsListViewsResponse.d.ts.map +1 -0
  70. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsListViewsResponse.js +11 -0
  71. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsListViewsResponse.js.map +1 -0
  72. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsRemoveViewResponse.d.ts +11 -0
  73. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsRemoveViewResponse.d.ts.map +1 -0
  74. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsRemoveViewResponse.js +11 -0
  75. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsRemoveViewResponse.js.map +1 -0
  76. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCanvasContentResponse.d.ts +11 -0
  77. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCanvasContentResponse.d.ts.map +1 -0
  78. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCanvasContentResponse.js +11 -0
  79. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCanvasContentResponse.js.map +1 -0
  80. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCommandsResponse.d.ts +11 -0
  81. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCommandsResponse.d.ts.map +1 -0
  82. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCommandsResponse.js +11 -0
  83. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCommandsResponse.js.map +1 -0
  84. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetPropertiesResponse.d.ts +10 -0
  85. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetPropertiesResponse.d.ts.map +1 -0
  86. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetPropertiesResponse.js +11 -0
  87. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetPropertiesResponse.js.map +1 -0
  88. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetViewResponse.d.ts +15 -0
  89. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetViewResponse.d.ts.map +1 -0
  90. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetViewResponse.js +11 -0
  91. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetViewResponse.js.map +1 -0
  92. package/node_modules/@slack/web-api/dist/types/response/ConversationsInfoResponse.d.ts +31 -0
  93. package/node_modules/@slack/web-api/dist/types/response/ConversationsInfoResponse.d.ts.map +1 -1
  94. package/node_modules/@slack/web-api/dist/types/response/index.d.ts +9 -0
  95. package/node_modules/@slack/web-api/dist/types/response/index.d.ts.map +1 -1
  96. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/LICENSE +21 -0
  97. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/README.md +15 -0
  98. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/assert/strict.d.ts +68 -0
  99. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/assert.d.ts +1077 -0
  100. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/async_hooks.d.ts +711 -0
  101. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/buffer.buffer.d.ts +471 -0
  102. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/buffer.d.ts +1800 -0
  103. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/child_process.d.ts +1361 -0
  104. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/cluster.d.ts +432 -0
  105. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/console.d.ts +93 -0
  106. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/constants.d.ts +14 -0
  107. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/crypto.d.ts +3964 -0
  108. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/dgram.d.ts +652 -0
  109. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/diagnostics_channel.d.ts +794 -0
  110. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/dns/promises.d.ts +497 -0
  111. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/dns.d.ts +876 -0
  112. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/domain.d.ts +150 -0
  113. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/events.d.ts +1008 -0
  114. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ffi.d.ts +500 -0
  115. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/fs/promises.d.ts +1477 -0
  116. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/fs.d.ts +4803 -0
  117. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/globals.d.ts +150 -0
  118. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/globals.typedarray.d.ts +101 -0
  119. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/http.d.ts +2218 -0
  120. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/http2.d.ts +2498 -0
  121. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/https.d.ts +400 -0
  122. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/index.d.ts +116 -0
  123. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/inspector/promises.d.ts +35 -0
  124. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/inspector.d.ts +265 -0
  125. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  126. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/module.d.ts +726 -0
  127. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/net.d.ts +1074 -0
  128. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/os.d.ts +498 -0
  129. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/package.json +155 -0
  130. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/path/posix.d.ts +8 -0
  131. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/path/win32.d.ts +8 -0
  132. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/path.d.ts +178 -0
  133. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/perf_hooks.d.ts +617 -0
  134. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/process.d.ts +2269 -0
  135. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/punycode.d.ts +89 -0
  136. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/querystring.d.ts +139 -0
  137. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/quic.d.ts +2191 -0
  138. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/readline/promises.d.ts +158 -0
  139. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/readline.d.ts +508 -0
  140. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/repl.d.ts +420 -0
  141. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/sea.d.ts +47 -0
  142. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/sqlite.d.ts +1140 -0
  143. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream/consumers.d.ts +114 -0
  144. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream/iter.d.ts +449 -0
  145. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream/promises.d.ts +211 -0
  146. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream/web.d.ts +320 -0
  147. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream.d.ts +1806 -0
  148. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/string_decoder.d.ts +27 -0
  149. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/test/reporters.d.ts +60 -0
  150. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/test.d.ts +2558 -0
  151. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/timers/promises.d.ts +93 -0
  152. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/timers.d.ts +149 -0
  153. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/tls.d.ts +1232 -0
  154. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/trace_events.d.ts +103 -0
  155. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +467 -0
  156. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  157. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  158. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.6/index.d.ts +118 -0
  159. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  160. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.7/index.d.ts +118 -0
  161. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/tty.d.ts +226 -0
  162. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/url.d.ts +556 -0
  163. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/util/types.d.ts +558 -0
  164. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/util.d.ts +1677 -0
  165. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/v8.d.ts +1059 -0
  166. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/vfs.d.ts +211 -0
  167. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/vm.d.ts +1137 -0
  168. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/wasi.d.ts +131 -0
  169. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
  170. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  171. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/console.d.ts +9 -0
  172. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  173. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/domexception.d.ts +83 -0
  174. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  175. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/events.d.ts +106 -0
  176. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
  177. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  178. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  179. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  180. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  181. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  182. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/streams.d.ts +119 -0
  183. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  184. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/url.d.ts +24 -0
  185. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/worker_threads.d.ts +672 -0
  186. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/zlib/iter.d.ts +131 -0
  187. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/zlib.d.ts +606 -0
  188. package/node_modules/@slack/web-api/node_modules/@types/node/README.md +2 -2
  189. package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -17
  190. package/node_modules/@slack/web-api/package.json +2 -2
  191. package/openclaw.plugin.json +0 -3
  192. package/package.json +6 -14
  193. package/dist/.setup/account-configured-sUohAxZr.mjs +0 -33
  194. package/dist/.setup/action-runtime.runtime-CdWL2mLC.mjs +0 -2
  195. package/dist/control-ui/2f4b1e827be6b68ced2ea0d8b7da8529a4eafbe72be27ee37e1064bdd530ec10/index.js +0 -1
@@ -0,0 +1,1477 @@
1
+ declare module "node:fs/promises" {
2
+ import { BufferView, NonSharedBuffer } from "node:buffer";
3
+ import { Abortable } from "node:events";
4
+ import { Interface as ReadlineInterface } from "node:readline";
5
+ import {
6
+ BigIntStats,
7
+ BigIntStatsFs,
8
+ BufferEncodingOption,
9
+ constants as fsConstants,
10
+ CopyOptions,
11
+ Dir,
12
+ Dirent,
13
+ EncodingOption,
14
+ GlobOptions,
15
+ GlobOptionsWithFileTypes,
16
+ GlobOptionsWithoutFileTypes,
17
+ MakeDirectoryOptions,
18
+ Mode,
19
+ ObjectEncodingOptions,
20
+ OpenDirOptions,
21
+ OpenMode,
22
+ PathLike,
23
+ ReadFileOptions,
24
+ ReadFileOptionsWithBuffer,
25
+ ReadFileOptionsWithBufferEncoding,
26
+ ReadFileOptionsWithStringEncoding,
27
+ ReadOptions,
28
+ ReadOptionsWithBuffer,
29
+ ReadPosition,
30
+ ReadStream,
31
+ ReadVResult,
32
+ RmOptions,
33
+ StatFsOptions,
34
+ StatOptions,
35
+ Stats,
36
+ StatsFs,
37
+ TimeLike,
38
+ WatchEventType,
39
+ WatchOptions as _WatchOptions,
40
+ WriteStream,
41
+ WriteVResult,
42
+ } from "node:fs";
43
+ import { ByteReadableStream, Transform, Writer } from "node:stream/iter";
44
+ import { ReadableStream } from "node:stream/web";
45
+ interface FileChangeInfo<T extends string | Buffer> {
46
+ eventType: WatchEventType;
47
+ filename: T | null;
48
+ }
49
+ interface FlagAndOpenMode {
50
+ mode?: Mode | undefined;
51
+ flag?: OpenMode | undefined;
52
+ }
53
+ interface FileReadResult<T extends NodeJS.ArrayBufferView> {
54
+ bytesRead: number;
55
+ buffer: T;
56
+ }
57
+ /** @deprecated This interface will be removed in a future version. Use `import { ReadOptionsWithBuffer } from "node:fs"` instead. */
58
+ interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
59
+ /**
60
+ * @default `Buffer.alloc(0xffff)`
61
+ */
62
+ buffer?: T;
63
+ /**
64
+ * @default 0
65
+ */
66
+ offset?: number | null;
67
+ /**
68
+ * @default `buffer.byteLength`
69
+ */
70
+ length?: number | null;
71
+ position?: ReadPosition | null;
72
+ }
73
+ interface CreateReadStreamOptions extends Abortable {
74
+ encoding?: BufferEncoding | null | undefined;
75
+ autoClose?: boolean | undefined;
76
+ emitClose?: boolean | undefined;
77
+ start?: number | undefined;
78
+ end?: number | undefined;
79
+ highWaterMark?: number | undefined;
80
+ }
81
+ interface CreateWriteStreamOptions {
82
+ encoding?: BufferEncoding | null | undefined;
83
+ autoClose?: boolean | undefined;
84
+ emitClose?: boolean | undefined;
85
+ start?: number | undefined;
86
+ highWaterMark?: number | undefined;
87
+ flush?: boolean | undefined;
88
+ }
89
+ interface ReadableWebStreamOptions {
90
+ autoClose?: boolean | undefined;
91
+ }
92
+ interface PullOptions extends Abortable {
93
+ /**
94
+ * Close the file handle when the stream ends.
95
+ * @default false
96
+ */
97
+ autoClose?: boolean | undefined;
98
+ /**
99
+ * Byte offset to begin reading from. When specified,
100
+ * reads use explicit positioning (`pread` semantics).
101
+ */
102
+ start?: number | undefined;
103
+ /**
104
+ * Maximum number of bytes to read before ending the
105
+ * iterator. Reads stop when `limit` bytes have been delivered or EOF is
106
+ * reached, whichever comes first.
107
+ */
108
+ limit?: number | undefined;
109
+ /**
110
+ * Size in bytes of the buffer allocated for each
111
+ * read operation.
112
+ * @default 131072
113
+ */
114
+ chunkSize?: number | undefined;
115
+ }
116
+ interface WriterOptions {
117
+ /**
118
+ * Close the file handle when the writer ends or fails.
119
+ * @default false
120
+ */
121
+ autoClose?: boolean | undefined;
122
+ /**
123
+ * Byte offset to start writing at. When specified,
124
+ * writes use explicit positioning.
125
+ */
126
+ start?: number | undefined;
127
+ /**
128
+ * Maximum number of bytes the writer will accept.
129
+ * Async writes (`write()`, `writev()`) that would exceed the limit reject
130
+ * with `ERR_OUT_OF_RANGE`. Sync writes (`writeSync()`, `writevSync()`)
131
+ * return `false`.
132
+ */
133
+ limit?: number | undefined;
134
+ /**
135
+ * Maximum chunk size in bytes for synchronous write
136
+ * operations. Writes larger than this threshold fall back to async I/O.
137
+ * Set this to match the reader's `chunkSize` for optimal `pipeTo()`
138
+ * performance.
139
+ * @default 131072
140
+ */
141
+ chunkSize?: number | undefined;
142
+ }
143
+ // TODO: Add `EventEmitter` close
144
+ interface FileHandle {
145
+ /**
146
+ * The numeric file descriptor managed by the {FileHandle} object.
147
+ * @since v10.0.0
148
+ */
149
+ readonly fd: number;
150
+ /**
151
+ * Alias of `filehandle.writeFile()`.
152
+ *
153
+ * When operating on file handles, the mode cannot be changed from what it was set
154
+ * to with `fsPromises.open()`. Therefore, this is equivalent to `filehandle.writeFile()`.
155
+ * @since v10.0.0
156
+ * @return Fulfills with `undefined` upon success.
157
+ */
158
+ appendFile(
159
+ data:
160
+ | string
161
+ | NodeJS.ArrayBufferView
162
+ | Iterable<string | NodeJS.ArrayBufferView>
163
+ | AsyncIterable<string | NodeJS.ArrayBufferView>,
164
+ options?:
165
+ | (ObjectEncodingOptions & Abortable)
166
+ | BufferEncoding
167
+ | null,
168
+ ): Promise<void>;
169
+ /**
170
+ * Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html).
171
+ * @since v10.0.0
172
+ * @param uid The file's new owner's user id.
173
+ * @param gid The file's new group's group id.
174
+ * @return Fulfills with `undefined` upon success.
175
+ */
176
+ chown(uid: number, gid: number): Promise<void>;
177
+ /**
178
+ * Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html).
179
+ * @since v10.0.0
180
+ * @param mode the file mode bit mask.
181
+ * @return Fulfills with `undefined` upon success.
182
+ */
183
+ chmod(mode: Mode): Promise<void>;
184
+ /**
185
+ * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
186
+ * returned by this method has a default `highWaterMark` of 64 KiB.
187
+ *
188
+ * `options` can include `start` and `end` values to read a range of bytes from
189
+ * the file instead of the entire file. Both `start` and `end` are inclusive and
190
+ * start counting at 0, allowed values are in the
191
+ * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `start` is
192
+ * omitted or `undefined`, `filehandle.createReadStream()` reads sequentially from
193
+ * the current file position. The `encoding` can be any one of those accepted by `Buffer`.
194
+ *
195
+ * If the `FileHandle` points to a character device that only supports blocking
196
+ * reads (such as keyboard or sound card), read operations do not finish until data
197
+ * is available. This can prevent the process from exiting and the stream from
198
+ * closing naturally.
199
+ *
200
+ * By default, the stream will emit a `'close'` event after it has been
201
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
202
+ *
203
+ * ```js
204
+ * import { open } from 'node:fs/promises';
205
+ *
206
+ * const fd = await open('/dev/input/event0');
207
+ * // Create a stream from some character device.
208
+ * const stream = fd.createReadStream();
209
+ * setTimeout(() => {
210
+ * stream.close(); // This may not close the stream.
211
+ * // Artificially marking end-of-stream, as if the underlying resource had
212
+ * // indicated end-of-file by itself, allows the stream to close.
213
+ * // This does not cancel pending read operations, and if there is such an
214
+ * // operation, the process may still not be able to exit successfully
215
+ * // until it finishes.
216
+ * stream.push(null);
217
+ * stream.read(0);
218
+ * }, 100);
219
+ * ```
220
+ *
221
+ * If `autoClose` is false, then the file descriptor won't be closed, even if
222
+ * there's an error. It is the application's responsibility to close it and make
223
+ * sure there's no file descriptor leak. If `autoClose` is set to true (default
224
+ * behavior), on `'error'` or `'end'` the file descriptor will be closed
225
+ * automatically.
226
+ *
227
+ * An example to read the last 10 bytes of a file which is 100 bytes long:
228
+ *
229
+ * ```js
230
+ * import { open } from 'node:fs/promises';
231
+ *
232
+ * const fd = await open('sample.txt');
233
+ * fd.createReadStream({ start: 90, end: 99 });
234
+ * ```
235
+ * @since v16.11.0
236
+ */
237
+ createReadStream(options?: CreateReadStreamOptions): ReadStream;
238
+ /**
239
+ * `options` may also include a `start` option to allow writing data at some
240
+ * position past the beginning of the file, allowed values are in the
241
+ * \[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
242
+ * replacing it may require the `flags` `open` option to be set to `r+` rather than
243
+ * the default `r`. The `encoding` can be any one of those accepted by `Buffer`.
244
+ *
245
+ * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'` the file descriptor will be closed automatically. If `autoClose` is false,
246
+ * then the file descriptor won't be closed, even if there's an error.
247
+ * It is the application's responsibility to close it and make sure there's no
248
+ * file descriptor leak.
249
+ *
250
+ * By default, the stream will emit a `'close'` event after it has been
251
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
252
+ * @since v16.11.0
253
+ */
254
+ createWriteStream(options?: CreateWriteStreamOptions): WriteStream;
255
+ /**
256
+ * Forces all currently queued I/O operations associated with the file to the
257
+ * 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.
258
+ *
259
+ * Unlike `filehandle.sync` this method does not flush modified metadata.
260
+ * @since v10.0.0
261
+ * @return Fulfills with `undefined` upon success.
262
+ */
263
+ datasync(): Promise<void>;
264
+ /**
265
+ * Return the file contents as an async iterable using the
266
+ * [`node:stream/iter`](https://nodejs.org/docs/latest-v26.x/api/stream_iter.html) pull model. Reads are performed in `chunkSize`-byte
267
+ * chunks (default 128 KB). If transforms are provided, they are applied
268
+ * via [`stream/iter pull()`](https://nodejs.org/docs/latest-v26.x/api/stream_iter.html#pullsource-transforms-options).
269
+ *
270
+ * The file handle is locked while the iterable is being consumed and unlocked
271
+ * when iteration completes, an error occurs, or the consumer breaks.
272
+ *
273
+ * This function is only available when the `--experimental-stream-iter` flag is
274
+ * enabled.
275
+ *
276
+ * ```js
277
+ * import { open } from 'node:fs/promises';
278
+ * import { text } from 'node:stream/iter';
279
+ * import { compressGzip } from 'node:zlib/iter';
280
+ *
281
+ * const fh = await open('input.txt', 'r');
282
+ *
283
+ * // Read as text
284
+ * console.log(await text(fh.pull({ autoClose: true })));
285
+ *
286
+ * // Read 1 KB starting at byte 100
287
+ * const fh2 = await open('input.txt', 'r');
288
+ * console.log(await text(fh2.pull({ start: 100, limit: 1024, autoClose: true })));
289
+ *
290
+ * // Read with compression
291
+ * const fh3 = await open('input.txt', 'r');
292
+ * const compressed = fh3.pull(compressGzip(), { autoClose: true });
293
+ * ```
294
+ * @since v25.9.0
295
+ * @experimental
296
+ */
297
+ pull(...transforms: Transform[]): ByteReadableStream;
298
+ pull(...args: [...transforms: Transform[], options: PullOptions]): ByteReadableStream;
299
+ /**
300
+ * Request that all data for the open file descriptor is flushed to the storage
301
+ * device. The specific implementation is operating system and device specific.
302
+ * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail.
303
+ * @since v10.0.0
304
+ * @return Fulfills with `undefined` upon success.
305
+ */
306
+ sync(): Promise<void>;
307
+ /**
308
+ * Reads data from the file and stores that in the given buffer.
309
+ *
310
+ * If the file is not modified concurrently, the end-of-file is reached when the
311
+ * number of bytes read is zero.
312
+ * @since v10.0.0
313
+ * @param buffer A buffer that will be filled with the file data read.
314
+ * @param offset The location in the buffer at which to start filling.
315
+ * @param length The number of bytes to read.
316
+ * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an
317
+ * integer, the current file position will remain unchanged.
318
+ * @return Fulfills upon success with an object with two properties:
319
+ */
320
+ read<T extends NodeJS.ArrayBufferView>(
321
+ buffer: T,
322
+ offset?: number | null,
323
+ length?: number | null,
324
+ position?: ReadPosition | null,
325
+ ): Promise<FileReadResult<T>>;
326
+ read<T extends NodeJS.ArrayBufferView>(
327
+ buffer: T,
328
+ options?: ReadOptions,
329
+ ): Promise<FileReadResult<T>>;
330
+ read<T extends NodeJS.ArrayBufferView = NonSharedBuffer>(
331
+ options?: ReadOptionsWithBuffer<T>,
332
+ ): Promise<FileReadResult<T>>;
333
+ /**
334
+ * Returns a byte-oriented `ReadableStream` that may be used to read the file's
335
+ * contents.
336
+ *
337
+ * An error will be thrown if this method is called more than once or is called
338
+ * after the `FileHandle` is closed or closing.
339
+ *
340
+ * ```js
341
+ * import {
342
+ * open,
343
+ * } from 'node:fs/promises';
344
+ *
345
+ * const file = await open('./some/file/to/read');
346
+ *
347
+ * for await (const chunk of file.readableWebStream())
348
+ * console.log(chunk);
349
+ *
350
+ * await file.close();
351
+ * ```
352
+ *
353
+ * While the `ReadableStream` will read the file to completion, it will not
354
+ * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
355
+ * @since v17.0.0
356
+ */
357
+ readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
358
+ /**
359
+ * Asynchronously reads the entire contents of a file.
360
+ *
361
+ * If `options` is a string, then it specifies the `encoding`.
362
+ *
363
+ * If `buffer` is provided and no encoding is specified, the returned {Buffer} is
364
+ * a view over the supplied buffer containing only the bytes read. If the
365
+ * supplied buffer is too small to contain the entire file, the operation will
366
+ * fail.
367
+ *
368
+ * The `FileHandle` has to support reading.
369
+ *
370
+ * If one or more `filehandle.read()` calls are made on a file handle and then a
371
+ * `filehandle.readFile()` call is made, the data will be read from the current
372
+ * position till the end of the file. It doesn't always read from the beginning
373
+ * of the file.
374
+ *
375
+ * An example using the `buffer` option with a pre-allocated buffer:
376
+ *
377
+ * ```js
378
+ * import { Buffer } from 'node:buffer';
379
+ * import { open } from 'node:fs/promises';
380
+ *
381
+ * const file = await open('./some/file/to/read');
382
+ * try {
383
+ * const buf = Buffer.alloc(16384);
384
+ * const contents = await file.readFile({ buffer: buf });
385
+ * console.log(contents); // A view over `buf` containing only the bytes read
386
+ * } finally {
387
+ * await file.close();
388
+ * }
389
+ * ```
390
+ *
391
+ * An example using the `buffer` option with a function returning a buffer:
392
+ *
393
+ * ```js
394
+ * import { Buffer } from 'node:buffer';
395
+ * import { open } from 'node:fs/promises';
396
+ *
397
+ * const file = await open('./some/file/to/read');
398
+ * try {
399
+ * const contents = await file.readFile({
400
+ * buffer: (size) => Buffer.alloc(size),
401
+ * });
402
+ * console.log(contents);
403
+ * } finally {
404
+ * await file.close();
405
+ * }
406
+ * ```
407
+ * @since v10.0.0
408
+ * @returns Fulfills upon a successful read with the contents of the
409
+ * file. If no encoding is specified (using `options.encoding`), the data is
410
+ * returned as a `Buffer` object. Otherwise, the data will be a string.
411
+ */
412
+ readFile<T extends NodeJS.ArrayBufferView>(
413
+ options: Omit<ReadFileOptionsWithBuffer<T>, "flag">,
414
+ ): Promise<BufferView<T>>;
415
+ readFile(options?: Omit<ReadFileOptionsWithBufferEncoding, "flag"> | null): Promise<NonSharedBuffer>;
416
+ readFile(options: Omit<ReadFileOptionsWithStringEncoding, "flag"> | BufferEncoding): Promise<string>;
417
+ readFile(options: Omit<ReadFileOptions, "flag"> | BufferEncoding | null): Promise<string | NonSharedBuffer>;
418
+ /**
419
+ * Convenience method to create a `readline` interface and stream over the file.
420
+ * See `filehandle.createReadStream()` for the options.
421
+ *
422
+ * ```js
423
+ * import { open } from 'node:fs/promises';
424
+ *
425
+ * const file = await open('./some/file/to/read');
426
+ *
427
+ * for await (const line of file.readLines()) {
428
+ * console.log(line);
429
+ * }
430
+ * ```
431
+ * @since v18.11.0
432
+ */
433
+ readLines(options?: CreateReadStreamOptions): ReadlineInterface;
434
+ /**
435
+ * @since v10.0.0
436
+ * @return Fulfills with an {fs.Stats} for the file.
437
+ */
438
+ stat(
439
+ opts?: StatOptions & {
440
+ bigint?: false | undefined;
441
+ },
442
+ ): Promise<Stats>;
443
+ stat(
444
+ opts: StatOptions & {
445
+ bigint: true;
446
+ },
447
+ ): Promise<BigIntStats>;
448
+ stat(opts?: StatOptions): Promise<Stats | BigIntStats>;
449
+ /**
450
+ * Truncates the file.
451
+ *
452
+ * If the file was larger than `len` bytes, only the first `len` bytes will be
453
+ * retained in the file.
454
+ *
455
+ * The following example retains only the first four bytes of the file:
456
+ *
457
+ * ```js
458
+ * import { open } from 'node:fs/promises';
459
+ *
460
+ * let filehandle = null;
461
+ * try {
462
+ * filehandle = await open('temp.txt', 'r+');
463
+ * await filehandle.truncate(4);
464
+ * } finally {
465
+ * await filehandle?.close();
466
+ * }
467
+ * ```
468
+ *
469
+ * If the file previously was shorter than `len` bytes, it is extended, and the
470
+ * extended part is filled with null bytes (`'\0'`):
471
+ *
472
+ * If `len` is negative then `0` will be used.
473
+ * @since v10.0.0
474
+ * @param [len=0]
475
+ * @return Fulfills with `undefined` upon success.
476
+ */
477
+ truncate(len?: number): Promise<void>;
478
+ /**
479
+ * Change the file system timestamps of the object referenced by the `FileHandle` then fulfills the promise with no arguments upon success.
480
+ * @since v10.0.0
481
+ */
482
+ utimes(atime: TimeLike, mtime: TimeLike): Promise<void>;
483
+ /**
484
+ * Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
485
+ * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
486
+ * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
487
+ * The promise is fulfilled with no arguments upon success.
488
+ *
489
+ * If `options` is a string, then it specifies the `encoding`.
490
+ *
491
+ * The `FileHandle` has to support writing.
492
+ *
493
+ * It is unsafe to use `filehandle.writeFile()` multiple times on the same file
494
+ * without waiting for the promise to be fulfilled (or rejected).
495
+ *
496
+ * If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the
497
+ * current position till the end of the file. It doesn't always write from the
498
+ * beginning of the file.
499
+ * @since v10.0.0
500
+ */
501
+ writeFile(
502
+ data:
503
+ | string
504
+ | NodeJS.ArrayBufferView
505
+ | Iterable<string | NodeJS.ArrayBufferView>
506
+ | AsyncIterable<string | NodeJS.ArrayBufferView>,
507
+ options?:
508
+ | (ObjectEncodingOptions & Abortable)
509
+ | BufferEncoding
510
+ | null,
511
+ ): Promise<void>;
512
+ /**
513
+ * Write `buffer` to the file.
514
+ *
515
+ * The promise is fulfilled with an object containing two properties:
516
+ *
517
+ * It is unsafe to use `filehandle.write()` multiple times on the same file
518
+ * without waiting for the promise to be fulfilled (or rejected). For this
519
+ * scenario, use `filehandle.createWriteStream()`.
520
+ *
521
+ * On Linux, positional writes do not work when the file is opened in append mode.
522
+ * The kernel ignores the position argument and always appends the data to
523
+ * the end of the file.
524
+ * @since v10.0.0
525
+ * @param offset The start position from within `buffer` where the data to write begins.
526
+ * @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write.
527
+ * @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current
528
+ * position. See the POSIX pwrite(2) documentation for more detail.
529
+ */
530
+ write<TBuffer extends NodeJS.ArrayBufferView>(
531
+ buffer: TBuffer,
532
+ offset?: number | null,
533
+ length?: number | null,
534
+ position?: number | null,
535
+ ): Promise<{
536
+ bytesWritten: number;
537
+ buffer: TBuffer;
538
+ }>;
539
+ write<TBuffer extends Uint8Array>(
540
+ buffer: TBuffer,
541
+ options?: { offset?: number; length?: number; position?: number },
542
+ ): Promise<{
543
+ bytesWritten: number;
544
+ buffer: TBuffer;
545
+ }>;
546
+ write(
547
+ data: string,
548
+ position?: number | null,
549
+ encoding?: BufferEncoding | null,
550
+ ): Promise<{
551
+ bytesWritten: number;
552
+ buffer: string;
553
+ }>;
554
+ /**
555
+ * Write an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s to the file.
556
+ *
557
+ * The promise is fulfilled with an object containing a two properties:
558
+ *
559
+ * It is unsafe to call `writev()` multiple times on the same file without waiting
560
+ * for the promise to be fulfilled (or rejected).
561
+ *
562
+ * On Linux, positional writes don't work when the file is opened in append mode.
563
+ * The kernel ignores the position argument and always appends the data to
564
+ * the end of the file.
565
+ * @since v12.9.0
566
+ * @param [position='null'] The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current
567
+ * position.
568
+ */
569
+ writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
570
+ buffers: TBuffers,
571
+ position?: number,
572
+ ): Promise<WriteVResult<TBuffers>>;
573
+ /**
574
+ * Return a [`node:stream/iter`](https://nodejs.org/docs/latest-v26.x/api/stream_iter.html) writer backed by this file handle.
575
+ *
576
+ * The writer supports both `Symbol.asyncDispose` and `Symbol.dispose`:
577
+ *
578
+ * * `await using w = fh.writer()` — if the writer is still open (no `end()`
579
+ * called), `asyncDispose` calls `fail()`. If `end()` is pending, it waits
580
+ * for it to complete.
581
+ * * `using w = fh.writer()` — calls `fail()` unconditionally.
582
+ *
583
+ * The `writeSync()` and `writevSync()` methods enable the try-sync fast path
584
+ * used by [`stream/iter pipeTo()`](https://nodejs.org/docs/latest-v26.x/api/stream_iter.html#pipetosource-transforms-writer). When the reader's chunk size matches the
585
+ * writer's `chunkSize`, all writes in a `pipeTo()` pipeline complete
586
+ * synchronously with zero promise overhead.
587
+ *
588
+ * This function is only available when the `--experimental-stream-iter` flag is
589
+ * enabled.
590
+ *
591
+ * ```js
592
+ * import { open } from 'node:fs/promises';
593
+ * import { from, pipeTo } from 'node:stream/iter';
594
+ * import { compressGzip } from 'node:zlib/iter';
595
+ *
596
+ * // Async pipeline
597
+ * const fh = await open('output.gz', 'w');
598
+ * await pipeTo(from('Hello!'), compressGzip(), fh.writer({ autoClose: true }));
599
+ *
600
+ * // Sync pipeline with limit
601
+ * const src = await open('input.txt', 'r');
602
+ * const dst = await open('output.txt', 'w');
603
+ * const w = dst.writer({ limit: 1024 * 1024 }); // Max 1 MB
604
+ * await pipeTo(src.pull({ autoClose: true }), w);
605
+ * await w.end();
606
+ * await dst.close();
607
+ * ```
608
+ * @since v25.9.0
609
+ * @experimental
610
+ */
611
+ writer(options?: WriterOptions): Writer;
612
+ /**
613
+ * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
614
+ * @since v13.13.0, v12.17.0
615
+ * @param [position='null'] The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position.
616
+ * @return Fulfills upon success an object containing two properties:
617
+ */
618
+ readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
619
+ buffers: TBuffers,
620
+ position?: number,
621
+ ): Promise<ReadVResult<TBuffers>>;
622
+ /**
623
+ * Closes the file handle after waiting for any pending operation on the handle to
624
+ * complete.
625
+ *
626
+ * ```js
627
+ * import { open } from 'node:fs/promises';
628
+ *
629
+ * let filehandle;
630
+ * try {
631
+ * filehandle = await open('thefile.txt', 'r');
632
+ * } finally {
633
+ * await filehandle?.close();
634
+ * }
635
+ * ```
636
+ * @since v10.0.0
637
+ * @return Fulfills with `undefined` upon success.
638
+ */
639
+ close(): Promise<void>;
640
+ /**
641
+ * Calls `filehandle.close()` and returns a promise that fulfills when the
642
+ * filehandle is closed.
643
+ * @since v20.4.0, v18.8.0
644
+ */
645
+ [Symbol.asyncDispose](): Promise<void>;
646
+ }
647
+ const constants: typeof fsConstants;
648
+ /**
649
+ * Tests a user's permissions for the file or directory specified by `path`.
650
+ * The `mode` argument is an optional integer that specifies the accessibility
651
+ * 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`
652
+ * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
653
+ * possible values of `mode`.
654
+ *
655
+ * If the accessibility check is successful, the promise is fulfilled with no
656
+ * value. If any of the accessibility checks fail, the promise is rejected
657
+ * with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and
658
+ * written by the current process.
659
+ *
660
+ * ```js
661
+ * import { access, constants } from 'node:fs/promises';
662
+ *
663
+ * try {
664
+ * await access('/etc/passwd', constants.R_OK | constants.W_OK);
665
+ * console.log('can access');
666
+ * } catch {
667
+ * console.error('cannot access');
668
+ * }
669
+ * ```
670
+ *
671
+ * Using `fsPromises.access()` to check for the accessibility of a file before
672
+ * calling `fsPromises.open()` is not recommended. Doing so introduces a race
673
+ * condition, since other processes may change the file's state between the two
674
+ * calls. Instead, user code should open/read/write the file directly and handle
675
+ * the error raised if the file is not accessible.
676
+ * @since v10.0.0
677
+ * @param [mode=fs.constants.F_OK]
678
+ * @return Fulfills with `undefined` upon success.
679
+ */
680
+ function access(path: PathLike, mode?: number): Promise<void>;
681
+ /**
682
+ * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
683
+ * already exists.
684
+ *
685
+ * No guarantees are made about the atomicity of the copy operation. If an
686
+ * error occurs after the destination file has been opened for writing, an attempt
687
+ * will be made to remove the destination.
688
+ *
689
+ * ```js
690
+ * import { copyFile, constants } from 'node:fs/promises';
691
+ *
692
+ * try {
693
+ * await copyFile('source.txt', 'destination.txt');
694
+ * console.log('source.txt was copied to destination.txt');
695
+ * } catch {
696
+ * console.error('The file could not be copied');
697
+ * }
698
+ *
699
+ * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
700
+ * try {
701
+ * await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
702
+ * console.log('source.txt was copied to destination.txt');
703
+ * } catch {
704
+ * console.error('The file could not be copied');
705
+ * }
706
+ * ```
707
+ * @since v10.0.0
708
+ * @param src source filename to copy
709
+ * @param dest destination filename of the copy operation
710
+ * @param [mode=0] Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.
711
+ * `fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`)
712
+ * @return Fulfills with `undefined` upon success.
713
+ */
714
+ function copyFile(src: PathLike, dest: PathLike, mode?: number): Promise<void>;
715
+ /**
716
+ * Opens a `FileHandle`.
717
+ *
718
+ * Refer to the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more detail.
719
+ *
720
+ * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
721
+ * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
722
+ * 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).
723
+ * @since v10.0.0
724
+ * @param [flags='r'] See `support of file system `flags``.
725
+ * @param [mode=0o666] Sets the file mode (permission and sticky bits) if the file is created.
726
+ * @return Fulfills with a {FileHandle} object.
727
+ */
728
+ function open(path: PathLike, flags?: string | number, mode?: Mode): Promise<FileHandle>;
729
+ /**
730
+ * Renames `oldPath` to `newPath`.
731
+ * @since v10.0.0
732
+ * @return Fulfills with `undefined` upon success.
733
+ */
734
+ function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
735
+ /**
736
+ * Truncates (shortens or extends the length) of the content at `path` to `len` bytes.
737
+ * @since v10.0.0
738
+ * @param [len=0]
739
+ * @return Fulfills with `undefined` upon success.
740
+ */
741
+ function truncate(path: PathLike, len?: number): Promise<void>;
742
+ /**
743
+ * Removes the directory identified by `path`.
744
+ *
745
+ * Using `fsPromises.rmdir()` on a file (not a directory) results in the
746
+ * promise being rejected with an `ENOENT` error on Windows and an `ENOTDIR` error on POSIX.
747
+ *
748
+ * To get a behavior similar to the `rm -rf` Unix command, use `fsPromises.rm()` with options `{ recursive: true, force: true }`.
749
+ * @since v10.0.0
750
+ * @return Fulfills with `undefined` upon success.
751
+ */
752
+ function rmdir(path: PathLike): Promise<void>;
753
+ /**
754
+ * Removes files and directories (modeled on the standard POSIX `rm` utility).
755
+ * @since v14.14.0
756
+ * @return Fulfills with `undefined` upon success.
757
+ */
758
+ function rm(path: PathLike, options?: RmOptions): Promise<void>;
759
+ /**
760
+ * Asynchronously creates a directory.
761
+ *
762
+ * The optional `options` argument can be an integer specifying `mode` (permission
763
+ * and sticky bits), or an object with a `mode` property and a `recursive` property indicating whether parent directories should be created. Calling `fsPromises.mkdir()` when `path` is a directory
764
+ * that exists results in a
765
+ * rejection only when `recursive` is false.
766
+ *
767
+ * ```js
768
+ * import { mkdir } from 'node:fs/promises';
769
+ *
770
+ * try {
771
+ * const projectFolder = new URL('./test/project/', import.meta.url);
772
+ * const createDir = await mkdir(projectFolder, { recursive: true });
773
+ *
774
+ * console.log(`created ${createDir}`);
775
+ * } catch (err) {
776
+ * console.error(err.message);
777
+ * }
778
+ * ```
779
+ * @since v10.0.0
780
+ * @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`.
781
+ */
782
+ function mkdir(
783
+ path: PathLike,
784
+ options: MakeDirectoryOptions & {
785
+ recursive: true;
786
+ },
787
+ ): Promise<string | undefined>;
788
+ /**
789
+ * Asynchronous mkdir(2) - create a directory.
790
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
791
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
792
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
793
+ */
794
+ function mkdir(
795
+ path: PathLike,
796
+ options?:
797
+ | Mode
798
+ | (MakeDirectoryOptions & {
799
+ recursive?: false | undefined;
800
+ })
801
+ | null,
802
+ ): Promise<void>;
803
+ /**
804
+ * Asynchronous mkdir(2) - create a directory.
805
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
806
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
807
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
808
+ */
809
+ function mkdir(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
810
+ /**
811
+ * Reads the contents of a directory.
812
+ *
813
+ * The optional `options` argument can be a string specifying an encoding, or an
814
+ * object with an `encoding` property specifying the character encoding to use for
815
+ * the filenames. If the `encoding` is set to `'buffer'`, the filenames returned
816
+ * will be passed as `Buffer` objects.
817
+ *
818
+ * If `options.withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects.
819
+ *
820
+ * ```js
821
+ * import { readdir } from 'node:fs/promises';
822
+ *
823
+ * try {
824
+ * const files = await readdir(path);
825
+ * for (const file of files)
826
+ * console.log(file);
827
+ * } catch (err) {
828
+ * console.error(err);
829
+ * }
830
+ * ```
831
+ * @since v10.0.0
832
+ * @return Fulfills with an array of the names of the files in the directory excluding `'.'` and `'..'`.
833
+ */
834
+ function readdir(
835
+ path: PathLike,
836
+ options?:
837
+ | (ObjectEncodingOptions & {
838
+ withFileTypes?: false | undefined;
839
+ recursive?: boolean | undefined;
840
+ })
841
+ | BufferEncoding
842
+ | null,
843
+ ): Promise<string[]>;
844
+ /**
845
+ * Asynchronous readdir(3) - read a directory.
846
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
847
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
848
+ */
849
+ function readdir(
850
+ path: PathLike,
851
+ options:
852
+ | {
853
+ encoding: "buffer";
854
+ withFileTypes?: false | undefined;
855
+ recursive?: boolean | undefined;
856
+ }
857
+ | "buffer",
858
+ ): Promise<NonSharedBuffer[]>;
859
+ /**
860
+ * Asynchronous readdir(3) - read a directory.
861
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
862
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
863
+ */
864
+ function readdir(
865
+ path: PathLike,
866
+ options?:
867
+ | (ObjectEncodingOptions & {
868
+ withFileTypes?: false | undefined;
869
+ recursive?: boolean | undefined;
870
+ })
871
+ | BufferEncoding
872
+ | null,
873
+ ): Promise<string[] | NonSharedBuffer[]>;
874
+ /**
875
+ * Asynchronous readdir(3) - read a directory.
876
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
877
+ * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
878
+ */
879
+ function readdir(
880
+ path: PathLike,
881
+ options: ObjectEncodingOptions & {
882
+ withFileTypes: true;
883
+ recursive?: boolean | undefined;
884
+ },
885
+ ): Promise<Dirent[]>;
886
+ /**
887
+ * Asynchronous readdir(3) - read a directory.
888
+ * @param path A path to a directory. If a URL is provided, it must use the `file:` protocol.
889
+ * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
890
+ */
891
+ function readdir(
892
+ path: PathLike,
893
+ options: {
894
+ encoding: "buffer";
895
+ withFileTypes: true;
896
+ recursive?: boolean | undefined;
897
+ },
898
+ ): Promise<Dirent<NonSharedBuffer>[]>;
899
+ /**
900
+ * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
901
+ * fulfilled with the`linkString` upon success.
902
+ *
903
+ * The optional `options` argument can be a string specifying an encoding, or an
904
+ * object with an `encoding` property specifying the character encoding to use for
905
+ * the link path returned. If the `encoding` is set to `'buffer'`, the link path
906
+ * returned will be passed as a `Buffer` object.
907
+ * @since v10.0.0
908
+ * @return Fulfills with the `linkString` upon success.
909
+ */
910
+ function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
911
+ /**
912
+ * Asynchronous readlink(2) - read value of a symbolic link.
913
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
914
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
915
+ */
916
+ function readlink(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
917
+ /**
918
+ * Asynchronous readlink(2) - read value of a symbolic link.
919
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
920
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
921
+ */
922
+ function readlink(
923
+ path: PathLike,
924
+ options?: ObjectEncodingOptions | string | null,
925
+ ): Promise<string | NonSharedBuffer>;
926
+ /**
927
+ * Creates a symbolic link.
928
+ *
929
+ * The `type` argument is only used on Windows platforms and can be one of `'dir'`, `'file'`, or `'junction'`. If the `type` argument is not a string, Node.js will
930
+ * autodetect `target` type and use `'file'` or `'dir'`. If the `target` does not
931
+ * exist, `'file'` will be used. Windows junction points require the destination
932
+ * path to be absolute. When using `'junction'`, the `target` argument will
933
+ * automatically be normalized to absolute path. Junction points on NTFS volumes
934
+ * can only point to directories.
935
+ * @since v10.0.0
936
+ * @param [type='null']
937
+ * @return Fulfills with `undefined` upon success.
938
+ */
939
+ function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
940
+ /**
941
+ * Equivalent to `fsPromises.stat()` unless `path` refers to a symbolic link,
942
+ * in which case the link itself is stat-ed, not the file that it refers to.
943
+ * Refer to the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) document for more detail.
944
+ * @since v10.0.0
945
+ * @return Fulfills with the {fs.Stats} object for the given symbolic link `path`.
946
+ */
947
+ function lstat(
948
+ path: PathLike,
949
+ opts?: StatOptions & {
950
+ bigint?: false | undefined;
951
+ },
952
+ ): Promise<Stats>;
953
+ function lstat(
954
+ path: PathLike,
955
+ opts: StatOptions & {
956
+ bigint: true;
957
+ },
958
+ ): Promise<BigIntStats>;
959
+ function lstat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
960
+ /**
961
+ * @since v10.0.0
962
+ * @return Fulfills with the {fs.Stats} object for the given `path`.
963
+ */
964
+ function stat(path: PathLike): Promise<Stats>;
965
+ function stat(
966
+ path: PathLike,
967
+ opts?: StatOptions & {
968
+ bigint?: false | undefined;
969
+ throwIfNoEntry?: true | undefined;
970
+ },
971
+ ): Promise<Stats>;
972
+ function stat(
973
+ path: PathLike,
974
+ opts: StatOptions & {
975
+ bigint: true;
976
+ throwIfNoEntry?: true | undefined;
977
+ },
978
+ ): Promise<BigIntStats>;
979
+ function stat(
980
+ path: PathLike,
981
+ opts: StatOptions & {
982
+ bigint?: false | undefined;
983
+ throwIfNoEntry: false;
984
+ },
985
+ ): Promise<Stats | undefined>;
986
+ function stat(
987
+ path: PathLike,
988
+ opts: StatOptions & {
989
+ bigint: true;
990
+ throwIfNoEntry: false;
991
+ },
992
+ ): Promise<BigIntStats | undefined>;
993
+ function stat(
994
+ path: PathLike,
995
+ opts: StatOptions & {
996
+ throwIfNoEntry?: true | undefined;
997
+ },
998
+ ): Promise<Stats | BigIntStats>;
999
+ function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats | undefined>;
1000
+ /**
1001
+ * @since v19.6.0, v18.15.0
1002
+ * @return Fulfills with the {fs.StatFs} object for the given `path`.
1003
+ */
1004
+ function statfs(
1005
+ path: PathLike,
1006
+ opts?: StatFsOptions & {
1007
+ bigint?: false | undefined;
1008
+ },
1009
+ ): Promise<StatsFs>;
1010
+ function statfs(
1011
+ path: PathLike,
1012
+ opts: StatFsOptions & {
1013
+ bigint: true;
1014
+ },
1015
+ ): Promise<BigIntStatsFs>;
1016
+ function statfs(path: PathLike, opts?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;
1017
+ /**
1018
+ * 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.
1019
+ * @since v10.0.0
1020
+ * @return Fulfills with `undefined` upon success.
1021
+ */
1022
+ function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
1023
+ /**
1024
+ * If `path` refers to a symbolic link, then the link is removed without affecting
1025
+ * the file or directory to which that link refers. If the `path` refers to a file
1026
+ * path that is not a symbolic link, the file is deleted. See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more detail.
1027
+ * @since v10.0.0
1028
+ * @return Fulfills with `undefined` upon success.
1029
+ */
1030
+ function unlink(path: PathLike): Promise<void>;
1031
+ /**
1032
+ * Changes the permissions of a file.
1033
+ * @since v10.0.0
1034
+ * @return Fulfills with `undefined` upon success.
1035
+ */
1036
+ function chmod(path: PathLike, mode: Mode): Promise<void>;
1037
+ /**
1038
+ * Changes the permissions on a symbolic link.
1039
+ *
1040
+ * This method is only implemented on macOS.
1041
+ * @deprecated Since v10.0.0
1042
+ * @return Fulfills with `undefined` upon success.
1043
+ */
1044
+ function lchmod(path: PathLike, mode: Mode): Promise<void>;
1045
+ /**
1046
+ * Changes the ownership on a symbolic link.
1047
+ * @since v10.0.0
1048
+ * @return Fulfills with `undefined` upon success.
1049
+ */
1050
+ function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
1051
+ /**
1052
+ * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, with the difference that if the path refers to a
1053
+ * symbolic link, then the link is not dereferenced: instead, the timestamps of
1054
+ * the symbolic link itself are changed.
1055
+ * @since v14.5.0, v12.19.0
1056
+ * @return Fulfills with `undefined` upon success.
1057
+ */
1058
+ function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
1059
+ /**
1060
+ * Changes the ownership of a file.
1061
+ * @since v10.0.0
1062
+ * @return Fulfills with `undefined` upon success.
1063
+ */
1064
+ function chown(path: PathLike, uid: number, gid: number): Promise<void>;
1065
+ /**
1066
+ * Change the file system timestamps of the object referenced by `path`.
1067
+ *
1068
+ * The `atime` and `mtime` arguments follow these rules:
1069
+ *
1070
+ * * Values can be either numbers representing Unix epoch time, `Date`s, or a
1071
+ * numeric string like `'123456789.0'`.
1072
+ * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or `-Infinity`, an `Error` will be thrown.
1073
+ * @since v10.0.0
1074
+ * @return Fulfills with `undefined` upon success.
1075
+ */
1076
+ function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
1077
+ /**
1078
+ * Determines the actual location of `path` using the same semantics as the `fs.realpath.native()` function.
1079
+ *
1080
+ * Only paths that can be converted to UTF8 strings are supported.
1081
+ *
1082
+ * The optional `options` argument can be a string specifying an encoding, or an
1083
+ * object with an `encoding` property specifying the character encoding to use for
1084
+ * the path. If the `encoding` is set to `'buffer'`, the path returned will be
1085
+ * passed as a `Buffer` object.
1086
+ *
1087
+ * On Linux, when Node.js is linked against musl libc, the procfs file system must
1088
+ * be mounted on `/proc` in order for this function to work. Glibc does not have
1089
+ * this restriction.
1090
+ * @since v10.0.0
1091
+ * @return Fulfills with the resolved path upon success.
1092
+ */
1093
+ function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
1094
+ /**
1095
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1096
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1097
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1098
+ */
1099
+ function realpath(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1100
+ /**
1101
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1102
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1103
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1104
+ */
1105
+ function realpath(
1106
+ path: PathLike,
1107
+ options?: ObjectEncodingOptions | BufferEncoding | null,
1108
+ ): Promise<string | NonSharedBuffer>;
1109
+ /**
1110
+ * Creates a unique temporary directory. A unique directory name is generated by
1111
+ * appending six random characters to the end of the provided `prefix`. Due to
1112
+ * platform inconsistencies, avoid trailing `X` characters in `prefix`. Some
1113
+ * platforms, notably the BSDs, can return more than six random characters, and
1114
+ * replace trailing `X` characters in `prefix` with random characters.
1115
+ *
1116
+ * The optional `options` argument can be a string specifying an encoding, or an
1117
+ * object with an `encoding` property specifying the character encoding to use.
1118
+ *
1119
+ * ```js
1120
+ * import { mkdtemp } from 'node:fs/promises';
1121
+ * import { join } from 'node:path';
1122
+ * import { tmpdir } from 'node:os';
1123
+ *
1124
+ * try {
1125
+ * await mkdtemp(join(tmpdir(), 'foo-'));
1126
+ * } catch (err) {
1127
+ * console.error(err);
1128
+ * }
1129
+ * ```
1130
+ *
1131
+ * The `fsPromises.mkdtemp()` method will append the six randomly selected
1132
+ * characters directly to the `prefix` string. For instance, given a directory `/tmp`, if the intention is to create a temporary directory _within_ `/tmp`, the `prefix` must end with a trailing
1133
+ * platform-specific path separator
1134
+ * (`import { sep } from 'node:path'`).
1135
+ * @since v10.0.0
1136
+ * @return Fulfills with a string containing the file system path of the newly created temporary directory.
1137
+ */
1138
+ function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
1139
+ /**
1140
+ * Asynchronously creates a unique temporary directory.
1141
+ * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
1142
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1143
+ */
1144
+ function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1145
+ /**
1146
+ * Asynchronously creates a unique temporary directory.
1147
+ * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
1148
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1149
+ */
1150
+ function mkdtemp(
1151
+ prefix: string,
1152
+ options?: ObjectEncodingOptions | BufferEncoding | null,
1153
+ ): Promise<string | NonSharedBuffer>;
1154
+ interface DisposableTempDir extends AsyncDisposable {
1155
+ /**
1156
+ * The path of the created directory.
1157
+ */
1158
+ path: string;
1159
+ /**
1160
+ * A function which removes the created directory.
1161
+ */
1162
+ remove(): Promise<void>;
1163
+ /**
1164
+ * The same as `remove`.
1165
+ */
1166
+ [Symbol.asyncDispose](): Promise<void>;
1167
+ }
1168
+ /**
1169
+ * The resulting Promise holds an async-disposable object whose `path` property
1170
+ * holds the created directory path. When the object is disposed, the directory
1171
+ * and its contents will be removed asynchronously if it still exists. If the
1172
+ * directory cannot be deleted, disposal will throw an error. The object has an
1173
+ * async `remove()` method which will perform the same task.
1174
+ *
1175
+ * Both this function and the disposal function on the resulting object are
1176
+ * async, so it should be used with `await` + `await using` as in
1177
+ * `await using dir = await fsPromises.mkdtempDisposable('prefix')`.
1178
+ *
1179
+ * <!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
1180
+ *
1181
+ * For detailed information, see the documentation of `fsPromises.mkdtemp()`.
1182
+ *
1183
+ * The optional `options` argument can be a string specifying an encoding, or an
1184
+ * object with an `encoding` property specifying the character encoding to use.
1185
+ * @since v24.4.0
1186
+ */
1187
+ function mkdtempDisposable(prefix: PathLike, options?: EncodingOption): Promise<DisposableTempDir>;
1188
+ /**
1189
+ * Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
1190
+ * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
1191
+ * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
1192
+ *
1193
+ * The `encoding` option is ignored if `data` is a buffer.
1194
+ *
1195
+ * If `options` is a string, then it specifies the encoding.
1196
+ *
1197
+ * The `mode` option only affects the newly created file. See `fs.open()` for more details.
1198
+ *
1199
+ * Any specified `FileHandle` has to support writing.
1200
+ *
1201
+ * It is unsafe to use `fsPromises.writeFile()` multiple times on the same file
1202
+ * without waiting for the promise to be settled.
1203
+ *
1204
+ * Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
1205
+ * method that performs multiple `write` calls internally to write the buffer
1206
+ * passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`.
1207
+ *
1208
+ * It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
1209
+ * Cancelation is "best effort", and some amount of data is likely still
1210
+ * to be written.
1211
+ *
1212
+ * ```js
1213
+ * import { writeFile } from 'node:fs/promises';
1214
+ * import { Buffer } from 'node:buffer';
1215
+ *
1216
+ * try {
1217
+ * const controller = new AbortController();
1218
+ * const { signal } = controller;
1219
+ * const data = new Uint8Array(Buffer.from('Hello Node.js'));
1220
+ * const promise = writeFile('message.txt', data, { signal });
1221
+ *
1222
+ * // Abort the request before the promise settles.
1223
+ * controller.abort();
1224
+ *
1225
+ * await promise;
1226
+ * } catch (err) {
1227
+ * // When a request is aborted - err is an AbortError
1228
+ * console.error(err);
1229
+ * }
1230
+ * ```
1231
+ *
1232
+ * Aborting an ongoing request does not abort individual operating
1233
+ * system requests but rather the internal buffering `fs.writeFile` performs.
1234
+ * @since v10.0.0
1235
+ * @param file filename or `FileHandle`
1236
+ * @return Fulfills with `undefined` upon success.
1237
+ */
1238
+ function writeFile(
1239
+ file: PathLike | FileHandle,
1240
+ data:
1241
+ | string
1242
+ | NodeJS.ArrayBufferView
1243
+ | Iterable<string | NodeJS.ArrayBufferView>
1244
+ | AsyncIterable<string | NodeJS.ArrayBufferView>,
1245
+ options?:
1246
+ | (ObjectEncodingOptions & {
1247
+ mode?: Mode | undefined;
1248
+ flag?: OpenMode | undefined;
1249
+ /**
1250
+ * If all data is successfully written to the file, and `flush`
1251
+ * is `true`, `filehandle.sync()` is used to flush the data.
1252
+ * @default false
1253
+ */
1254
+ flush?: boolean | undefined;
1255
+ } & Abortable)
1256
+ | BufferEncoding
1257
+ | null,
1258
+ ): Promise<void>;
1259
+ /**
1260
+ * Asynchronously append data to a file, creating the file if it does not yet
1261
+ * exist. `data` can be a string or a `Buffer`.
1262
+ *
1263
+ * If `options` is a string, then it specifies the `encoding`.
1264
+ *
1265
+ * The `mode` option only affects the newly created file. See `fs.open()` for more details.
1266
+ *
1267
+ * The `path` may be specified as a `FileHandle` that has been opened
1268
+ * for appending (using `fsPromises.open()`).
1269
+ * @since v10.0.0
1270
+ * @param path filename or {FileHandle}
1271
+ * @return Fulfills with `undefined` upon success.
1272
+ */
1273
+ function appendFile(
1274
+ path: PathLike | FileHandle,
1275
+ data:
1276
+ | string
1277
+ | NodeJS.ArrayBufferView
1278
+ | Iterable<string | NodeJS.ArrayBufferView>
1279
+ | AsyncIterable<string | NodeJS.ArrayBufferView>,
1280
+ options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null,
1281
+ ): Promise<void>;
1282
+ /**
1283
+ * Asynchronously reads the entire contents of a file.
1284
+ *
1285
+ * If no encoding is specified (using `options.encoding`), the data is returned
1286
+ * as a `Buffer` object. Otherwise, the data will be a string.
1287
+ *
1288
+ * If `options` is a string, then it specifies the encoding.
1289
+ *
1290
+ * When the `path` is a directory, the behavior of `fsPromises.readFile()` is
1291
+ * platform-specific. On macOS, Linux, and Windows, the promise will be rejected
1292
+ * with an error. On FreeBSD, a representation of the directory's contents will be
1293
+ * returned.
1294
+ *
1295
+ * An example of reading a `package.json` file located in the same directory of the
1296
+ * running code:
1297
+ *
1298
+ * ```js
1299
+ * import { readFile } from 'node:fs/promises';
1300
+ * try {
1301
+ * const filePath = new URL('./package.json', import.meta.url);
1302
+ * const contents = await readFile(filePath, { encoding: 'utf8' });
1303
+ * console.log(contents);
1304
+ * } catch (err) {
1305
+ * console.error(err.message);
1306
+ * }
1307
+ * ```
1308
+ *
1309
+ * It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a
1310
+ * request is aborted the promise returned is rejected with an `AbortError`:
1311
+ *
1312
+ * ```js
1313
+ * import { readFile } from 'node:fs/promises';
1314
+ *
1315
+ * try {
1316
+ * const controller = new AbortController();
1317
+ * const { signal } = controller;
1318
+ * const promise = readFile(fileName, { signal });
1319
+ *
1320
+ * // Abort the request before the promise settles.
1321
+ * controller.abort();
1322
+ *
1323
+ * await promise;
1324
+ * } catch (err) {
1325
+ * // When a request is aborted - err is an AbortError
1326
+ * console.error(err);
1327
+ * }
1328
+ * ```
1329
+ *
1330
+ * Aborting an ongoing request does not abort individual operating
1331
+ * system requests but rather the internal buffering `fs.readFile` performs.
1332
+ *
1333
+ * Any specified `FileHandle` has to support reading.
1334
+ * @since v10.0.0
1335
+ * @param path filename or `FileHandle`
1336
+ * @return Fulfills with the contents of the file.
1337
+ */
1338
+ function readFile<T extends NodeJS.ArrayBufferView>(
1339
+ path: PathLike | FileHandle,
1340
+ options: ReadFileOptionsWithBuffer<T>,
1341
+ ): Promise<BufferView<T>>;
1342
+ function readFile(
1343
+ path: PathLike | FileHandle,
1344
+ options?: ReadFileOptionsWithBufferEncoding | null,
1345
+ ): Promise<NonSharedBuffer>;
1346
+ function readFile(
1347
+ path: PathLike | FileHandle,
1348
+ options: ReadFileOptionsWithStringEncoding | BufferEncoding,
1349
+ ): Promise<string>;
1350
+ function readFile(
1351
+ path: PathLike | FileHandle,
1352
+ options: ReadFileOptions | BufferEncoding | null,
1353
+ ): Promise<string | NonSharedBuffer>;
1354
+ /**
1355
+ * Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.
1356
+ *
1357
+ * Creates an `fs.Dir`, which contains all further functions for reading from
1358
+ * and cleaning up the directory.
1359
+ *
1360
+ * The `encoding` option sets the encoding for the `path` while opening the
1361
+ * directory and subsequent read operations.
1362
+ *
1363
+ * Example using async iteration:
1364
+ *
1365
+ * ```js
1366
+ * import { opendir } from 'node:fs/promises';
1367
+ *
1368
+ * try {
1369
+ * const dir = await opendir('./');
1370
+ * for await (const dirent of dir)
1371
+ * console.log(dirent.name);
1372
+ * } catch (err) {
1373
+ * console.error(err);
1374
+ * }
1375
+ * ```
1376
+ *
1377
+ * When using the async iterator, the `fs.Dir` object will be automatically
1378
+ * closed after the iterator exits.
1379
+ * @since v12.12.0
1380
+ * @return Fulfills with an {fs.Dir}.
1381
+ */
1382
+ function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
1383
+ interface WatchOptions extends _WatchOptions {
1384
+ maxQueue?: number | undefined;
1385
+ overflow?: "ignore" | "throw" | undefined;
1386
+ }
1387
+ interface WatchOptionsWithBufferEncoding extends WatchOptions {
1388
+ encoding: "buffer";
1389
+ }
1390
+ interface WatchOptionsWithStringEncoding extends WatchOptions {
1391
+ encoding?: BufferEncoding | undefined;
1392
+ }
1393
+ /**
1394
+ * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
1395
+ *
1396
+ * ```js
1397
+ * import { watch } from 'node:fs/promises';
1398
+ *
1399
+ * const ac = new AbortController();
1400
+ * const { signal } = ac;
1401
+ * setTimeout(() => ac.abort(), 10000);
1402
+ *
1403
+ * (async () => {
1404
+ * try {
1405
+ * const watcher = watch(__filename, { signal });
1406
+ * for await (const event of watcher)
1407
+ * console.log(event);
1408
+ * } catch (err) {
1409
+ * if (err.name === 'AbortError')
1410
+ * return;
1411
+ * throw err;
1412
+ * }
1413
+ * })();
1414
+ * ```
1415
+ *
1416
+ * On most platforms, `'rename'` is emitted whenever a filename appears or
1417
+ * disappears in the directory.
1418
+ *
1419
+ * All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`.
1420
+ * @since v15.9.0, v14.18.0
1421
+ * @return of objects with the properties:
1422
+ */
1423
+ function watch(
1424
+ filename: PathLike,
1425
+ options?: WatchOptionsWithStringEncoding | BufferEncoding,
1426
+ ): NodeJS.AsyncIterator<FileChangeInfo<string>>;
1427
+ function watch(
1428
+ filename: PathLike,
1429
+ options: WatchOptionsWithBufferEncoding | "buffer",
1430
+ ): NodeJS.AsyncIterator<FileChangeInfo<NonSharedBuffer>>;
1431
+ function watch(
1432
+ filename: PathLike,
1433
+ options: WatchOptions | BufferEncoding | "buffer",
1434
+ ): NodeJS.AsyncIterator<FileChangeInfo<string | NonSharedBuffer>>;
1435
+ /**
1436
+ * Asynchronously copies the entire directory structure from `src` to `dest`,
1437
+ * including subdirectories and files.
1438
+ *
1439
+ * When copying a directory to another directory, globs are not supported and
1440
+ * behavior is similar to `cp dir1/ dir2/`.
1441
+ * @since v16.7.0
1442
+ * @param src source path to copy.
1443
+ * @param dest destination path to copy to.
1444
+ * @return Fulfills with `undefined` upon success.
1445
+ */
1446
+ function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
1447
+ /**
1448
+ * When `followSymlinks` is enabled, detected symbolic link cycles are not
1449
+ * traversed recursively.
1450
+ *
1451
+ * ```js
1452
+ * import { glob } from 'node:fs/promises';
1453
+ *
1454
+ * for await (const entry of glob('*.js'))
1455
+ * console.log(entry);
1456
+ * ```
1457
+ * @since v22.0.0
1458
+ * @returns An AsyncIterator that yields the paths of files
1459
+ * that match the pattern.
1460
+ */
1461
+ function glob(pattern: string | readonly string[]): NodeJS.AsyncIterator<string>;
1462
+ function glob(
1463
+ pattern: string | readonly string[],
1464
+ options: GlobOptionsWithFileTypes,
1465
+ ): NodeJS.AsyncIterator<Dirent>;
1466
+ function glob(
1467
+ pattern: string | readonly string[],
1468
+ options: GlobOptionsWithoutFileTypes,
1469
+ ): NodeJS.AsyncIterator<string>;
1470
+ function glob(
1471
+ pattern: string | readonly string[],
1472
+ options: GlobOptions,
1473
+ ): NodeJS.AsyncIterator<Dirent | string>;
1474
+ }
1475
+ declare module "fs/promises" {
1476
+ export * from "node:fs/promises";
1477
+ }