modelmix 2.3.8 → 2.4.2

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