@visulima/fs 5.0.0-alpha.3 → 5.0.0-alpha.31

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 (223) hide show
  1. package/CHANGELOG.md +377 -0
  2. package/LICENSE.md +208 -131
  3. package/dist/eol.d.ts +31 -30
  4. package/dist/eol.js +3 -26
  5. package/dist/error.d.ts +273 -7
  6. package/dist/error.js +1 -7
  7. package/dist/glob-parent.d.ts +35 -0
  8. package/dist/glob-parent.js +1 -0
  9. package/dist/glob.d.ts +4 -0
  10. package/dist/glob.js +1 -0
  11. package/dist/index.d.ts +857 -36
  12. package/dist/index.js +1 -33
  13. package/dist/ini.d.ts +70 -0
  14. package/dist/ini.js +1 -0
  15. package/dist/is-glob.d.ts +34 -0
  16. package/dist/is-glob.js +1 -0
  17. package/dist/json5.d.ts +36 -0
  18. package/dist/json5.js +1 -0
  19. package/dist/jsonc.d.ts +65 -0
  20. package/dist/jsonc.js +1 -0
  21. package/dist/match.d.ts +80 -0
  22. package/dist/match.js +1 -0
  23. package/dist/packem_shared/AlreadyExistsError-DEb3UWja.js +1 -0
  24. package/dist/packem_shared/DirectoryError-BtwSTLmT.js +1 -0
  25. package/dist/packem_shared/F_OK-CAwY1qU7.js +1 -0
  26. package/dist/packem_shared/JSONError-Cvp9ycba.js +4 -0
  27. package/dist/packem_shared/NotEmptyError-DZ1Ix089.js +1 -0
  28. package/dist/packem_shared/NotFoundError-CnRY6lVp.js +1 -0
  29. package/dist/packem_shared/PermissionError-DJ_2VWEj.js +1 -0
  30. package/dist/packem_shared/WalkError-B8qTd-v-.js +1 -0
  31. package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +1 -0
  32. package/dist/packem_shared/assertValidFileContents-CbIN7sy7.js +1 -0
  33. package/dist/packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js +1 -0
  34. package/dist/packem_shared/build-rm-options-avnusYx-.js +1 -0
  35. package/dist/packem_shared/collect-VHN_VRLN.js +1 -0
  36. package/dist/packem_shared/collectSync-C28T6vrY.js +1 -0
  37. package/dist/packem_shared/emptyDir-C7lyd1lW.js +1 -0
  38. package/dist/packem_shared/emptyDirSync-B8EYpmO9.js +1 -0
  39. package/dist/packem_shared/ensureDir-DGarVZw8.js +1 -0
  40. package/dist/packem_shared/ensureDirSync-CsgPrsDH.js +1 -0
  41. package/dist/packem_shared/ensureFile-CMugWljp.js +1 -0
  42. package/dist/packem_shared/ensureFileSync-CJYTEx2r.js +1 -0
  43. package/dist/packem_shared/ensureLink-ChShf3lf.js +1 -0
  44. package/dist/packem_shared/ensureLinkSync-DPpq0I2Z.js +1 -0
  45. package/dist/packem_shared/ensureSymlink-y4FZjfxA.js +1 -0
  46. package/dist/packem_shared/ensureSymlinkSync-TcHssCH7.js +1 -0
  47. package/dist/packem_shared/findUp-D49u53m9.js +1 -0
  48. package/dist/packem_shared/findUpSync-C2oAKTw1.js +1 -0
  49. package/dist/packem_shared/get-file-info-type-DzWpohDB.js +1 -0
  50. package/dist/packem_shared/glob-D_7bct6p.js +1 -0
  51. package/dist/packem_shared/glob-sync.d-BgJM6l8W.d.ts +54 -0
  52. package/dist/packem_shared/globSync-f-4jVwn9.js +1 -0
  53. package/dist/packem_shared/index-B2MhYg3r.js +1 -0
  54. package/dist/packem_shared/index-BHy3Kcr7.js +11 -0
  55. package/dist/packem_shared/index-BspkXADC.js +1 -0
  56. package/dist/packem_shared/index-CChvzByK.js +1 -0
  57. package/dist/packem_shared/indexToLineColumn-BRSZFC6I-B2OZwR8G.js +6 -0
  58. package/dist/packem_shared/ini-preserve-D1DopDLd.js +4 -0
  59. package/dist/packem_shared/is-stats-identical-l1GRN4Qu.js +1 -0
  60. package/dist/packem_shared/isAccessible-DV2K-m2B.js +1 -0
  61. package/dist/packem_shared/isAccessibleSync-BCjiSxHj.js +1 -0
  62. package/dist/packem_shared/isFsCaseSensitive-j6UlSSM7.js +1 -0
  63. package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
  64. package/dist/packem_shared/jsonc-merge-Bkw73TLW.js +2 -0
  65. package/dist/packem_shared/move-CvE-ntXL.js +1 -0
  66. package/dist/packem_shared/parseJson-vUriP0eD.js +1 -0
  67. package/dist/packem_shared/readFile-ZXEXbVU5.js +1 -0
  68. package/dist/packem_shared/readFileSync-DseCu8sg.js +1 -0
  69. package/dist/packem_shared/readIni-CQK8HYxE.js +1 -0
  70. package/dist/packem_shared/readIniSync-l9LoYPoP.js +1 -0
  71. package/dist/packem_shared/readJson-T0hatQjC.js +1 -0
  72. package/dist/packem_shared/readJson5-CHbnB73J.js +1 -0
  73. package/dist/packem_shared/readJson5Sync-BsyhQYi8.js +1 -0
  74. package/dist/packem_shared/readJsonSync-Drti0sPY.js +1 -0
  75. package/dist/packem_shared/readJsonc-1woJjNLd.js +1 -0
  76. package/dist/packem_shared/readJsoncSync-TILCPRUQ.js +1 -0
  77. package/dist/packem_shared/readToml-Dawx4pqK.js +1 -0
  78. package/dist/packem_shared/readTomlSync-hnDlOU7g.js +1 -0
  79. package/dist/packem_shared/readYaml-DuXAtLKY.js +1 -0
  80. package/dist/packem_shared/readYamlSync-KlhBWm72.js +1 -0
  81. package/dist/packem_shared/remove-DmEfBrzp.js +1 -0
  82. package/dist/packem_shared/removeSync--c4qlu32.js +1 -0
  83. package/dist/packem_shared/resolve-symlink-target-CWrn0v4P.js +1 -0
  84. package/dist/packem_shared/sanitize-DGZ3w-_w.js +1 -0
  85. package/dist/packem_shared/stripJsonComments-gXl-1fAs.js +1 -0
  86. package/dist/packem_shared/to-uint-8-array-BBchIT6g.js +1 -0
  87. package/dist/packem_shared/types.d-C1ygRkw1.d.ts +1660 -0
  88. package/dist/packem_shared/walk-CxKfBzrV.js +1 -0
  89. package/dist/packem_shared/walk-include-BXhGSn6t.js +1 -0
  90. package/dist/packem_shared/walkSync-JkSkFL-F.js +1 -0
  91. package/dist/packem_shared/writeFile-CM-OVzxG.js +1 -0
  92. package/dist/packem_shared/writeFileSync-CNaAkXSP.js +1 -0
  93. package/dist/packem_shared/writeIni-B1NVnZkX.js +4 -0
  94. package/dist/packem_shared/writeIniSync-CwS1da1r.js +4 -0
  95. package/dist/packem_shared/writeJson-DC1V8Afe.js +4 -0
  96. package/dist/packem_shared/writeJson5--_qaVjxW.js +4 -0
  97. package/dist/packem_shared/writeJson5Sync-DPOk8wWz.js +4 -0
  98. package/dist/packem_shared/writeJsonSync-CUt49Wp1.js +4 -0
  99. package/dist/packem_shared/writeJsonc-DXuAO3_X.js +4 -0
  100. package/dist/packem_shared/writeJsoncSync-BEeqh1ry.js +4 -0
  101. package/dist/packem_shared/writeToml-BFD91-Sv.js +1 -0
  102. package/dist/packem_shared/writeTomlSync-D30hzuuu.js +1 -0
  103. package/dist/packem_shared/writeYaml-BD9JVGkk.js +1 -0
  104. package/dist/packem_shared/writeYamlSync-BobkRsmd.js +1 -0
  105. package/dist/size.d.ts +246 -246
  106. package/dist/size.js +1 -144
  107. package/dist/toml.d.ts +63 -0
  108. package/dist/toml.js +1 -0
  109. package/dist/utils.d.ts +103 -6
  110. package/dist/utils.js +1 -6
  111. package/dist/yaml.d.ts +13 -5
  112. package/dist/yaml.js +1 -4
  113. package/package.json +69 -18
  114. package/dist/constants.d.ts +0 -42
  115. package/dist/ensure/ensure-dir-sync.d.ts +0 -14
  116. package/dist/ensure/ensure-dir.d.ts +0 -14
  117. package/dist/ensure/ensure-file-sync.d.ts +0 -15
  118. package/dist/ensure/ensure-file.d.ts +0 -27
  119. package/dist/ensure/ensure-link-sync.d.ts +0 -16
  120. package/dist/ensure/ensure-link.d.ts +0 -16
  121. package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
  122. package/dist/ensure/ensure-symlink.d.ts +0 -23
  123. package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
  124. package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
  125. package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
  126. package/dist/error/already-exists-error.d.ts +0 -39
  127. package/dist/error/directory-error.d.ts +0 -47
  128. package/dist/error/json-error.d.ts +0 -52
  129. package/dist/error/not-empty-error.d.ts +0 -51
  130. package/dist/error/not-found-error.d.ts +0 -44
  131. package/dist/error/permission-error.d.ts +0 -45
  132. package/dist/error/walk-error.d.ts +0 -51
  133. package/dist/find/collect-sync.d.ts +0 -31
  134. package/dist/find/collect.d.ts +0 -35
  135. package/dist/find/find-up-sync.d.ts +0 -42
  136. package/dist/find/find-up.d.ts +0 -46
  137. package/dist/find/utils/glob-to-regexp.d.ts +0 -2
  138. package/dist/find/utils/walk-include.d.ts +0 -2
  139. package/dist/find/walk-sync.d.ts +0 -34
  140. package/dist/find/walk.d.ts +0 -37
  141. package/dist/is-accessible-sync.d.ts +0 -3
  142. package/dist/is-accessible.d.ts +0 -29
  143. package/dist/move/index.d.ts +0 -68
  144. package/dist/move/types.d.ts +0 -36
  145. package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
  146. package/dist/move/utils/internal-move-file.d.ts +0 -3
  147. package/dist/move/utils/validate-same-directory.d.ts +0 -2
  148. package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
  149. package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
  150. package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
  151. package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
  152. package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
  153. package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
  154. package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
  155. package/dist/packem_shared/WalkError-DUdQd6FT.js +0 -24
  156. package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
  157. package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
  158. package/dist/packem_shared/collect-DcBwsYYd.js +0 -14
  159. package/dist/packem_shared/collectSync-Bkjf9Dbm.js +0 -14
  160. package/dist/packem_shared/emptyDir-CYB5Tict.js +0 -43
  161. package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +0 -41
  162. package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +0 -53
  163. package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +0 -53
  164. package/dist/packem_shared/ensureFile-BUtXGlGT.js +0 -47
  165. package/dist/packem_shared/ensureFileSync-C8hASR-1.js +0 -47
  166. package/dist/packem_shared/ensureLink-BPnAG5-P.js +0 -54
  167. package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +0 -54
  168. package/dist/packem_shared/ensureSymlink-U5B6J0BN.js +0 -73
  169. package/dist/packem_shared/ensureSymlinkSync-DHnZj-9F.js +0 -74
  170. package/dist/packem_shared/findUp-BSnyGqer.js +0 -85
  171. package/dist/packem_shared/findUpSync-jRHbSCMV.js +0 -85
  172. package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
  173. package/dist/packem_shared/index-CHM-in-V.js +0 -100
  174. package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
  175. package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
  176. package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
  177. package/dist/packem_shared/isFsCaseSensitive-D-ayleCy.js +0 -62
  178. package/dist/packem_shared/move-DbpW5_vA.js +0 -134
  179. package/dist/packem_shared/parseJson-C8xb-3LR.js +0 -231
  180. package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
  181. package/dist/packem_shared/readFileSync-6GEIrOnl.js +0 -53
  182. package/dist/packem_shared/readJson-vddQ97Ll.js +0 -22
  183. package/dist/packem_shared/readJsonSync-DzeAdYZl.js +0 -22
  184. package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
  185. package/dist/packem_shared/readYamlSync-DMV4U-gi.js +0 -10
  186. package/dist/packem_shared/remove-_oDY3uKo.js +0 -38
  187. package/dist/packem_shared/removeSync-DETRj7Qn.js +0 -38
  188. package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
  189. package/dist/packem_shared/sanitize-lOzE6k2A.js +0 -205
  190. package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
  191. package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
  192. package/dist/packem_shared/walk-BhTbpr3y.js +0 -115
  193. package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
  194. package/dist/packem_shared/walkSync-DDBq95s8.js +0 -114
  195. package/dist/packem_shared/writeFile-DSHERs0Z.js +0 -83
  196. package/dist/packem_shared/writeFileSync-CJp1kXQR.js +0 -83
  197. package/dist/packem_shared/writeJson-C0OfLDbe.js +0 -50
  198. package/dist/packem_shared/writeJsonSync-Cs21FE7v.js +0 -50
  199. package/dist/packem_shared/writeYaml-n4xzYN9a.js +0 -24
  200. package/dist/packem_shared/writeYamlSync-DnOEnP10.js +0 -24
  201. package/dist/read/read-file-sync.d.ts +0 -37
  202. package/dist/read/read-file.d.ts +0 -41
  203. package/dist/read/read-json-sync.d.ts +0 -5
  204. package/dist/read/read-json.d.ts +0 -5
  205. package/dist/read/read-yaml-sync.d.ts +0 -4
  206. package/dist/read/read-yaml.d.ts +0 -4
  207. package/dist/remove/empty-dir-sync.d.ts +0 -23
  208. package/dist/remove/empty-dir.d.ts +0 -28
  209. package/dist/remove/remove-sync.d.ts +0 -27
  210. package/dist/remove/remove.d.ts +0 -32
  211. package/dist/sanitize.d.ts +0 -31
  212. package/dist/types.d.ts +0 -304
  213. package/dist/utils/assert-valid-file-contents.d.ts +0 -27
  214. package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
  215. package/dist/utils/parse-json.d.ts +0 -5
  216. package/dist/utils/strip-json-comments.d.ts +0 -44
  217. package/dist/write/utils/to-uint-8-array.d.ts +0 -2
  218. package/dist/write/write-file-sync.d.ts +0 -30
  219. package/dist/write/write-file.d.ts +0 -30
  220. package/dist/write/write-json-sync.d.ts +0 -29
  221. package/dist/write/write-json.d.ts +0 -30
  222. package/dist/write/write-yaml-sync.d.ts +0 -4
  223. package/dist/write/write-yaml.d.ts +0 -4
package/dist/index.d.ts CHANGED
@@ -1,36 +1,857 @@
1
- export { F_OK, FIND_UP_STOP, R_OK, W_OK, X_OK } from "./constants.d.ts";
2
- export { default as ensureDir } from "./ensure/ensure-dir.d.ts";
3
- export { default as ensureDirSync } from "./ensure/ensure-dir-sync.d.ts";
4
- export { default as ensureFile } from "./ensure/ensure-file.d.ts";
5
- export { default as ensureFileSync } from "./ensure/ensure-file-sync.d.ts";
6
- export { default as ensureLink } from "./ensure/ensure-link.d.ts";
7
- export { default as ensureLinkSync } from "./ensure/ensure-link-sync.d.ts";
8
- export { default as ensureSymlink } from "./ensure/ensure-symlink.d.ts";
9
- export { default as ensureSymlinkSync } from "./ensure/ensure-symlink-sync.d.ts";
10
- export { CRLF, detect, EOL, format, LF } from "./eol.d.ts";
11
- export { default as collect } from "./find/collect.d.ts";
12
- export { default as collectSync } from "./find/collect-sync.d.ts";
13
- export { default as findUp } from "./find/find-up.d.ts";
14
- export { default as findUpSync } from "./find/find-up-sync.d.ts";
15
- export { default as walk } from "./find/walk.d.ts";
16
- export { default as walkSync } from "./find/walk-sync.d.ts";
17
- export { default as isAccessible } from "./is-accessible.d.ts";
18
- export { default as isAccessibleSync } from "./is-accessible-sync.d.ts";
19
- export { move, moveSync, rename, renameSync } from "./move/index.d.ts";
20
- export type { Options as MoveOptions } from "./move/types.d.ts";
21
- export { default as readFile } from "./read/read-file.d.ts";
22
- export { default as readFileSync } from "./read/read-file-sync.d.ts";
23
- export { default as readJson } from "./read/read-json.d.ts";
24
- export { default as readJsonSync } from "./read/read-json-sync.d.ts";
25
- export { default as emptyDir } from "./remove/empty-dir.d.ts";
26
- export { default as emptyDirSync } from "./remove/empty-dir-sync.d.ts";
27
- export { default as remove } from "./remove/remove.d.ts";
28
- export { default as removeSync } from "./remove/remove-sync.d.ts";
29
- export type { SanitizeOptions } from "./sanitize.d.ts";
30
- export { sanitize } from "./sanitize.d.ts";
31
- export type { CodeFrameLocation, CodeFrameOptions, ContentType, FindUpName, FindUpNameFnResult, FindUpNameSync, FindUpNameSyncFnResult, FindUpOptions, JsonReplacer, JsonReviver, ReadFileEncoding, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, } from "./types.d.ts";
32
- export { default as writeFile } from "./write/write-file.d.ts";
33
- export { default as writeFileSync } from "./write/write-file-sync.d.ts";
34
- export { default as writeJson } from "./write/write-json.d.ts";
35
- export { default as writeJsonSync } from "./write/write-json-sync.d.ts";
36
- export { isFsCaseSensitive } from "is-fs-case-sensitive";
1
+ import { q as WalkOptions, F as FindUpName, r as FindUpOptions, s as FindUpNameSync, t as WalkEntry, u as ReadFileOptions, v as ContentType, w as ReadJsonOptions, J as JsonReviver, x as RetryOptions, y as WriteFileOptions, z as WriteJsonOptions } from "./packem_shared/types.d-C1ygRkw1.js";
2
+ export { type A as CodeFrameLocation, type C as CodeFrameOptions, B as FIND_UP_STOP, D as F_OK, type E as FindUpNameFnResult, type H as FindUpNameSyncFnResult, type G as GlobOptions, type b as JsonReplacer, K as R_OK, type L as ReadFileEncoding, M as W_OK, X as X_OK } from "./packem_shared/types.d-C1ygRkw1.js";
3
+ import { symlink } from 'node:fs';
4
+ export { CRLF, EOL, LF, detect, format } from "./eol.js";
5
+ export { g as glob, a as globSync } from "./packem_shared/glob-sync.d-BgJM6l8W.js";
6
+ export { type GlobParentOptions, default as globParent } from "./glob-parent.js";
7
+ export { type IsGlobOptions, default as isGlob } from "./is-glob.js";
8
+ export { type MatchOptions, match, matcher } from "./match.js";
9
+ import { JsonValue } from 'type-fest';
10
+ import fs from 'fs';
11
+ import 'tinyglobby';
12
+ /**
13
+ * Ensures that the directory exists.
14
+ * If the directory structure does not exist, it is created. Like mkdir -p.
15
+ * @param directory The path to the directory to ensure exists.
16
+ * @example
17
+ * ```javascript
18
+ * import ensureDir from "@visulima/fs/ensure/ensure-dir";
19
+ *
20
+ * await ensureDir("/tmp/foo/bar/baz");
21
+ * // Creates the directory structure /tmp/foo/bar/baz if it doesn't exist
22
+ * ```
23
+ */
24
+ declare const ensureDir: (directory: URL | string) => Promise<void>;
25
+ /**
26
+ * Ensures that the directory exists.
27
+ * If the directory structure does not exist, it is created. Like mkdir -p.
28
+ * @param directory The path to the directory to ensure exists.
29
+ * @example
30
+ * ```javascript
31
+ * import ensureDirSync from "@visulima/fs/ensure/ensure-dir-sync";
32
+ *
33
+ * ensureDirSync("/tmp/foo/bar/baz");
34
+ * // Creates the directory structure /tmp/foo/bar/baz if it doesn't exist
35
+ * ```
36
+ */
37
+ declare const ensureDirSync: (directory: URL | string) => void;
38
+ /**
39
+ * Asynchronously ensures that a file exists.
40
+ * If the directory structure for the file does not exist, it is created.
41
+ * If the file already exists, it is not modified.
42
+ * @param filePath The path to the file. Can be a string or a URL object.
43
+ * @returns A Promise that resolves when the file has been created or confirmed to exist.
44
+ * @throws Will throw an error if the path exists and is not a file.
45
+ * @throws Will throw an error if directory or file creation fails for reasons other than the path not existing initially.
46
+ * @example
47
+ * ```typescript
48
+ * import { ensureFile } from "@visulima/fs";
49
+ *
50
+ * (async () => {
51
+ * try {
52
+ * await ensureFile("path/to/my/file.txt");
53
+ * console.log("File ensured!");
54
+ *
55
+ * await ensureFile(new URL("file:///path/to/another/file.log"));
56
+ * console.log("Another file ensured!");
57
+ * } catch (error) {
58
+ * console.error("Failed to ensure file:", error);
59
+ * }
60
+ * })();
61
+ * ```
62
+ */
63
+ declare const ensureFile: (filePath: URL | string) => Promise<void>;
64
+ /**
65
+ * Ensures that the file exists.
66
+ * If the file that is requested to be created is in directories that do not exist,
67
+ * these directories are created. If the file already exists, it is NOT MODIFIED.
68
+ * @param filePath The path to the file to ensure exists.
69
+ * @example
70
+ * ```javascript
71
+ * import { ensureFileSync } from "@visulima/fs";
72
+ *
73
+ * ensureFileSync("/tmp/foo/bar/baz.txt");
74
+ * // Creates the file /tmp/foo/bar/baz.txt and any missing parent directories if they don't exist
75
+ * ```
76
+ */
77
+ declare const ensureFileSync: (filePath: URL | string) => void;
78
+ /**
79
+ * Ensures that the hard link exists.
80
+ * If the directory structure does not exist, it is created.
81
+ * @param source The path to the source file or directory.
82
+ * @param destination The path to the destination link.
83
+ * @example
84
+ * ```javascript
85
+ * import { ensureLink } from "@visulima/fs";
86
+ * import { join } from "node:path";
87
+ *
88
+ * // ensure the link /tmp/foo/bar-link.txt points to /tmp/foo/bar.txt
89
+ * await ensureLink(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "bar-link.txt"));
90
+ * ```
91
+ */
92
+ declare const ensureLink: (source: URL | string, destination: URL | string) => Promise<void>;
93
+ /**
94
+ * Ensures that the hard link exists.
95
+ * If the directory structure does not exist, it is created.
96
+ * @param source The path to the source file or directory.
97
+ * @param destination The path to the destination link.
98
+ * @example
99
+ * ```javascript
100
+ * import { ensureLinkSync } from "@visulima/fs";
101
+ * import { join } from "node:path";
102
+ *
103
+ * // ensure the link /tmp/foo/bar-link.txt points to /tmp/foo/bar.txt
104
+ * ensureLinkSync(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "bar-link.txt"));
105
+ * ```
106
+ */
107
+ declare const ensureLinkSync: (source: URL | string, destination: URL | string) => void;
108
+ /**
109
+ * Ensures that the link exists, and points to a valid file.
110
+ * If the directory structure does not exist, it is created.
111
+ * If the link already exists, it is not modified but error is thrown if it is not point to the given target.
112
+ * @param target the source file path
113
+ * @param linkName the destination link path
114
+ * @param type the type of the symlink, or null to use automatic detection
115
+ * @returns A void promise that resolves once the link exists.
116
+ * @example
117
+ * ```javascript
118
+ * import { ensureSymlink } from "@visulima/fs";
119
+ * import { join } from "node:path";
120
+ *
121
+ * // Ensure a symlink /tmp/foo/link-to-bar.txt points to /tmp/foo/bar.txt
122
+ * await ensureSymlink(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "link-to-bar.txt"));
123
+ *
124
+ * // Ensure a directory symlink /tmp/foo/link-to-baz-dir points to /tmp/foo/baz-dir
125
+ * await ensureSymlink(join("/tmp", "foo", "baz-dir"), join("/tmp", "foo", "link-to-baz-dir"), "dir");
126
+ * ```
127
+ */
128
+ declare const ensureSymlink: (target: URL | string, linkName: URL | string, type?: symlink.Type) => Promise<void>;
129
+ /**
130
+ * Ensures that the link exists, and points to a valid file.
131
+ * If the directory structure does not exist, it is created.
132
+ * If the link already exists, it is not modified but error is thrown if it is not point to the given target.
133
+ * @param target the source file path
134
+ * @param linkName the destination link path
135
+ * @param type the type of the symlink, or null to use automatic detection
136
+ * @returns A void.
137
+ * @example
138
+ * ```javascript
139
+ * import { ensureSymlinkSync } from "@visulima/fs";
140
+ * import { join } from "node:path";
141
+ *
142
+ * // Ensure a symlink /tmp/foo/link-to-bar.txt points to /tmp/foo/bar.txt
143
+ * ensureSymlinkSync(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "link-to-bar.txt"));
144
+ *
145
+ * // Ensure a directory symlink /tmp/foo/link-to-baz-dir points to /tmp/foo/baz-dir
146
+ * ensureSymlinkSync(join("/tmp", "foo", "baz-dir"), join("/tmp", "foo", "link-to-baz-dir"), "dir");
147
+ * ```
148
+ */
149
+ declare const ensureSymlinkSync: (target: URL | string, linkName: URL | string, type?: symlink.Type) => void;
150
+ /**
151
+ * Asynchronously collects all file paths within a directory that match the specified criteria.
152
+ * By default, it searches for JavaScript and TypeScript file extensions.
153
+ * @param directory The root directory to start collecting files from.
154
+ * @param options Optional configuration to control the collection process. See {@link WalkOptions}.
155
+ * @returns A promise that resolves to an array of absolute file paths.
156
+ * @example
157
+ * ```javascript
158
+ * import { collect } from "@visulima/fs";
159
+ * import { join } from "node:path";
160
+ *
161
+ * const collectFiles = async () => {
162
+ * // Collect all .txt and .md files in /tmp/docs, up to 2 levels deep
163
+ * const files = await collect(join("/tmp", "docs"), {
164
+ * extensions: ["txt", "md"],
165
+ * maxDepth: 2,
166
+ * includeDirs: false, // Only collect files
167
+ * });
168
+ * console.log(files);
169
+ * // Example output: ['/tmp/docs/file1.txt', '/tmp/docs/subdir/report.md']
170
+ *
171
+ * // Collect all .js files, excluding anything in node_modules
172
+ * const jsFiles = await collect(join("/tmp", "project"), {
173
+ * extensions: ["js"],
174
+ * skip: [/node_modules/],
175
+ * });
176
+ * console.log(jsFiles);
177
+ * };
178
+ *
179
+ * collectFiles();
180
+ * ```
181
+ */
182
+ declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
183
+ /**
184
+ * Synchronously collects all file paths within a directory that match the specified criteria.
185
+ * By default, it searches for JavaScript and TypeScript file extensions.
186
+ * @param directory The root directory to start collecting files from.
187
+ * @param options Optional configuration to control the collection process. See {@link WalkOptions}.
188
+ * @returns An array of absolute file paths.
189
+ * @example
190
+ * ```javascript
191
+ * import { collectSync } from "@visulima/fs";
192
+ * import { join } from "node:path";
193
+ *
194
+ * // Collect all .txt and .md files in /tmp/docs, up to 2 levels deep
195
+ * const files = collectSync(join("/tmp", "docs"), {
196
+ * extensions: ["txt", "md"],
197
+ * maxDepth: 2,
198
+ * includeDirs: false, // Only collect files
199
+ * });
200
+ * console.log(files);
201
+ * // Example output: ['/tmp/docs/file1.txt', '/tmp/docs/subdir/report.md']
202
+ *
203
+ * // Collect all .js files, excluding anything in node_modules
204
+ * const jsFiles = collectSync(join("/tmp", "project"), {
205
+ * extensions: ["js"],
206
+ * skip: [/node_modules/],
207
+ * });
208
+ * console.log(jsFiles);
209
+ * ```
210
+ */
211
+ declare const collectSync: (directory: string, options?: WalkOptions) => string[];
212
+ /**
213
+ * Asynchronously finds a file or directory by walking up parent directories.
214
+ * @param name The name(s) of the file or directory to find. Can be a string, an array of strings, or a function that returns a name or `FIND_UP_STOP`.
215
+ * @param options Optional configuration for the search. See {@link FindUpOptions}.
216
+ * @returns A promise that resolves to the absolute path of the first found file/directory, or `undefined` if not found.
217
+ * @example
218
+ * ```javascript
219
+ * import { findUp } from "@visulima/fs";
220
+ * import { join } from "node:path";
221
+ *
222
+ * const findProjectRoot = async () => {
223
+ * // Find the closest package.json, starting from /tmp/foo/bar/baz
224
+ * const projectRoot = await findUp("package.json", {
225
+ * cwd: join("/tmp", "foo", "bar", "baz"),
226
+ * type: "file",
227
+ * });
228
+ * console.log(projectRoot); // e.g., /tmp/foo/package.json or undefined
229
+ *
230
+ * // Find the closest .git directory or a README.md file
231
+ * const gitDirOrReadme = await findUp([".git", "README.md"], {
232
+ * cwd: join("/tmp", "foo", "bar"),
233
+ * });
234
+ * console.log(gitDirOrReadme);
235
+ *
236
+ * // Find using a custom function, stopping at /tmp
237
+ * const customFound = await findUp(
238
+ * (directory) => {
239
+ * if (directory === join("/tmp", "foo")) {
240
+ * return "found-it-here.txt"; // Pretend this file exists in /tmp/foo
241
+ * }
242
+ * return undefined;
243
+ * },
244
+ * {
245
+ * cwd: join("/tmp", "foo", "bar", "baz"),
246
+ * stopAt: join("/tmp"),
247
+ * }
248
+ * );
249
+ * console.log(customFound);
250
+ * };
251
+ *
252
+ * findProjectRoot();
253
+ * ```
254
+ */
255
+ declare const findUp: (name: FindUpName, options?: FindUpOptions) => Promise<string | undefined>;
256
+ /**
257
+ * Synchronously finds a file or directory by walking up parent directories.
258
+ * @param name The name(s) of the file or directory to find. Can be a string, an array of strings, or a function that returns a name or `FIND_UP_STOP`.
259
+ * @param options Optional configuration for the search. See {@link FindUpOptions}.
260
+ * @returns The absolute path of the first found file/directory, or `undefined` if not found.
261
+ * @example
262
+ * ```javascript
263
+ * import { findUpSync } from "@visulima/fs";
264
+ * import { join } from "node:path";
265
+ *
266
+ * // Find the closest package.json, starting from /tmp/foo/bar/baz
267
+ * const projectRoot = findUpSync("package.json", {
268
+ * cwd: join("/tmp", "foo", "bar", "baz"),
269
+ * type: "file",
270
+ * });
271
+ * console.log(projectRoot); // e.g., /tmp/foo/package.json or undefined
272
+ *
273
+ * // Find the closest .git directory or a README.md file
274
+ * const gitDirOrReadme = findUpSync([".git", "README.md"], {
275
+ * cwd: join("/tmp", "foo", "bar"),
276
+ * });
277
+ * console.log(gitDirOrReadme);
278
+ *
279
+ * // Find using a custom function, stopping at /tmp
280
+ * const customFound = findUpSync(
281
+ * (directory) => {
282
+ * if (directory === join("/tmp", "foo")) {
283
+ * return "found-it-here.txt"; // Pretend this file exists in /tmp/foo
284
+ * }
285
+ * return undefined;
286
+ * },
287
+ * {
288
+ * cwd: join("/tmp", "foo", "bar", "baz"),
289
+ * stopAt: join("/tmp"),
290
+ * }
291
+ * );
292
+ * console.log(customFound);
293
+ * ```
294
+ */
295
+ declare const findUpSync: (name: FindUpNameSync, options?: FindUpOptions) => string | undefined;
296
+ /**
297
+ * Asynchronously walks the file tree rooted at `directory`, yielding each file or directory that matches the criteria specified in `options`.
298
+ * @param directory The root directory to start walking from.
299
+ * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
300
+ * @param options.extensions List of file extensions used to filter entries.
301
+ * @param options.followSymlinks Indicates whether symlinks should be resolved or not.
302
+ * @param options.includeDirs Indicates whether directory entries should be included or not.
303
+ * @param options.includeFiles Indicates whether file entries should be included or not.
304
+ * @param options.includeSymlinks Indicates whether symlink entries should be included or not.
305
+ * @param options.match List of regular expression or glob patterns used to filter entries.
306
+ * @param options.maxDepth Maximum depth to walk. Defaults to infinity.
307
+ * @param options.skip List of regular expression or glob patterns used to skip entries.
308
+ * @returns An async iterable iterator yielding {@link WalkEntry} objects for each matching file or directory.
309
+ * @example
310
+ * ```javascript
311
+ * import { walk } from "@visulima/fs";
312
+ * import { join } from "node:path";
313
+ *
314
+ * const printEntries = async () => {
315
+ * // Walk through /tmp/my-project, looking for .ts files, max depth 2
316
+ * for await (const entry of walk(join("/tmp", "my-project"), { extensions: ["ts"], maxDepth: 2 })) {
317
+ * console.log(`Found: ${entry.path} (Type: ${entry.isFile() ? 'file' : 'directory'})`);
318
+ * }
319
+ *
320
+ * // Walk, including only directories, and skip any node_modules folders
321
+ * for await (const entry of walk(join("/tmp", "another-project"), { includeFiles: false, skip: [/node_modules/] })) {
322
+ * if (entry.isDirectory()) {
323
+ * console.log(`Directory: ${entry.path}`);
324
+ * }
325
+ * }
326
+ * };
327
+ *
328
+ * printEntries();
329
+ * ```
330
+ */
331
+ declare function walk(directory: URL | string, {
332
+ extensions,
333
+ followSymlinks,
334
+ includeDirs: includeDirectories,
335
+ includeFiles,
336
+ includeSymlinks,
337
+ match,
338
+ maxDepth,
339
+ skip
340
+ }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
341
+ /**
342
+ * Synchronously walks the file tree rooted at `directory`, yielding each file or directory that matches the criteria specified in `options`.
343
+ * This is the synchronous version of the async walk function.
344
+ * @param directory The root directory to start walking from.
345
+ * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
346
+ * @param options.extensions List of file extensions used to filter entries.
347
+ * @param options.followSymlinks Indicates whether symlinks should be resolved or not.
348
+ * @param options.includeDirs Indicates whether directory entries should be included or not.
349
+ * @param options.includeFiles Indicates whether file entries should be included or not.
350
+ * @param options.includeSymlinks Indicates whether symlink entries should be included or not.
351
+ * @param options.match List of regular expression or glob patterns used to filter entries.
352
+ * @param options.maxDepth Maximum depth to walk. Defaults to infinity.
353
+ * @param options.skip List of regular expression or glob patterns used to skip entries.
354
+ * @returns An iterable iterator yielding {@link WalkEntry} objects for each matching file or directory.
355
+ * @example
356
+ * ```javascript
357
+ * import { walkSync } from "@visulima/fs";
358
+ * import { join } from "node:path";
359
+ *
360
+ * // Walk through /tmp/my-project, looking for .ts files, max depth 2
361
+ * for (const entry of walkSync(join("/tmp", "my-project"), { extensions: ["ts"], maxDepth: 2 })) {
362
+ * console.log(`Found: ${entry.path} (Type: ${entry.isFile() ? 'file' : 'directory'})`);
363
+ * }
364
+ *
365
+ * // Walk, including only directories, and skip any node_modules folders
366
+ * for (const entry of walkSync(join("/tmp", "another-project"), { includeFiles: false, skip: [/node_modules/] })) {
367
+ * if (entry.isDirectory()) {
368
+ * console.log(`Directory: ${entry.path}`);
369
+ * }
370
+ * }
371
+ * ```
372
+ */
373
+ declare function walkSync(directory: URL | string, {
374
+ extensions,
375
+ followSymlinks,
376
+ includeDirs: includeDirectories,
377
+ includeFiles,
378
+ includeSymlinks,
379
+ match,
380
+ maxDepth,
381
+ skip
382
+ }?: WalkOptions): IterableIterator<WalkEntry>;
383
+ /**
384
+ * Asynchronously tests a user's permissions for the file or directory specified by path.
385
+ * Returns a Promise that resolves to `true` if the accessibility check is successful, `false` otherwise.
386
+ * @param path The path to the file or directory. Can be a string or a URL object.
387
+ * @param mode The accessibility checks to perform. Defaults to `F_OK` (check for existence).
388
+ * Other possible values include `R_OK` (check for read access), `W_OK` (check for write access),
389
+ * and `X_OK` (check for execute/search access). Multiple modes can be combined using bitwise OR.
390
+ * @returns A Promise that resolves to a boolean indicating if the path is accessible with the specified mode.
391
+ * @example
392
+ * ```typescript
393
+ * import { isAccessible, F_OK, R_OK } from "@visulima/fs";
394
+ *
395
+ * (async () => {
396
+ * if (await isAccessible("myFile.txt")) {
397
+ * console.log("myFile.txt exists");
398
+ * }
399
+ *
400
+ * if (await isAccessible("myFile.txt", R_OK)) {
401
+ * console.log("myFile.txt is readable");
402
+ * }
403
+ *
404
+ * if (await isAccessible("myDirectory", F_OK | R_OK | W_OK)) {
405
+ * console.log("myDirectory exists, is readable and writable");
406
+ * }
407
+ * })();
408
+ * ```
409
+ */
410
+ declare function isAccessible(path: URL | string, mode?: number): Promise<boolean>;
411
+ /** Returns a boolean indicating if the path is accessible or not. */
412
+ declare function isAccessibleSync(path: URL | string, mode?: number): boolean;
413
+ type Options = {
414
+ /**
415
+ * The working directory to find source files.
416
+ * The source and destination path are relative to this.
417
+ * @default process.cwd()
418
+ */
419
+ cwd?: URL | string;
420
+ /**
421
+ * [Permissions](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) for created directories.
422
+ *
423
+ * It has no effect on Windows.
424
+ * @default 0o777
425
+ */
426
+ readonly directoryMode?: number;
427
+ /**
428
+ * Overwrite existing destination file.
429
+ * @default true
430
+ */
431
+ readonly overwrite?: boolean;
432
+ };
433
+ /**
434
+ * Move a file asynchronously.
435
+ * @param sourcePath The file you want to move.
436
+ * @param destinationPath Where you want the file moved.
437
+ * @param options Configuration options.
438
+ * @returns A `Promise` that resolves when the file has been moved.
439
+ * @example
440
+ * ```
441
+ * import { move } from '@visulima/fs';
442
+ *
443
+ * await move('source/test.png', 'destination/test.png');
444
+ * console.log('The file has been moved');
445
+ * ```
446
+ */
447
+ declare const move: (sourcePath: string, destinationPath: string, options?: Options) => Promise<void>;
448
+ /**
449
+ * Move a file synchronously.
450
+ * @param sourcePath The file you want to move.
451
+ * @param destinationPath Where you want the file moved.
452
+ * @param options Configuration options.
453
+ * @example
454
+ * ```
455
+ * import { moveSync } from '@visulima/fs';
456
+ *
457
+ * moveSync('source/test.png', 'destination/test.png');
458
+ * console.log('The file has been moved');
459
+ * ```
460
+ */
461
+ declare const moveSync: (sourcePath: string, destinationPath: string, options?: Options) => void;
462
+ /**
463
+ * Rename a file asynchronously.
464
+ * @param source The file you want to rename.
465
+ * @param destination The name of the renamed file.
466
+ * @param options Configuration options.
467
+ * @returns A `Promise` that resolves when the file has been renamed.
468
+ * @example
469
+ * ```
470
+ * import { rename } from '@visulima/fs';
471
+ *
472
+ * await rename('test.png', 'tests.png', {cwd: 'source'});
473
+ * console.log('The file has been renamed');
474
+ * ```
475
+ */
476
+ declare const rename: (source: string, destination: string, options?: Options) => Promise<void>;
477
+ /**
478
+ * Rename a file synchronously.
479
+ * @param source The file you want to rename.
480
+ * @param destination The name of the renamed file.
481
+ * @param options Configuration options.
482
+ * @example
483
+ * ```
484
+ * import { renameSync } from '@visulima/fs';
485
+ *
486
+ * renameSync('test.png', 'tests.png', {cwd: 'source'});
487
+ * console.log('The file has been renamed');
488
+ * ```
489
+ */
490
+ declare const renameSync: (source: string, destination: string, options?: Options) => void;
491
+ type DecompressionMethod$1 = (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => void;
492
+ declare const decompressionMethods$1: Record<string, DecompressionMethod$1>;
493
+ /**
494
+ * Asynchronously reads the entire contents of a file.
495
+ * It can also decompress the file content if a `compression` option is provided.
496
+ * @template O - The type of the options object, extending {@link ReadFileOptions}.
497
+ * @param path The path to the file to read. Can be a file URL or a string path.
498
+ * @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
499
+ * Available `compression` methods: "brotli", "gzip", "none" (default).
500
+ * @returns A promise that resolves with the file content. The type of the content (string or Buffer)
501
+ * depends on the `buffer` option (defaults to string if `buffer` is false or not set).
502
+ * @example
503
+ * ```javascript
504
+ * import { readFile } from "@visulima/fs";
505
+ * import { join } from "node:path";
506
+ *
507
+ * const readMyFile = async () => {
508
+ * try {
509
+ * // Read a regular text file
510
+ * const content = await readFile(join("path", "to", "my-file.txt"));
511
+ * console.log("File content:", content);
512
+ *
513
+ * // Read a file as a Buffer
514
+ * const bufferContent = await readFile(join("path", "to", "another-file.bin"), { buffer: true });
515
+ * console.log("Buffer length:", bufferContent.length);
516
+ *
517
+ * // Read and decompress a gzipped file
518
+ * // Assume my-archive.txt.gz exists
519
+ * // const decompressedContent = await readFile(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
520
+ * // console.log("Decompressed content:", decompressedContent);
521
+ * } catch (error) {
522
+ * console.error("Failed to read file:", error);
523
+ * }
524
+ * };
525
+ *
526
+ * readMyFile();
527
+ * ```
528
+ */
529
+ declare const readFile: <O extends ReadFileOptions<keyof typeof decompressionMethods$1> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O>>;
530
+ type DecompressionMethod = (buffer: Buffer) => Buffer;
531
+ declare const decompressionMethods: Record<string, DecompressionMethod>;
532
+ /**
533
+ * Synchronously reads the entire contents of a file.
534
+ * It can also decompress the file content if a `compression` option is provided.
535
+ * @template O - The type of the options object, extending {@link ReadFileOptions}.
536
+ * @param path The path to the file to read. Can be a file URL or a string path.
537
+ * @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
538
+ * Available `compression` methods: "brotli", "gzip", "none" (default).
539
+ * @returns The file content. The type of the content (string or Buffer)
540
+ * depends on the `buffer` option (defaults to string if `buffer` is false or not set).
541
+ * @example
542
+ * ```javascript
543
+ * import { readFileSync } from "@visulima/fs";
544
+ * import { join } from "node:path";
545
+ *
546
+ * try {
547
+ * // Read a regular text file
548
+ * const content = readFileSync(join("path", "to", "my-file.txt"));
549
+ * console.log("File content:", content);
550
+ *
551
+ * // Read a file as a Buffer
552
+ * const bufferContent = readFileSync(join("path", "to", "another-file.bin"), { buffer: true });
553
+ * console.log("Buffer length:", bufferContent.length);
554
+ *
555
+ * // Read and decompress a gzipped file
556
+ * // Assume my-archive.txt.gz exists
557
+ * // const decompressedContent = readFileSync(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
558
+ * // console.log("Decompressed content:", decompressedContent);
559
+ * } catch (error) {
560
+ * console.error("Failed to read file:", error);
561
+ * }
562
+ * ```
563
+ */
564
+ declare const readFileSync: <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O>;
565
+ declare function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;
566
+ declare function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;
567
+ declare function readJsonSync(path: URL | string, options?: ReadJsonOptions): JsonValue;
568
+ declare function readJsonSync(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): JsonValue;
569
+ /**
570
+ * Ensures that a directory is empty.
571
+ * Deletes directory contents if the directory is not empty.
572
+ * If the directory does not exist, it is created.
573
+ * The directory itself is not deleted.
574
+ * @param dir The path to the directory to empty.
575
+ * @param options Optional configuration for the operation. See {@link RetryOptions}.
576
+ * @returns A promise that resolves when the directory is empty.
577
+ * @example
578
+ * ```javascript
579
+ * import { emptyDir } from "@visulima/fs";
580
+ * import { join } from "node:path";
581
+ *
582
+ * const clearTempDir = async () => {
583
+ * try {
584
+ * await emptyDir(join("/tmp", "my-app-temp"));
585
+ * console.log("Temporary directory emptied or created.");
586
+ * } catch (error) {
587
+ * console.error("Failed to empty directory:", error);
588
+ * }
589
+ * };
590
+ *
591
+ * clearTempDir();
592
+ * ```
593
+ */
594
+ declare const emptyDir: (dir: URL | string, options?: RetryOptions) => Promise<void>;
595
+ /**
596
+ * Ensures that a directory is empty.
597
+ * Deletes directory contents if the directory is not empty.
598
+ * If the directory does not exist, it is created.
599
+ * The directory itself is not deleted.
600
+ * @param dir The path to the directory to empty.
601
+ * @param options Optional configuration for the operation. See {@link RetryOptions}.
602
+ * @example
603
+ * ```javascript
604
+ * import { emptyDirSync } from "@visulima/fs";
605
+ * import { join } from "node:path";
606
+ *
607
+ * try {
608
+ * emptyDirSync(join("/tmp", "my-app-temp"));
609
+ * console.log("Temporary directory emptied or created.");
610
+ * } catch (error) {
611
+ * console.error("Failed to empty directory:", error);
612
+ * }
613
+ * ```
614
+ */
615
+ declare const emptyDirSync: (dir: URL | string, options?: RetryOptions) => void;
616
+ /**
617
+ * Asynchronously removes a file or directory (recursively).
618
+ * If the path does not exist, it does nothing.
619
+ * @param path The path to the file or directory to remove.
620
+ * @param options Optional configuration for the operation. See {@link RetryOptions}.
621
+ * @returns A promise that resolves when the path has been removed.
622
+ * @example
623
+ * ```javascript
624
+ * import { remove } from "@visulima/fs";
625
+ * import { join } from "node:path";
626
+ *
627
+ * const deleteFileOrDir = async () => {
628
+ * try {
629
+ * await remove(join("/tmp", "my-file.txt"));
630
+ * console.log("File /tmp/my-file.txt removed.");
631
+ *
632
+ * await remove(join("/tmp", "my-empty-dir"));
633
+ * console.log("Directory /tmp/my-empty-dir removed.");
634
+ *
635
+ * await remove(join("/tmp", "my-dir-with-contents"));
636
+ * console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
637
+ * } catch (error) {
638
+ * console.error("Failed to remove path:", error);
639
+ * }
640
+ * };
641
+ *
642
+ * deleteFileOrDir();
643
+ * ```
644
+ */
645
+ declare const remove: (path: URL | string, options?: RetryOptions) => Promise<void>;
646
+ /**
647
+ * Synchronously removes a file or directory (recursively).
648
+ * If the path does not exist, it does nothing.
649
+ * @param path The path to the file or directory to remove.
650
+ * @param options Optional configuration for the operation. See {@link RetryOptions}.
651
+ * @example
652
+ * ```javascript
653
+ * import { removeSync } from "@visulima/fs";
654
+ * import { join } from "node:path";
655
+ *
656
+ * try {
657
+ * removeSync(join("/tmp", "my-file.txt"));
658
+ * console.log("File /tmp/my-file.txt removed.");
659
+ *
660
+ * removeSync(join("/tmp", "my-empty-dir"));
661
+ * console.log("Directory /tmp/my-empty-dir removed.");
662
+ *
663
+ * removeSync(join("/tmp", "my-dir-with-contents"));
664
+ * console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
665
+ * } catch (error) {
666
+ * console.error("Failed to remove path:", error);
667
+ * }
668
+ * ```
669
+ */
670
+ declare const removeSync: (path: URL | string, options?: RetryOptions) => void;
671
+ /**
672
+ * Supported filesystem types
673
+ */
674
+ type FileSystemType = "win32" | "unix" | "darwin" | "fat32" | "auto";
675
+ /**
676
+ * Options for the sanitize function
677
+ */
678
+ interface SanitizeOptions {
679
+ /**
680
+ * Target filesystem type for sanitization rules
681
+ * - "win32": Windows filesystem rules (reserved names, Windows forbidden chars, no trailing periods/spaces)
682
+ * - "unix": Unix/Linux filesystem rules (only / and null forbidden)
683
+ * - "darwin": macOS filesystem rules (same as unix)
684
+ * - "fat32": FAT32 filesystem rules (Windows rules + no leading/trailing spaces/periods in name part)
685
+ * - "auto": Automatically detect from process.platform
686
+ * @default "auto"
687
+ */
688
+ filesystem?: FileSystemType;
689
+ /**
690
+ * Maximum length of the sanitized name
691
+ * @default 128
692
+ */
693
+ maxLength?: number;
694
+ }
695
+ /**
696
+ * Sanitizes a filename by removing or replacing forbidden characters.
697
+ * @param name The filename to sanitize.
698
+ * @param options Optional configuration.
699
+ * @returns The sanitized filename, or "unnamed" if the result would be empty.
700
+ */
701
+ declare const sanitize: (name: string, options?: Partial<SanitizeOptions>) => string;
702
+ /**
703
+ * Asynchronously writes data to a file, replacing the file if it already exists.
704
+ * This function includes safeguards like writing to a temporary file first and then renaming, and handling permissions.
705
+ * @param path The path to the file to write. Can be a file URL or a string path.
706
+ * @param content The data to write. Can be a string, Buffer, ArrayBuffer, or ArrayBufferView.
707
+ * @param options Optional configuration for writing the file. See {@link WriteFileOptions}.
708
+ * @returns A promise that resolves when the file has been written.
709
+ * @example
710
+ * ```javascript
711
+ * import { writeFile } from "@visulima/fs";
712
+ * import { join } from "node:path";
713
+ *
714
+ * const writeMyFile = async () => {
715
+ * try {
716
+ * await writeFile(join("/tmp", "my-new-file.txt"), "Hello World!");
717
+ * console.log("File written successfully.");
718
+ *
719
+ * await writeFile(join("/tmp", "another-file.txt"), "Some other content", { encoding: 'utf16le', mode: 0o600 });
720
+ * console.log("Another file written with specific options.");
721
+ * } catch (error) {
722
+ * console.error("Failed to write file:", error);
723
+ * }
724
+ * };
725
+ *
726
+ * writeMyFile();
727
+ * ```
728
+ */
729
+ declare const writeFile: (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions) => Promise<void>;
730
+ /**
731
+ * Synchronously writes data to a file, replacing the file if it already exists.
732
+ * This function includes safeguards like writing to a temporary file first and then renaming, and handling permissions.
733
+ * @param path The path to the file to write. Can be a file URL or a string path.
734
+ * @param content The data to write. Can be a string, Buffer, ArrayBuffer, or ArrayBufferView.
735
+ * @param options Optional configuration for writing the file. See {@link WriteFileOptions}.
736
+ * @returns void
737
+ * @example
738
+ * ```javascript
739
+ * import { writeFileSync } from "@visulima/fs";
740
+ * import { join } from "node:path";
741
+ *
742
+ * const writeMyFileSync = () => {
743
+ * try {
744
+ * writeFileSync(join("/tmp", "my-new-file-sync.txt"), "Hello World Synchronously!");
745
+ * console.log("File written successfully (sync).");
746
+ *
747
+ * writeFileSync(join("/tmp", "another-file-sync.txt"), "Some other sync content", { encoding: 'utf16le', mode: 0o600 });
748
+ * console.log("Another file written with specific options (sync).");
749
+ * } catch (error) {
750
+ * console.error("Failed to write file (sync):", error);
751
+ * }
752
+ * };
753
+ *
754
+ * writeMyFileSync();
755
+ * ```
756
+ */
757
+ declare const writeFileSync: (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions) => void;
758
+ /**
759
+ * Asynchronously writes an object to a JSON file.
760
+ * Handles indentation detection, custom stringifiers, and gracefully manages existing files.
761
+ * @param path The path to the JSON file to write. Can be a file URL or a string path.
762
+ * @param data The data to serialize and write. Can be any JavaScript value that can be stringified by `JSON.stringify` or a custom stringifier.
763
+ * @param options Optional configuration for writing the JSON file. See {@link WriteJsonOptions}.
764
+ * @returns A promise that resolves when the JSON file has been written.
765
+ * @example
766
+ * ```javascript
767
+ * import { writeJson } from "@visulima/fs";
768
+ * import { join } from "node:path";
769
+ *
770
+ * const writeMyJson = async () => {
771
+ * try {
772
+ * await writeJson(join("/tmp", "my-config.json"), { setting: "enabled", value: 123 });
773
+ * console.log("JSON file written successfully.");
774
+ *
775
+ * await writeJson(join("/tmp", "another-config.json"), { user: "test", id: "abc" }, { indent: 2, replacer: ["user"] });
776
+ * console.log("Another JSON file written with specific options (indent 2, only 'user' key).");
777
+ * } catch (error) {
778
+ * console.error("Failed to write JSON file:", error);
779
+ * }
780
+ * };
781
+ *
782
+ * writeMyJson();
783
+ * ```
784
+ */
785
+ declare const writeJson: (path: URL | string, data: unknown, options?: WriteJsonOptions) => Promise<void>;
786
+ /**
787
+ * Synchronously writes an object to a JSON file.
788
+ * Handles indentation detection, custom stringifiers, and gracefully manages existing files.
789
+ * @param path The path to the JSON file to write. Can be a file URL or a string path.
790
+ * @param data The data to serialize and write. Can be any JavaScript value that can be stringified by `JSON.stringify` or a custom stringifier.
791
+ * @param options Optional configuration for writing the JSON file. See {@link WriteJsonOptions}.
792
+ * @example
793
+ * ```javascript
794
+ * import { writeJsonSync } from "@visulima/fs";
795
+ * import { join } from "node:path";
796
+ *
797
+ * const writeMyJsonSync = () => {
798
+ * try {
799
+ * writeJsonSync(join("/tmp", "my-config-sync.json"), { setting: "enabled", value: 456 });
800
+ * console.log("JSON file written successfully (sync).");
801
+ *
802
+ * writeJsonSync(join("/tmp", "another-config-sync.json"), { user: "testSync", id: "def" }, { indent: 4, replacer: ["id"] });
803
+ * console.log("Another JSON file written with specific options (sync, indent 4, only 'id' key).");
804
+ * } catch (error) {
805
+ * console.error("Failed to write JSON file (sync):", error);
806
+ * }
807
+ * };
808
+ *
809
+ * writeMyJsonSync();
810
+ * ```
811
+ */
812
+ declare const writeJsonSync: (path: URL | string, data: unknown, options?: WriteJsonOptions) => void;
813
+ /**
814
+ * Subset of Node.js fs module methods required for case-sensitivity detection.
815
+ * This allows custom fs implementations to be passed for testing purposes.
816
+ */
817
+ type FsSubset = {
818
+ existsSync: typeof fs.existsSync;
819
+ writeFileSync: typeof fs.writeFileSync;
820
+ unlinkSync: typeof fs.unlinkSync;
821
+ };
822
+ /**
823
+ * Detects whether the filesystem is case-sensitive.
824
+ *
825
+ * Uses a fast, I/O-free primary method that checks if the specified directory
826
+ * path can be accessed with inverted case. Falls back to writing a temporary
827
+ * file if the primary method is inconclusive.
828
+ *
829
+ * Different mount points can have different case-sensitivity settings, so this
830
+ * function checks the filesystem where the specified directory resides.
831
+ *
832
+ * @param directoryPath - The directory path to check. Defaults to
833
+ * `process.cwd()`. Different mount points can have different case-sensitivity.
834
+ * @param fsInstance - Custom filesystem implementation (primarily for
835
+ * testing). Defaults to Node.js `fs` module.
836
+ * @param useCache - Whether to cache the result per directory. Defaults to
837
+ * `true`. When enabled, subsequent calls for the same directory return
838
+ * instantly without re-checking.
839
+ * @returns `true` if the filesystem is case-sensitive, `false` otherwise
840
+ *
841
+ * @example
842
+ * ```ts
843
+ * import { isFsCaseSensitive } from 'is-fs-case-sensitive'
844
+ *
845
+ * // Check current working directory's filesystem
846
+ * if (isFsCaseSensitive()) {
847
+ * console.log('Case-sensitive filesystem (likely Linux)')
848
+ * } else {
849
+ * console.log('Case-insensitive filesystem (likely macOS/Windows)')
850
+ * }
851
+ *
852
+ * // Check specific directory
853
+ * const isHomeCaseSensitive = isFsCaseSensitive('/home/user')
854
+ * ```
855
+ */
856
+ declare const isFsCaseSensitive: (directoryPath?: string, fsInstance?: FsSubset, useCache?: boolean) => boolean;
857
+ export { type ContentType, type FindUpName, type FindUpNameSync, type FindUpOptions, type JsonReviver, type Options as MoveOptions, type ReadFileOptions, type ReadJsonOptions, type SanitizeOptions, type WalkEntry, type WalkOptions, type WriteFileOptions, type WriteJsonOptions, collect, collectSync, emptyDir, emptyDirSync, ensureDir, ensureDirSync, ensureFile, ensureFileSync, ensureLink, ensureLinkSync, ensureSymlink, ensureSymlinkSync, findUp, findUpSync, isAccessible, isAccessibleSync, isFsCaseSensitive, move, moveSync, readFile, readFileSync, readJson, readJsonSync, remove, removeSync, rename, renameSync, sanitize, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync };