@visulima/fs 5.0.9 → 5.0.11

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 (132) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/eol.d.ts +25 -25
  3. package/dist/eol.js +2 -2
  4. package/dist/error.d.ts +218 -218
  5. package/dist/glob-parent.d.ts +27 -27
  6. package/dist/glob-parent.js +1 -1
  7. package/dist/glob.d.ts +2 -2
  8. package/dist/glob.js +1 -1
  9. package/dist/index.d.ts +765 -765
  10. package/dist/index.js +1 -1
  11. package/dist/ini.d.ts +59 -59
  12. package/dist/ini.js +1 -1
  13. package/dist/is-glob.d.ts +26 -26
  14. package/dist/json5.d.ts +25 -25
  15. package/dist/json5.js +1 -1
  16. package/dist/jsonc.d.ts +54 -54
  17. package/dist/jsonc.js +1 -1
  18. package/dist/match.d.ts +40 -40
  19. package/dist/packem_shared/{collect-CIKDOMiD.js → collect-B0S0bJoE.js} +1 -1
  20. package/dist/packem_shared/{collectSync-D0FRLLqg.js → collectSync-0M1eoilI.js} +1 -1
  21. package/dist/packem_shared/copy-DiR5_5iA.js +1 -0
  22. package/dist/packem_shared/copySync-DffsYlhb.js +1 -0
  23. package/dist/packem_shared/emptyDir-BlBeczk0.js +1 -0
  24. package/dist/packem_shared/emptyDirSync-DfUZ9Ejz.js +1 -0
  25. package/dist/packem_shared/ensureDir-BEiomfxz.js +1 -0
  26. package/dist/packem_shared/ensureDirSync-B0w9WMwE.js +1 -0
  27. package/dist/packem_shared/ensureFile-waD4hDO8.js +1 -0
  28. package/dist/packem_shared/ensureFileSync-CG07zjV7.js +1 -0
  29. package/dist/packem_shared/ensureLink-Dz-PDWa5.js +1 -0
  30. package/dist/packem_shared/ensureLinkSync-BZH7TaSQ.js +1 -0
  31. package/dist/packem_shared/ensureSymlink-Byi6ajoE.js +1 -0
  32. package/dist/packem_shared/ensureSymlinkSync-D7OCsAd8.js +1 -0
  33. package/dist/packem_shared/findUp-Ylerv_a2.js +1 -0
  34. package/dist/packem_shared/findUpSync-BWBPRzEq.js +1 -0
  35. package/dist/packem_shared/glob-BUjyjdE8.js +1 -0
  36. package/dist/packem_shared/glob-sync.d-DaAZHTsv.d.ts +54 -0
  37. package/dist/packem_shared/globSync-Bk9TUV7x.js +1 -0
  38. package/dist/packem_shared/index-CPZbuHkp.js +1 -0
  39. package/dist/packem_shared/isAccessible-B7guOm3k.js +1 -0
  40. package/dist/packem_shared/isAccessibleSync-XH4YleJW.js +1 -0
  41. package/dist/packem_shared/json-error.d-COL8oxF_.d.ts +52 -0
  42. package/dist/packem_shared/move-KhPRvsRd.js +1 -0
  43. package/dist/packem_shared/{parseJson-EASgP4J9.js → parseJson-_OfIPruP.js} +1 -1
  44. package/dist/packem_shared/readFile-VgxUDrNH.js +1 -0
  45. package/dist/packem_shared/readFileSync-CloFeQw8.js +1 -0
  46. package/dist/packem_shared/{readIni-BsXudu2r.js → readIni-CEXHWn92.js} +1 -1
  47. package/dist/packem_shared/readIniSync-DsxVHypc.js +1 -0
  48. package/dist/packem_shared/{readJson-CcAsHxE5.js → readJson-Q3T3RlSy.js} +1 -1
  49. package/dist/packem_shared/{readJson5-CM1TIiHd.js → readJson5-S68aVros.js} +1 -1
  50. package/dist/packem_shared/{readJson5Sync-Bc26c3Fy.js → readJson5Sync-Bi9Rv46R.js} +1 -1
  51. package/dist/packem_shared/{readJsonSync-DuMMeB3s.js → readJsonSync-BnWiH5-R.js} +1 -1
  52. package/dist/packem_shared/{readJsonc-BZjMw_0f.js → readJsonc-DSoFyuDk.js} +1 -1
  53. package/dist/packem_shared/{readJsoncSync-C-xzeZz4.js → readJsoncSync-CLtlvFKV.js} +1 -1
  54. package/dist/packem_shared/readToml-CN_xnICv.js +1 -0
  55. package/dist/packem_shared/readTomlSync-B9TVGzen.js +1 -0
  56. package/dist/packem_shared/{readYaml-DvPxndW_.js → readYaml-DcpUq11D.js} +1 -1
  57. package/dist/packem_shared/{readYamlSync-DZ-0hSbZ.js → readYamlSync-D5RVZwco.js} +1 -1
  58. package/dist/packem_shared/remove-D_CUIlBL.js +1 -0
  59. package/dist/packem_shared/removeSync-F4nKiwrU.js +1 -0
  60. package/dist/packem_shared/renderError-DjesnVYT-pWsLqw-_.js +6 -0
  61. package/dist/packem_shared/sanitize-aEqeyx4d.js +1 -0
  62. package/dist/packem_shared/to-uint-8-array-7sXMoZwU.js +1 -0
  63. package/dist/packem_shared/{types.d-BMdL_ygj.d.ts → types.d-D3Jo_iA-.d.ts} +361 -383
  64. package/dist/packem_shared/walk-BReeHTKb.js +1 -0
  65. package/dist/packem_shared/walkSync-yHJUIJb9.js +1 -0
  66. package/dist/packem_shared/writeFile-srDcYaRC.js +1 -0
  67. package/dist/packem_shared/writeFileSync-Ddl_u4my.js +1 -0
  68. package/dist/packem_shared/writeIni-CKinbquM.js +4 -0
  69. package/dist/packem_shared/writeIniSync-BISRFyg0.js +4 -0
  70. package/dist/packem_shared/writeJson-DlCrFMXb.js +4 -0
  71. package/dist/packem_shared/writeJson5-rSp3QAKP.js +4 -0
  72. package/dist/packem_shared/writeJson5Sync-tSBBKnaP.js +4 -0
  73. package/dist/packem_shared/writeJsonSync-CKqVRz_9.js +4 -0
  74. package/dist/packem_shared/writeJsonc-bxz1jdeU.js +4 -0
  75. package/dist/packem_shared/writeJsoncSync-C-W0H9qP.js +4 -0
  76. package/dist/packem_shared/{writeToml-IuMO-yDu.js → writeToml-CrpfWNyK.js} +1 -1
  77. package/dist/packem_shared/{writeTomlSync-DhL7hHzB.js → writeTomlSync-DveRchLG.js} +1 -1
  78. package/dist/packem_shared/{writeYaml-ClQgvQID.js → writeYaml-DvSQ_Jbn.js} +1 -1
  79. package/dist/packem_shared/{writeYamlSync-DrXtHQQq.js → writeYamlSync-CEf0PUGQ.js} +1 -1
  80. package/dist/size.d.ts +236 -236
  81. package/dist/size.js +1 -1
  82. package/dist/toml.d.ts +52 -52
  83. package/dist/toml.js +1 -1
  84. package/dist/utils.d.ts +88 -88
  85. package/dist/utils.js +1 -1
  86. package/dist/yaml.d.ts +2 -2
  87. package/dist/yaml.js +1 -1
  88. package/package.json +1 -1
  89. package/dist/packem_shared/copy-Beb64BYG.js +0 -1
  90. package/dist/packem_shared/copySync-CagcIEBi.js +0 -1
  91. package/dist/packem_shared/emptyDir-C7lyd1lW.js +0 -1
  92. package/dist/packem_shared/emptyDirSync-B8EYpmO9.js +0 -1
  93. package/dist/packem_shared/ensureDir-DGarVZw8.js +0 -1
  94. package/dist/packem_shared/ensureDirSync-CsgPrsDH.js +0 -1
  95. package/dist/packem_shared/ensureFile-CMugWljp.js +0 -1
  96. package/dist/packem_shared/ensureFileSync-CJYTEx2r.js +0 -1
  97. package/dist/packem_shared/ensureLink-ChShf3lf.js +0 -1
  98. package/dist/packem_shared/ensureLinkSync-DPpq0I2Z.js +0 -1
  99. package/dist/packem_shared/ensureSymlink-y4FZjfxA.js +0 -1
  100. package/dist/packem_shared/ensureSymlinkSync-TcHssCH7.js +0 -1
  101. package/dist/packem_shared/findUp-Cii5ATt5.js +0 -1
  102. package/dist/packem_shared/findUpSync-C9Lkh7-v.js +0 -1
  103. package/dist/packem_shared/glob-DMbPwGSj.js +0 -1
  104. package/dist/packem_shared/glob-sync.d-hXe38TnZ.d.ts +0 -54
  105. package/dist/packem_shared/globSync-DiP2rtGn.js +0 -1
  106. package/dist/packem_shared/index-Ct4GqZSP.js +0 -1
  107. package/dist/packem_shared/isAccessible-PmWJhV6I.js +0 -1
  108. package/dist/packem_shared/isAccessibleSync-BrbOtwdr.js +0 -1
  109. package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +0 -52
  110. package/dist/packem_shared/move-DopmzT-2.js +0 -1
  111. package/dist/packem_shared/readFile-BswaBgM0.js +0 -1
  112. package/dist/packem_shared/readFileSync-_fDF6Oj1.js +0 -1
  113. package/dist/packem_shared/readIniSync-DKwRbbs9.js +0 -1
  114. package/dist/packem_shared/readToml-D4jpe9q_.js +0 -1
  115. package/dist/packem_shared/readTomlSync-B5PIYT9z.js +0 -1
  116. package/dist/packem_shared/remove-CSbrd0dl.js +0 -1
  117. package/dist/packem_shared/removeSync-BoLAzRQE.js +0 -1
  118. package/dist/packem_shared/renderError-B3ePOoBG-Bi9WKMjv.js +0 -6
  119. package/dist/packem_shared/sanitize-DGZ3w-_w.js +0 -1
  120. package/dist/packem_shared/to-uint-8-array-BImOQNXm.js +0 -1
  121. package/dist/packem_shared/walk-OX4-6oCP.js +0 -1
  122. package/dist/packem_shared/walkSync-BPs6czIM.js +0 -1
  123. package/dist/packem_shared/writeFile-BrMtsJY7.js +0 -1
  124. package/dist/packem_shared/writeFileSync-W7Mf4BNy.js +0 -1
  125. package/dist/packem_shared/writeIni-BWX3cP1K.js +0 -4
  126. package/dist/packem_shared/writeIniSync-fOdgPFfL.js +0 -4
  127. package/dist/packem_shared/writeJson-bEVi25gX.js +0 -4
  128. package/dist/packem_shared/writeJson5-Ch8TpNPI.js +0 -4
  129. package/dist/packem_shared/writeJson5Sync-BrctV_Mk.js +0 -4
  130. package/dist/packem_shared/writeJsonSync-DkGnd416.js +0 -4
  131. package/dist/packem_shared/writeJsonc-CefrwsOc.js +0 -4
  132. package/dist/packem_shared/writeJsoncSync-BskDjn8o.js +0 -4
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
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, l as JsonReviver, x as RetryOptions, y as WriteFileOptions, z as WriteJsonOptions } from "./packem_shared/types.d-BMdL_ygj.js";
2
- export { type A as CodeFrameLocation, type k as CodeFrameOptions, B as FIND_UP_STOP, D as F_OK, type E as FindUpNameFnResult, type H as FindUpNameSyncFnResult, type G as GlobOptions, type o as JsonReplacer, K as R_OK, type L as ReadFileEncoding, M as W_OK, X as X_OK } from "./packem_shared/types.d-BMdL_ygj.js";
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, l as JsonReviver, x as RetryOptions, y as WriteFileOptions, z as WriteJsonOptions } from "./packem_shared/types.d-D3Jo_iA-.js";
2
+ export { type A as CodeFrameLocation, type k as CodeFrameOptions, B as FIND_UP_STOP, D as F_OK, type E as FindUpNameFnResult, type H as FindUpNameSyncFnResult, type G as GlobOptions, type o as JsonReplacer, K as R_OK, type L as ReadFileEncoding, M as W_OK, X as X_OK } from "./packem_shared/types.d-D3Jo_iA-.js";
3
3
  import { symlink } from 'node:fs';
4
4
  export { CRLF, EOL, LF, detect, format } from "./eol.js";
5
- export { g as glob, a as globSync } from "./packem_shared/glob-sync.d-hXe38TnZ.js";
5
+ export { g as glob, a as globSync } from "./packem_shared/glob-sync.d-DaAZHTsv.js";
6
6
  export { type GlobParentOptions, default as globParent } from "./glob-parent.js";
7
7
  export { type IsGlobOptions, default as isGlob } from "./is-glob.js";
8
8
  export { type MatchOptions, match, matcher } from "./match.js";
@@ -10,878 +10,878 @@ import { JsonValue } from 'type-fest';
10
10
  import fs from 'fs';
11
11
  import 'fdir';
12
12
  /**
13
- * Options for `copy` and `copySync`.
14
- */
13
+ * Options for `copy` and `copySync`.
14
+ */
15
15
  type CopyOptions = {
16
16
  /**
17
- * Dereference symlinks, copying the files they point to instead of the
18
- * links themselves.
19
- * @default false
20
- */
17
+ * Dereference symlinks, copying the files they point to instead of the
18
+ * links themselves.
19
+ * @default false
20
+ */
21
21
  dereference?: boolean;
22
22
  /**
23
- * When `true`, throw an error if the destination already exists and
24
- * {@link CopyOptions.overwrite} is `false`. When `false`, existing files
25
- * are silently skipped.
26
- * @default true
27
- */
23
+ * When `true`, throw an error if the destination already exists and
24
+ * {@link CopyOptions.overwrite} is `false`. When `false`, existing files
25
+ * are silently skipped.
26
+ * @default true
27
+ */
28
28
  errorOnExist?: boolean;
29
29
  /**
30
- * Function to filter which files/directories are copied. Return `true` to
31
- * copy the item, `false` to skip it (and, for directories, their contents).
32
- * @param source The source path being considered.
33
- * @param destination The destination path it would be copied to.
34
- * @returns Whether to copy the item.
35
- */
30
+ * Function to filter which files/directories are copied. Return `true` to
31
+ * copy the item, `false` to skip it (and, for directories, their contents).
32
+ * @param source The source path being considered.
33
+ * @param destination The destination path it would be copied to.
34
+ * @returns Whether to copy the item.
35
+ */
36
36
  filter?: (source: string, destination: string) => boolean | Promise<boolean>;
37
37
  /**
38
- * Overwrite existing files/directories at the destination.
39
- * @default true
40
- */
38
+ * Overwrite existing files/directories at the destination.
39
+ * @default true
40
+ */
41
41
  overwrite?: boolean;
42
42
  /**
43
- * Preserve timestamps (`atime`/`mtime`) from the source.
44
- * @default false
45
- */
43
+ * Preserve timestamps (`atime`/`mtime`) from the source.
44
+ * @default false
45
+ */
46
46
  preserveTimestamps?: boolean;
47
47
  /**
48
- * When `true`, copy directories recursively.
49
- * @default true
50
- */
48
+ * When `true`, copy directories recursively.
49
+ * @default true
50
+ */
51
51
  recursive?: boolean;
52
52
  /**
53
- * When `overwrite` is `false`, this controls whether copying over an
54
- * existing file throws. Mirrors `node:fs.cp`'s `verbatimSymlinks`.
55
- * @default false
56
- */
53
+ * When `overwrite` is `false`, this controls whether copying over an
54
+ * existing file throws. Mirrors `node:fs.cp`'s `verbatimSymlinks`.
55
+ * @default false
56
+ */
57
57
  verbatimSymlinks?: boolean;
58
58
  };
59
59
  /**
60
- * Synchronous variant of {@link CopyOptions.filter}.
61
- */
60
+ * Synchronous variant of {@link CopyOptions.filter}.
61
+ */
62
62
  type CopyFilterSync = (source: string, destination: string) => boolean;
63
63
  /**
64
- * Asynchronously copies a file or directory (recursively) from `source` to `destination`.
65
- *
66
- * Built on `node:fs.cp`, this completes the fs-extra parity story alongside
67
- * `move`, `remove` and `emptyDir`.
68
- * @param source The file or directory to copy. Can be a file URL or a string path.
69
- * @param destination The target path. Can be a file URL or a string path.
70
- * @param options Optional configuration. See {@link CopyOptions}.
71
- * @returns A promise that resolves when the copy completes.
72
- * @throws {AlreadyExistsError} When `overwrite` is `false`, `errorOnExist` is `true`, and the destination exists.
73
- * @example
74
- * ```javascript
75
- * import { copy } from "@visulima/fs";
76
- *
77
- * // Copy a template directory, skipping node_modules and overwriting existing files
78
- * await copy("templates/app", "out/app", {
79
- * filter: (src) => !src.includes("node_modules"),
80
- * });
81
- * ```
82
- */
64
+ * Asynchronously copies a file or directory (recursively) from `source` to `destination`.
65
+ *
66
+ * Built on `node:fs.cp`, this completes the fs-extra parity story alongside
67
+ * `move`, `remove` and `emptyDir`.
68
+ * @param source The file or directory to copy. Can be a file URL or a string path.
69
+ * @param destination The target path. Can be a file URL or a string path.
70
+ * @param options Optional configuration. See {@link CopyOptions}.
71
+ * @returns A promise that resolves when the copy completes.
72
+ * @throws {AlreadyExistsError} When `overwrite` is `false`, `errorOnExist` is `true`, and the destination exists.
73
+ * @example
74
+ * ```javascript
75
+ * import { copy } from "@visulima/fs";
76
+ *
77
+ * // Copy a template directory, skipping node_modules and overwriting existing files
78
+ * await copy("templates/app", "out/app", {
79
+ * filter: (src) => !src.includes("node_modules"),
80
+ * });
81
+ * ```
82
+ */
83
83
  declare const copy: (source: URL | string, destination: URL | string, options?: CopyOptions) => Promise<void>;
84
84
  /**
85
- * Synchronously copies a file or directory (recursively) from `source` to `destination`.
86
- *
87
- * The synchronous counterpart of `copy`. Note that `cpSync` only accepts a
88
- * synchronous `filter`.
89
- * @param source The file or directory to copy. Can be a file URL or a string path.
90
- * @param destination The target path. Can be a file URL or a string path.
91
- * @param options Optional configuration. See {@link CopyOptions} (the `filter` must be synchronous).
92
- * @throws {AlreadyExistsError} When `overwrite` is `false`, `errorOnExist` is `true`, and the destination exists.
93
- * @example
94
- * ```javascript
95
- * import { copySync } from "@visulima/fs";
96
- *
97
- * copySync("templates/app", "out/app", { overwrite: false, errorOnExist: false });
98
- * ```
99
- */
85
+ * Synchronously copies a file or directory (recursively) from `source` to `destination`.
86
+ *
87
+ * The synchronous counterpart of `copy`. Note that `cpSync` only accepts a
88
+ * synchronous `filter`.
89
+ * @param source The file or directory to copy. Can be a file URL or a string path.
90
+ * @param destination The target path. Can be a file URL or a string path.
91
+ * @param options Optional configuration. See {@link CopyOptions} (the `filter` must be synchronous).
92
+ * @throws {AlreadyExistsError} When `overwrite` is `false`, `errorOnExist` is `true`, and the destination exists.
93
+ * @example
94
+ * ```javascript
95
+ * import { copySync } from "@visulima/fs";
96
+ *
97
+ * copySync("templates/app", "out/app", { overwrite: false, errorOnExist: false });
98
+ * ```
99
+ */
100
100
  declare const copySync: (source: URL | string, destination: URL | string, options?: Omit<CopyOptions, "filter"> & {
101
101
  filter?: CopyFilterSync;
102
102
  }) => void;
103
103
  /**
104
- * Ensures that the directory exists.
105
- * If the directory structure does not exist, it is created. Like mkdir -p.
106
- * @param directory The path to the directory to ensure exists.
107
- * @example
108
- * ```javascript
109
- * import ensureDir from "@visulima/fs/ensure/ensure-dir";
110
- *
111
- * await ensureDir("/tmp/foo/bar/baz");
112
- * // Creates the directory structure /tmp/foo/bar/baz if it doesn't exist
113
- * ```
114
- */
104
+ * Ensures that the directory exists.
105
+ * If the directory structure does not exist, it is created. Like mkdir -p.
106
+ * @param directory The path to the directory to ensure exists.
107
+ * @example
108
+ * ```javascript
109
+ * import ensureDir from "@visulima/fs/ensure/ensure-dir";
110
+ *
111
+ * await ensureDir("/tmp/foo/bar/baz");
112
+ * // Creates the directory structure /tmp/foo/bar/baz if it doesn't exist
113
+ * ```
114
+ */
115
115
  declare const ensureDir: (directory: URL | string) => Promise<void>;
116
116
  /**
117
- * Ensures that the directory exists.
118
- * If the directory structure does not exist, it is created. Like mkdir -p.
119
- * @param directory The path to the directory to ensure exists.
120
- * @example
121
- * ```javascript
122
- * import ensureDirSync from "@visulima/fs/ensure/ensure-dir-sync";
123
- *
124
- * ensureDirSync("/tmp/foo/bar/baz");
125
- * // Creates the directory structure /tmp/foo/bar/baz if it doesn't exist
126
- * ```
127
- */
117
+ * Ensures that the directory exists.
118
+ * If the directory structure does not exist, it is created. Like mkdir -p.
119
+ * @param directory The path to the directory to ensure exists.
120
+ * @example
121
+ * ```javascript
122
+ * import ensureDirSync from "@visulima/fs/ensure/ensure-dir-sync";
123
+ *
124
+ * ensureDirSync("/tmp/foo/bar/baz");
125
+ * // Creates the directory structure /tmp/foo/bar/baz if it doesn't exist
126
+ * ```
127
+ */
128
128
  declare const ensureDirSync: (directory: URL | string) => void;
129
129
  /**
130
- * Asynchronously ensures that a file exists.
131
- * If the directory structure for the file does not exist, it is created.
132
- * If the file already exists, it is not modified.
133
- * @param filePath The path to the file. Can be a string or a URL object.
134
- * @returns A Promise that resolves when the file has been created or confirmed to exist.
135
- * @throws Will throw an error if the path exists and is not a file.
136
- * @throws Will throw an error if directory or file creation fails for reasons other than the path not existing initially.
137
- * @example
138
- * ```typescript
139
- * import { ensureFile } from "@visulima/fs";
140
- *
141
- * (async () => {
142
- * try {
143
- * await ensureFile("path/to/my/file.txt");
144
- * console.log("File ensured!");
145
- *
146
- * await ensureFile(new URL("file:///path/to/another/file.log"));
147
- * console.log("Another file ensured!");
148
- * } catch (error) {
149
- * console.error("Failed to ensure file:", error);
150
- * }
151
- * })();
152
- * ```
153
- */
130
+ * Asynchronously ensures that a file exists.
131
+ * If the directory structure for the file does not exist, it is created.
132
+ * If the file already exists, it is not modified.
133
+ * @param filePath The path to the file. Can be a string or a URL object.
134
+ * @returns A Promise that resolves when the file has been created or confirmed to exist.
135
+ * @throws Will throw an error if the path exists and is not a file.
136
+ * @throws Will throw an error if directory or file creation fails for reasons other than the path not existing initially.
137
+ * @example
138
+ * ```typescript
139
+ * import { ensureFile } from "@visulima/fs";
140
+ *
141
+ * (async () => {
142
+ * try {
143
+ * await ensureFile("path/to/my/file.txt");
144
+ * console.log("File ensured!");
145
+ *
146
+ * await ensureFile(new URL("file:///path/to/another/file.log"));
147
+ * console.log("Another file ensured!");
148
+ * } catch (error) {
149
+ * console.error("Failed to ensure file:", error);
150
+ * }
151
+ * })();
152
+ * ```
153
+ */
154
154
  declare const ensureFile: (filePath: URL | string) => Promise<void>;
155
155
  /**
156
- * Ensures that the file exists.
157
- * If the file that is requested to be created is in directories that do not exist,
158
- * these directories are created. If the file already exists, it is NOT MODIFIED.
159
- * @param filePath The path to the file to ensure exists.
160
- * @example
161
- * ```javascript
162
- * import { ensureFileSync } from "@visulima/fs";
163
- *
164
- * ensureFileSync("/tmp/foo/bar/baz.txt");
165
- * // Creates the file /tmp/foo/bar/baz.txt and any missing parent directories if they don't exist
166
- * ```
167
- */
156
+ * Ensures that the file exists.
157
+ * If the file that is requested to be created is in directories that do not exist,
158
+ * these directories are created. If the file already exists, it is NOT MODIFIED.
159
+ * @param filePath The path to the file to ensure exists.
160
+ * @example
161
+ * ```javascript
162
+ * import { ensureFileSync } from "@visulima/fs";
163
+ *
164
+ * ensureFileSync("/tmp/foo/bar/baz.txt");
165
+ * // Creates the file /tmp/foo/bar/baz.txt and any missing parent directories if they don't exist
166
+ * ```
167
+ */
168
168
  declare const ensureFileSync: (filePath: URL | string) => void;
169
169
  /**
170
- * Ensures that the hard link exists.
171
- * If the directory structure does not exist, it is created.
172
- * @param source The path to the source file or directory.
173
- * @param destination The path to the destination link.
174
- * @example
175
- * ```javascript
176
- * import { ensureLink } from "@visulima/fs";
177
- * import { join } from "node:path";
178
- *
179
- * // ensure the link /tmp/foo/bar-link.txt points to /tmp/foo/bar.txt
180
- * await ensureLink(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "bar-link.txt"));
181
- * ```
182
- */
170
+ * Ensures that the hard link exists.
171
+ * If the directory structure does not exist, it is created.
172
+ * @param source The path to the source file or directory.
173
+ * @param destination The path to the destination link.
174
+ * @example
175
+ * ```javascript
176
+ * import { ensureLink } from "@visulima/fs";
177
+ * import { join } from "node:path";
178
+ *
179
+ * // ensure the link /tmp/foo/bar-link.txt points to /tmp/foo/bar.txt
180
+ * await ensureLink(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "bar-link.txt"));
181
+ * ```
182
+ */
183
183
  declare const ensureLink: (source: URL | string, destination: URL | string) => Promise<void>;
184
184
  /**
185
- * Ensures that the hard link exists.
186
- * If the directory structure does not exist, it is created.
187
- * @param source The path to the source file or directory.
188
- * @param destination The path to the destination link.
189
- * @example
190
- * ```javascript
191
- * import { ensureLinkSync } from "@visulima/fs";
192
- * import { join } from "node:path";
193
- *
194
- * // ensure the link /tmp/foo/bar-link.txt points to /tmp/foo/bar.txt
195
- * ensureLinkSync(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "bar-link.txt"));
196
- * ```
197
- */
185
+ * Ensures that the hard link exists.
186
+ * If the directory structure does not exist, it is created.
187
+ * @param source The path to the source file or directory.
188
+ * @param destination The path to the destination link.
189
+ * @example
190
+ * ```javascript
191
+ * import { ensureLinkSync } from "@visulima/fs";
192
+ * import { join } from "node:path";
193
+ *
194
+ * // ensure the link /tmp/foo/bar-link.txt points to /tmp/foo/bar.txt
195
+ * ensureLinkSync(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "bar-link.txt"));
196
+ * ```
197
+ */
198
198
  declare const ensureLinkSync: (source: URL | string, destination: URL | string) => void;
199
199
  /**
200
- * Ensures that the link exists, and points to a valid file.
201
- * If the directory structure does not exist, it is created.
202
- * If the link already exists, it is not modified but error is thrown if it is not point to the given target.
203
- * @param target the source file path
204
- * @param linkName the destination link path
205
- * @param type the type of the symlink, or null to use automatic detection
206
- * @returns A void promise that resolves once the link exists.
207
- * @example
208
- * ```javascript
209
- * import { ensureSymlink } from "@visulima/fs";
210
- * import { join } from "node:path";
211
- *
212
- * // Ensure a symlink /tmp/foo/link-to-bar.txt points to /tmp/foo/bar.txt
213
- * await ensureSymlink(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "link-to-bar.txt"));
214
- *
215
- * // Ensure a directory symlink /tmp/foo/link-to-baz-dir points to /tmp/foo/baz-dir
216
- * await ensureSymlink(join("/tmp", "foo", "baz-dir"), join("/tmp", "foo", "link-to-baz-dir"), "dir");
217
- * ```
218
- */
200
+ * Ensures that the link exists, and points to a valid file.
201
+ * If the directory structure does not exist, it is created.
202
+ * If the link already exists, it is not modified but error is thrown if it is not point to the given target.
203
+ * @param target the source file path
204
+ * @param linkName the destination link path
205
+ * @param type the type of the symlink, or null to use automatic detection
206
+ * @returns A void promise that resolves once the link exists.
207
+ * @example
208
+ * ```javascript
209
+ * import { ensureSymlink } from "@visulima/fs";
210
+ * import { join } from "node:path";
211
+ *
212
+ * // Ensure a symlink /tmp/foo/link-to-bar.txt points to /tmp/foo/bar.txt
213
+ * await ensureSymlink(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "link-to-bar.txt"));
214
+ *
215
+ * // Ensure a directory symlink /tmp/foo/link-to-baz-dir points to /tmp/foo/baz-dir
216
+ * await ensureSymlink(join("/tmp", "foo", "baz-dir"), join("/tmp", "foo", "link-to-baz-dir"), "dir");
217
+ * ```
218
+ */
219
219
  declare const ensureSymlink: (target: URL | string, linkName: URL | string, type?: symlink.Type) => Promise<void>;
220
220
  /**
221
- * Ensures that the link exists, and points to a valid file.
222
- * If the directory structure does not exist, it is created.
223
- * If the link already exists, it is not modified but error is thrown if it is not point to the given target.
224
- * @param target the source file path
225
- * @param linkName the destination link path
226
- * @param type the type of the symlink, or null to use automatic detection
227
- * @returns A void.
228
- * @example
229
- * ```javascript
230
- * import { ensureSymlinkSync } from "@visulima/fs";
231
- * import { join } from "node:path";
232
- *
233
- * // Ensure a symlink /tmp/foo/link-to-bar.txt points to /tmp/foo/bar.txt
234
- * ensureSymlinkSync(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "link-to-bar.txt"));
235
- *
236
- * // Ensure a directory symlink /tmp/foo/link-to-baz-dir points to /tmp/foo/baz-dir
237
- * ensureSymlinkSync(join("/tmp", "foo", "baz-dir"), join("/tmp", "foo", "link-to-baz-dir"), "dir");
238
- * ```
239
- */
221
+ * Ensures that the link exists, and points to a valid file.
222
+ * If the directory structure does not exist, it is created.
223
+ * If the link already exists, it is not modified but error is thrown if it is not point to the given target.
224
+ * @param target the source file path
225
+ * @param linkName the destination link path
226
+ * @param type the type of the symlink, or null to use automatic detection
227
+ * @returns A void.
228
+ * @example
229
+ * ```javascript
230
+ * import { ensureSymlinkSync } from "@visulima/fs";
231
+ * import { join } from "node:path";
232
+ *
233
+ * // Ensure a symlink /tmp/foo/link-to-bar.txt points to /tmp/foo/bar.txt
234
+ * ensureSymlinkSync(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "link-to-bar.txt"));
235
+ *
236
+ * // Ensure a directory symlink /tmp/foo/link-to-baz-dir points to /tmp/foo/baz-dir
237
+ * ensureSymlinkSync(join("/tmp", "foo", "baz-dir"), join("/tmp", "foo", "link-to-baz-dir"), "dir");
238
+ * ```
239
+ */
240
240
  declare const ensureSymlinkSync: (target: URL | string, linkName: URL | string, type?: symlink.Type) => void;
241
241
  /**
242
- * Asynchronously collects all file paths within a directory that match the specified criteria.
243
- * By default, it searches for JavaScript and TypeScript file extensions.
244
- * @param directory The root directory to start collecting files from.
245
- * @param options Optional configuration to control the collection process. See {@link WalkOptions}.
246
- * @returns A promise that resolves to an array of absolute file paths.
247
- * @example
248
- * ```javascript
249
- * import { collect } from "@visulima/fs";
250
- * import { join } from "node:path";
251
- *
252
- * const collectFiles = async () => {
253
- * // Collect all .txt and .md files in /tmp/docs, up to 2 levels deep
254
- * const files = await collect(join("/tmp", "docs"), {
255
- * extensions: ["txt", "md"],
256
- * maxDepth: 2,
257
- * includeDirs: false, // Only collect files
258
- * });
259
- * console.log(files);
260
- * // Example output: ['/tmp/docs/file1.txt', '/tmp/docs/subdir/report.md']
261
- *
262
- * // Collect all .js files, excluding anything in node_modules
263
- * const jsFiles = await collect(join("/tmp", "project"), {
264
- * extensions: ["js"],
265
- * skip: [/node_modules/],
266
- * });
267
- * console.log(jsFiles);
268
- * };
269
- *
270
- * collectFiles();
271
- * ```
272
- */
242
+ * Asynchronously collects all file paths within a directory that match the specified criteria.
243
+ * By default, it searches for JavaScript and TypeScript file extensions.
244
+ * @param directory The root directory to start collecting files from.
245
+ * @param options Optional configuration to control the collection process. See {@link WalkOptions}.
246
+ * @returns A promise that resolves to an array of absolute file paths.
247
+ * @example
248
+ * ```javascript
249
+ * import { collect } from "@visulima/fs";
250
+ * import { join } from "node:path";
251
+ *
252
+ * const collectFiles = async () => {
253
+ * // Collect all .txt and .md files in /tmp/docs, up to 2 levels deep
254
+ * const files = await collect(join("/tmp", "docs"), {
255
+ * extensions: ["txt", "md"],
256
+ * maxDepth: 2,
257
+ * includeDirs: false, // Only collect files
258
+ * });
259
+ * console.log(files);
260
+ * // Example output: ['/tmp/docs/file1.txt', '/tmp/docs/subdir/report.md']
261
+ *
262
+ * // Collect all .js files, excluding anything in node_modules
263
+ * const jsFiles = await collect(join("/tmp", "project"), {
264
+ * extensions: ["js"],
265
+ * skip: [/node_modules/],
266
+ * });
267
+ * console.log(jsFiles);
268
+ * };
269
+ *
270
+ * collectFiles();
271
+ * ```
272
+ */
273
273
  declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
274
274
  /**
275
- * Synchronously collects all file paths within a directory that match the specified criteria.
276
- * By default, it searches for JavaScript and TypeScript file extensions.
277
- * @param directory The root directory to start collecting files from.
278
- * @param options Optional configuration to control the collection process. See {@link WalkOptions}.
279
- * @returns An array of absolute file paths.
280
- * @example
281
- * ```javascript
282
- * import { collectSync } from "@visulima/fs";
283
- * import { join } from "node:path";
284
- *
285
- * // Collect all .txt and .md files in /tmp/docs, up to 2 levels deep
286
- * const files = collectSync(join("/tmp", "docs"), {
287
- * extensions: ["txt", "md"],
288
- * maxDepth: 2,
289
- * includeDirs: false, // Only collect files
290
- * });
291
- * console.log(files);
292
- * // Example output: ['/tmp/docs/file1.txt', '/tmp/docs/subdir/report.md']
293
- *
294
- * // Collect all .js files, excluding anything in node_modules
295
- * const jsFiles = collectSync(join("/tmp", "project"), {
296
- * extensions: ["js"],
297
- * skip: [/node_modules/],
298
- * });
299
- * console.log(jsFiles);
300
- * ```
301
- */
275
+ * Synchronously collects all file paths within a directory that match the specified criteria.
276
+ * By default, it searches for JavaScript and TypeScript file extensions.
277
+ * @param directory The root directory to start collecting files from.
278
+ * @param options Optional configuration to control the collection process. See {@link WalkOptions}.
279
+ * @returns An array of absolute file paths.
280
+ * @example
281
+ * ```javascript
282
+ * import { collectSync } from "@visulima/fs";
283
+ * import { join } from "node:path";
284
+ *
285
+ * // Collect all .txt and .md files in /tmp/docs, up to 2 levels deep
286
+ * const files = collectSync(join("/tmp", "docs"), {
287
+ * extensions: ["txt", "md"],
288
+ * maxDepth: 2,
289
+ * includeDirs: false, // Only collect files
290
+ * });
291
+ * console.log(files);
292
+ * // Example output: ['/tmp/docs/file1.txt', '/tmp/docs/subdir/report.md']
293
+ *
294
+ * // Collect all .js files, excluding anything in node_modules
295
+ * const jsFiles = collectSync(join("/tmp", "project"), {
296
+ * extensions: ["js"],
297
+ * skip: [/node_modules/],
298
+ * });
299
+ * console.log(jsFiles);
300
+ * ```
301
+ */
302
302
  declare const collectSync: (directory: string, options?: WalkOptions) => string[];
303
303
  /**
304
- * Asynchronously finds a file or directory by walking up parent directories.
305
- * @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`.
306
- * @param options Optional configuration for the search. See {@link FindUpOptions}.
307
- * @returns A promise that resolves to the absolute path of the first found file/directory, or `undefined` if not found.
308
- * @example
309
- * ```javascript
310
- * import { findUp } from "@visulima/fs";
311
- * import { join } from "node:path";
312
- *
313
- * const findProjectRoot = async () => {
314
- * // Find the closest package.json, starting from /tmp/foo/bar/baz
315
- * const projectRoot = await findUp("package.json", {
316
- * cwd: join("/tmp", "foo", "bar", "baz"),
317
- * type: "file",
318
- * });
319
- * console.log(projectRoot); // e.g., /tmp/foo/package.json or undefined
320
- *
321
- * // Find the closest .git directory or a README.md file
322
- * const gitDirOrReadme = await findUp([".git", "README.md"], {
323
- * cwd: join("/tmp", "foo", "bar"),
324
- * });
325
- * console.log(gitDirOrReadme);
326
- *
327
- * // Find using a custom function, stopping at /tmp
328
- * const customFound = await findUp(
329
- * (directory) => {
330
- * if (directory === join("/tmp", "foo")) {
331
- * return "found-it-here.txt"; // Pretend this file exists in /tmp/foo
332
- * }
333
- * return undefined;
334
- * },
335
- * {
336
- * cwd: join("/tmp", "foo", "bar", "baz"),
337
- * stopAt: join("/tmp"),
338
- * }
339
- * );
340
- * console.log(customFound);
341
- * };
342
- *
343
- * findProjectRoot();
344
- * ```
345
- */
304
+ * Asynchronously finds a file or directory by walking up parent directories.
305
+ * @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`.
306
+ * @param options Optional configuration for the search. See {@link FindUpOptions}.
307
+ * @returns A promise that resolves to the absolute path of the first found file/directory, or `undefined` if not found.
308
+ * @example
309
+ * ```javascript
310
+ * import { findUp } from "@visulima/fs";
311
+ * import { join } from "node:path";
312
+ *
313
+ * const findProjectRoot = async () => {
314
+ * // Find the closest package.json, starting from /tmp/foo/bar/baz
315
+ * const projectRoot = await findUp("package.json", {
316
+ * cwd: join("/tmp", "foo", "bar", "baz"),
317
+ * type: "file",
318
+ * });
319
+ * console.log(projectRoot); // e.g., /tmp/foo/package.json or undefined
320
+ *
321
+ * // Find the closest .git directory or a README.md file
322
+ * const gitDirOrReadme = await findUp([".git", "README.md"], {
323
+ * cwd: join("/tmp", "foo", "bar"),
324
+ * });
325
+ * console.log(gitDirOrReadme);
326
+ *
327
+ * // Find using a custom function, stopping at /tmp
328
+ * const customFound = await findUp(
329
+ * (directory) => {
330
+ * if (directory === join("/tmp", "foo")) {
331
+ * return "found-it-here.txt"; // Pretend this file exists in /tmp/foo
332
+ * }
333
+ * return undefined;
334
+ * },
335
+ * {
336
+ * cwd: join("/tmp", "foo", "bar", "baz"),
337
+ * stopAt: join("/tmp"),
338
+ * }
339
+ * );
340
+ * console.log(customFound);
341
+ * };
342
+ *
343
+ * findProjectRoot();
344
+ * ```
345
+ */
346
346
  declare const findUp: (name: FindUpName, options?: FindUpOptions) => Promise<string | undefined>;
347
347
  /**
348
- * Synchronously finds a file or directory by walking up parent directories.
349
- * @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`.
350
- * @param options Optional configuration for the search. See {@link FindUpOptions}.
351
- * @returns The absolute path of the first found file/directory, or `undefined` if not found.
352
- * @example
353
- * ```javascript
354
- * import { findUpSync } from "@visulima/fs";
355
- * import { join } from "node:path";
356
- *
357
- * // Find the closest package.json, starting from /tmp/foo/bar/baz
358
- * const projectRoot = findUpSync("package.json", {
359
- * cwd: join("/tmp", "foo", "bar", "baz"),
360
- * type: "file",
361
- * });
362
- * console.log(projectRoot); // e.g., /tmp/foo/package.json or undefined
363
- *
364
- * // Find the closest .git directory or a README.md file
365
- * const gitDirOrReadme = findUpSync([".git", "README.md"], {
366
- * cwd: join("/tmp", "foo", "bar"),
367
- * });
368
- * console.log(gitDirOrReadme);
369
- *
370
- * // Find using a custom function, stopping at /tmp
371
- * const customFound = findUpSync(
372
- * (directory) => {
373
- * if (directory === join("/tmp", "foo")) {
374
- * return "found-it-here.txt"; // Pretend this file exists in /tmp/foo
375
- * }
376
- * return undefined;
377
- * },
378
- * {
379
- * cwd: join("/tmp", "foo", "bar", "baz"),
380
- * stopAt: join("/tmp"),
381
- * }
382
- * );
383
- * console.log(customFound);
384
- * ```
385
- */
348
+ * Synchronously finds a file or directory by walking up parent directories.
349
+ * @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`.
350
+ * @param options Optional configuration for the search. See {@link FindUpOptions}.
351
+ * @returns The absolute path of the first found file/directory, or `undefined` if not found.
352
+ * @example
353
+ * ```javascript
354
+ * import { findUpSync } from "@visulima/fs";
355
+ * import { join } from "node:path";
356
+ *
357
+ * // Find the closest package.json, starting from /tmp/foo/bar/baz
358
+ * const projectRoot = findUpSync("package.json", {
359
+ * cwd: join("/tmp", "foo", "bar", "baz"),
360
+ * type: "file",
361
+ * });
362
+ * console.log(projectRoot); // e.g., /tmp/foo/package.json or undefined
363
+ *
364
+ * // Find the closest .git directory or a README.md file
365
+ * const gitDirOrReadme = findUpSync([".git", "README.md"], {
366
+ * cwd: join("/tmp", "foo", "bar"),
367
+ * });
368
+ * console.log(gitDirOrReadme);
369
+ *
370
+ * // Find using a custom function, stopping at /tmp
371
+ * const customFound = findUpSync(
372
+ * (directory) => {
373
+ * if (directory === join("/tmp", "foo")) {
374
+ * return "found-it-here.txt"; // Pretend this file exists in /tmp/foo
375
+ * }
376
+ * return undefined;
377
+ * },
378
+ * {
379
+ * cwd: join("/tmp", "foo", "bar", "baz"),
380
+ * stopAt: join("/tmp"),
381
+ * }
382
+ * );
383
+ * console.log(customFound);
384
+ * ```
385
+ */
386
386
  declare const findUpSync: (name: FindUpNameSync, options?: FindUpOptions) => string | undefined;
387
387
  /**
388
- * Asynchronously walks the file tree rooted at `directory`, yielding each file or directory that matches the criteria specified in `options`.
389
- * @param directory The root directory to start walking from.
390
- * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
391
- * @param options.extensions List of file extensions used to filter entries.
392
- * @param options.followSymlinks Indicates whether symlinks should be resolved or not.
393
- * @param options.includeDirs Indicates whether directory entries should be included or not.
394
- * @param options.includeFiles Indicates whether file entries should be included or not.
395
- * @param options.includeSymlinks Indicates whether symlink entries should be included or not.
396
- * @param options.match List of regular expression or glob patterns used to filter entries.
397
- * @param options.maxDepth Maximum depth to walk. Defaults to infinity.
398
- * @param options.skip List of regular expression or glob patterns used to skip entries.
399
- * @returns An async iterable iterator yielding {@link WalkEntry} objects for each matching file or directory.
400
- * @example
401
- * ```javascript
402
- * import { walk } from "@visulima/fs";
403
- * import { join } from "node:path";
404
- *
405
- * const printEntries = async () => {
406
- * // Walk through /tmp/my-project, looking for .ts files, max depth 2
407
- * for await (const entry of walk(join("/tmp", "my-project"), { extensions: ["ts"], maxDepth: 2 })) {
408
- * console.log(`Found: ${entry.path} (Type: ${entry.isFile() ? 'file' : 'directory'})`);
409
- * }
410
- *
411
- * // Walk, including only directories, and skip any node_modules folders
412
- * for await (const entry of walk(join("/tmp", "another-project"), { includeFiles: false, skip: [/node_modules/] })) {
413
- * if (entry.isDirectory()) {
414
- * console.log(`Directory: ${entry.path}`);
415
- * }
416
- * }
417
- * };
418
- *
419
- * printEntries();
420
- * ```
421
- */
388
+ * Asynchronously walks the file tree rooted at `directory`, yielding each file or directory that matches the criteria specified in `options`.
389
+ * @param directory The root directory to start walking from.
390
+ * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
391
+ * @param options.extensions List of file extensions used to filter entries.
392
+ * @param options.followSymlinks Indicates whether symlinks should be resolved or not.
393
+ * @param options.includeDirs Indicates whether directory entries should be included or not.
394
+ * @param options.includeFiles Indicates whether file entries should be included or not.
395
+ * @param options.includeSymlinks Indicates whether symlink entries should be included or not.
396
+ * @param options.match List of regular expression or glob patterns used to filter entries.
397
+ * @param options.maxDepth Maximum depth to walk. Defaults to infinity.
398
+ * @param options.skip List of regular expression or glob patterns used to skip entries.
399
+ * @returns An async iterable iterator yielding {@link WalkEntry} objects for each matching file or directory.
400
+ * @example
401
+ * ```javascript
402
+ * import { walk } from "@visulima/fs";
403
+ * import { join } from "node:path";
404
+ *
405
+ * const printEntries = async () => {
406
+ * // Walk through /tmp/my-project, looking for .ts files, max depth 2
407
+ * for await (const entry of walk(join("/tmp", "my-project"), { extensions: ["ts"], maxDepth: 2 })) {
408
+ * console.log(`Found: ${entry.path} (Type: ${entry.isFile() ? 'file' : 'directory'})`);
409
+ * }
410
+ *
411
+ * // Walk, including only directories, and skip any node_modules folders
412
+ * for await (const entry of walk(join("/tmp", "another-project"), { includeFiles: false, skip: [/node_modules/] })) {
413
+ * if (entry.isDirectory()) {
414
+ * console.log(`Directory: ${entry.path}`);
415
+ * }
416
+ * }
417
+ * };
418
+ *
419
+ * printEntries();
420
+ * ```
421
+ */
422
422
  declare function walk(directory: URL | string, options?: WalkOptions): AsyncIterableIterator<WalkEntry>;
423
423
  /**
424
- * Synchronously walks the file tree rooted at `directory`, yielding each file or directory that matches the criteria specified in `options`.
425
- * This is the synchronous version of the async walk function.
426
- * @param directory The root directory to start walking from.
427
- * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
428
- * @param options.extensions List of file extensions used to filter entries.
429
- * @param options.followSymlinks Indicates whether symlinks should be resolved or not.
430
- * @param options.includeDirs Indicates whether directory entries should be included or not.
431
- * @param options.includeFiles Indicates whether file entries should be included or not.
432
- * @param options.includeSymlinks Indicates whether symlink entries should be included or not.
433
- * @param options.match List of regular expression or glob patterns used to filter entries.
434
- * @param options.maxDepth Maximum depth to walk. Defaults to infinity.
435
- * @param options.skip List of regular expression or glob patterns used to skip entries.
436
- * @returns An iterable iterator yielding {@link WalkEntry} objects for each matching file or directory.
437
- * @example
438
- * ```javascript
439
- * import { walkSync } from "@visulima/fs";
440
- * import { join } from "node:path";
441
- *
442
- * // Walk through /tmp/my-project, looking for .ts files, max depth 2
443
- * for (const entry of walkSync(join("/tmp", "my-project"), { extensions: ["ts"], maxDepth: 2 })) {
444
- * console.log(`Found: ${entry.path} (Type: ${entry.isFile() ? 'file' : 'directory'})`);
445
- * }
446
- *
447
- * // Walk, including only directories, and skip any node_modules folders
448
- * for (const entry of walkSync(join("/tmp", "another-project"), { includeFiles: false, skip: [/node_modules/] })) {
449
- * if (entry.isDirectory()) {
450
- * console.log(`Directory: ${entry.path}`);
451
- * }
452
- * }
453
- * ```
454
- */
424
+ * Synchronously walks the file tree rooted at `directory`, yielding each file or directory that matches the criteria specified in `options`.
425
+ * This is the synchronous version of the async walk function.
426
+ * @param directory The root directory to start walking from.
427
+ * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
428
+ * @param options.extensions List of file extensions used to filter entries.
429
+ * @param options.followSymlinks Indicates whether symlinks should be resolved or not.
430
+ * @param options.includeDirs Indicates whether directory entries should be included or not.
431
+ * @param options.includeFiles Indicates whether file entries should be included or not.
432
+ * @param options.includeSymlinks Indicates whether symlink entries should be included or not.
433
+ * @param options.match List of regular expression or glob patterns used to filter entries.
434
+ * @param options.maxDepth Maximum depth to walk. Defaults to infinity.
435
+ * @param options.skip List of regular expression or glob patterns used to skip entries.
436
+ * @returns An iterable iterator yielding {@link WalkEntry} objects for each matching file or directory.
437
+ * @example
438
+ * ```javascript
439
+ * import { walkSync } from "@visulima/fs";
440
+ * import { join } from "node:path";
441
+ *
442
+ * // Walk through /tmp/my-project, looking for .ts files, max depth 2
443
+ * for (const entry of walkSync(join("/tmp", "my-project"), { extensions: ["ts"], maxDepth: 2 })) {
444
+ * console.log(`Found: ${entry.path} (Type: ${entry.isFile() ? 'file' : 'directory'})`);
445
+ * }
446
+ *
447
+ * // Walk, including only directories, and skip any node_modules folders
448
+ * for (const entry of walkSync(join("/tmp", "another-project"), { includeFiles: false, skip: [/node_modules/] })) {
449
+ * if (entry.isDirectory()) {
450
+ * console.log(`Directory: ${entry.path}`);
451
+ * }
452
+ * }
453
+ * ```
454
+ */
455
455
  declare function walkSync(directory: URL | string, options?: WalkOptions): IterableIterator<WalkEntry>;
456
456
  /**
457
- * Asynchronously tests a user's permissions for the file or directory specified by path.
458
- * Returns a Promise that resolves to `true` if the accessibility check is successful, `false` otherwise.
459
- * @param path The path to the file or directory. Can be a string or a URL object.
460
- * @param mode The accessibility checks to perform. Defaults to `F_OK` (check for existence).
461
- * Other possible values include `R_OK` (check for read access), `W_OK` (check for write access),
462
- * and `X_OK` (check for execute/search access). Multiple modes can be combined using bitwise OR.
463
- * @returns A Promise that resolves to a boolean indicating if the path is accessible with the specified mode.
464
- * @example
465
- * ```typescript
466
- * import { isAccessible, F_OK, R_OK } from "@visulima/fs";
467
- *
468
- * (async () => {
469
- * if (await isAccessible("myFile.txt")) {
470
- * console.log("myFile.txt exists");
471
- * }
472
- *
473
- * if (await isAccessible("myFile.txt", R_OK)) {
474
- * console.log("myFile.txt is readable");
475
- * }
476
- *
477
- * if (await isAccessible("myDirectory", F_OK | R_OK | W_OK)) {
478
- * console.log("myDirectory exists, is readable and writable");
479
- * }
480
- * })();
481
- * ```
482
- */
457
+ * Asynchronously tests a user's permissions for the file or directory specified by path.
458
+ * Returns a Promise that resolves to `true` if the accessibility check is successful, `false` otherwise.
459
+ * @param path The path to the file or directory. Can be a string or a URL object.
460
+ * @param mode The accessibility checks to perform. Defaults to `F_OK` (check for existence).
461
+ * Other possible values include `R_OK` (check for read access), `W_OK` (check for write access),
462
+ * and `X_OK` (check for execute/search access). Multiple modes can be combined using bitwise OR.
463
+ * @returns A Promise that resolves to a boolean indicating if the path is accessible with the specified mode.
464
+ * @example
465
+ * ```typescript
466
+ * import { isAccessible, F_OK, R_OK } from "@visulima/fs";
467
+ *
468
+ * (async () => {
469
+ * if (await isAccessible("myFile.txt")) {
470
+ * console.log("myFile.txt exists");
471
+ * }
472
+ *
473
+ * if (await isAccessible("myFile.txt", R_OK)) {
474
+ * console.log("myFile.txt is readable");
475
+ * }
476
+ *
477
+ * if (await isAccessible("myDirectory", F_OK | R_OK | W_OK)) {
478
+ * console.log("myDirectory exists, is readable and writable");
479
+ * }
480
+ * })();
481
+ * ```
482
+ */
483
483
  declare function isAccessible(path: URL | string, mode?: number): Promise<boolean>;
484
484
  /** Returns a boolean indicating if the path is accessible or not. */
485
485
  declare function isAccessibleSync(path: URL | string, mode?: number): boolean;
486
486
  type Options = {
487
487
  /**
488
- * The working directory to find source files.
489
- * The source and destination path are relative to this.
490
- * @default process.cwd()
491
- */
488
+ * The working directory to find source files.
489
+ * The source and destination path are relative to this.
490
+ * @default process.cwd()
491
+ */
492
492
  cwd?: URL | string;
493
493
  /**
494
- * [Permissions](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) for created directories.
495
- *
496
- * It has no effect on Windows.
497
- * @default 0o777
498
- */
494
+ * [Permissions](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) for created directories.
495
+ *
496
+ * It has no effect on Windows.
497
+ * @default 0o777
498
+ */
499
499
  readonly directoryMode?: number;
500
500
  /**
501
- * Overwrite existing destination file.
502
- * @default true
503
- */
501
+ * Overwrite existing destination file.
502
+ * @default true
503
+ */
504
504
  readonly overwrite?: boolean;
505
505
  };
506
506
  /**
507
- * Move a file asynchronously.
508
- * @param sourcePath The file you want to move.
509
- * @param destinationPath Where you want the file moved.
510
- * @param options Configuration options.
511
- * @returns A `Promise` that resolves when the file has been moved.
512
- * @example
513
- * ```
514
- * import { move } from '@visulima/fs';
515
- *
516
- * await move('source/test.png', 'destination/test.png');
517
- * console.log('The file has been moved');
518
- * ```
519
- */
507
+ * Move a file asynchronously.
508
+ * @param sourcePath The file you want to move.
509
+ * @param destinationPath Where you want the file moved.
510
+ * @param options Configuration options.
511
+ * @returns A `Promise` that resolves when the file has been moved.
512
+ * @example
513
+ * ```
514
+ * import { move } from '@visulima/fs';
515
+ *
516
+ * await move('source/test.png', 'destination/test.png');
517
+ * console.log('The file has been moved');
518
+ * ```
519
+ */
520
520
  declare const move: (sourcePath: string, destinationPath: string, options?: Options) => Promise<void>;
521
521
  /**
522
- * Move a file synchronously.
523
- * @param sourcePath The file you want to move.
524
- * @param destinationPath Where you want the file moved.
525
- * @param options Configuration options.
526
- * @example
527
- * ```
528
- * import { moveSync } from '@visulima/fs';
529
- *
530
- * moveSync('source/test.png', 'destination/test.png');
531
- * console.log('The file has been moved');
532
- * ```
533
- */
522
+ * Move a file synchronously.
523
+ * @param sourcePath The file you want to move.
524
+ * @param destinationPath Where you want the file moved.
525
+ * @param options Configuration options.
526
+ * @example
527
+ * ```
528
+ * import { moveSync } from '@visulima/fs';
529
+ *
530
+ * moveSync('source/test.png', 'destination/test.png');
531
+ * console.log('The file has been moved');
532
+ * ```
533
+ */
534
534
  declare const moveSync: (sourcePath: string, destinationPath: string, options?: Options) => void;
535
535
  /**
536
- * Rename a file asynchronously.
537
- * @param source The file you want to rename.
538
- * @param destination The name of the renamed file.
539
- * @param options Configuration options.
540
- * @returns A `Promise` that resolves when the file has been renamed.
541
- * @example
542
- * ```
543
- * import { rename } from '@visulima/fs';
544
- *
545
- * await rename('test.png', 'tests.png', {cwd: 'source'});
546
- * console.log('The file has been renamed');
547
- * ```
548
- */
536
+ * Rename a file asynchronously.
537
+ * @param source The file you want to rename.
538
+ * @param destination The name of the renamed file.
539
+ * @param options Configuration options.
540
+ * @returns A `Promise` that resolves when the file has been renamed.
541
+ * @example
542
+ * ```
543
+ * import { rename } from '@visulima/fs';
544
+ *
545
+ * await rename('test.png', 'tests.png', {cwd: 'source'});
546
+ * console.log('The file has been renamed');
547
+ * ```
548
+ */
549
549
  declare const rename: (source: string, destination: string, options?: Options) => Promise<void>;
550
550
  /**
551
- * Rename a file synchronously.
552
- * @param source The file you want to rename.
553
- * @param destination The name of the renamed file.
554
- * @param options Configuration options.
555
- * @example
556
- * ```
557
- * import { renameSync } from '@visulima/fs';
558
- *
559
- * renameSync('test.png', 'tests.png', {cwd: 'source'});
560
- * console.log('The file has been renamed');
561
- * ```
562
- */
551
+ * Rename a file synchronously.
552
+ * @param source The file you want to rename.
553
+ * @param destination The name of the renamed file.
554
+ * @param options Configuration options.
555
+ * @example
556
+ * ```
557
+ * import { renameSync } from '@visulima/fs';
558
+ *
559
+ * renameSync('test.png', 'tests.png', {cwd: 'source'});
560
+ * console.log('The file has been renamed');
561
+ * ```
562
+ */
563
563
  declare const renameSync: (source: string, destination: string, options?: Options) => void;
564
564
  type DecompressionMethod$1 = (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => void;
565
565
  declare const decompressionMethods$1: Record<string, DecompressionMethod$1>;
566
566
  /**
567
- * Asynchronously reads the entire contents of a file.
568
- * It can also decompress the file content if a `compression` option is provided.
569
- * @template O - The type of the options object, extending {@link ReadFileOptions}.
570
- * @param path The path to the file to read. Can be a file URL or a string path.
571
- * @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
572
- * Available `compression` methods: "brotli", "gzip", "none" (default).
573
- * @returns A promise that resolves with the file content. The type of the content (string or Buffer)
574
- * depends on the `buffer` option (defaults to string if `buffer` is false or not set).
575
- * @example
576
- * ```javascript
577
- * import { readFile } from "@visulima/fs";
578
- * import { join } from "node:path";
579
- *
580
- * const readMyFile = async () => {
581
- * try {
582
- * // Read a regular text file
583
- * const content = await readFile(join("path", "to", "my-file.txt"));
584
- * console.log("File content:", content);
585
- *
586
- * // Read a file as a Buffer
587
- * const bufferContent = await readFile(join("path", "to", "another-file.bin"), { buffer: true });
588
- * console.log("Buffer length:", bufferContent.length);
589
- *
590
- * // Read and decompress a gzipped file
591
- * // Assume my-archive.txt.gz exists
592
- * // const decompressedContent = await readFile(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
593
- * // console.log("Decompressed content:", decompressedContent);
594
- * } catch (error) {
595
- * console.error("Failed to read file:", error);
596
- * }
597
- * };
598
- *
599
- * readMyFile();
600
- * ```
601
- */
567
+ * Asynchronously reads the entire contents of a file.
568
+ * It can also decompress the file content if a `compression` option is provided.
569
+ * @template O - The type of the options object, extending {@link ReadFileOptions}.
570
+ * @param path The path to the file to read. Can be a file URL or a string path.
571
+ * @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
572
+ * Available `compression` methods: "brotli", "gzip", "none" (default).
573
+ * @returns A promise that resolves with the file content. The type of the content (string or Buffer)
574
+ * depends on the `buffer` option (defaults to string if `buffer` is false or not set).
575
+ * @example
576
+ * ```javascript
577
+ * import { readFile } from "@visulima/fs";
578
+ * import { join } from "node:path";
579
+ *
580
+ * const readMyFile = async () => {
581
+ * try {
582
+ * // Read a regular text file
583
+ * const content = await readFile(join("path", "to", "my-file.txt"));
584
+ * console.log("File content:", content);
585
+ *
586
+ * // Read a file as a Buffer
587
+ * const bufferContent = await readFile(join("path", "to", "another-file.bin"), { buffer: true });
588
+ * console.log("Buffer length:", bufferContent.length);
589
+ *
590
+ * // Read and decompress a gzipped file
591
+ * // Assume my-archive.txt.gz exists
592
+ * // const decompressedContent = await readFile(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
593
+ * // console.log("Decompressed content:", decompressedContent);
594
+ * } catch (error) {
595
+ * console.error("Failed to read file:", error);
596
+ * }
597
+ * };
598
+ *
599
+ * readMyFile();
600
+ * ```
601
+ */
602
602
  declare const readFile: <O extends ReadFileOptions<keyof typeof decompressionMethods$1> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O>>;
603
603
  type DecompressionMethod = (buffer: Buffer) => Buffer;
604
604
  declare const decompressionMethods: Record<string, DecompressionMethod>;
605
605
  /**
606
- * Synchronously reads the entire contents of a file.
607
- * It can also decompress the file content if a `compression` option is provided.
608
- * @template O - The type of the options object, extending {@link ReadFileOptions}.
609
- * @param path The path to the file to read. Can be a file URL or a string path.
610
- * @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
611
- * Available `compression` methods: "brotli", "gzip", "none" (default).
612
- * @returns The file content. The type of the content (string or Buffer)
613
- * depends on the `buffer` option (defaults to string if `buffer` is false or not set).
614
- * @example
615
- * ```javascript
616
- * import { readFileSync } from "@visulima/fs";
617
- * import { join } from "node:path";
618
- *
619
- * try {
620
- * // Read a regular text file
621
- * const content = readFileSync(join("path", "to", "my-file.txt"));
622
- * console.log("File content:", content);
623
- *
624
- * // Read a file as a Buffer
625
- * const bufferContent = readFileSync(join("path", "to", "another-file.bin"), { buffer: true });
626
- * console.log("Buffer length:", bufferContent.length);
627
- *
628
- * // Read and decompress a gzipped file
629
- * // Assume my-archive.txt.gz exists
630
- * // const decompressedContent = readFileSync(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
631
- * // console.log("Decompressed content:", decompressedContent);
632
- * } catch (error) {
633
- * console.error("Failed to read file:", error);
634
- * }
635
- * ```
636
- */
606
+ * Synchronously reads the entire contents of a file.
607
+ * It can also decompress the file content if a `compression` option is provided.
608
+ * @template O - The type of the options object, extending {@link ReadFileOptions}.
609
+ * @param path The path to the file to read. Can be a file URL or a string path.
610
+ * @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
611
+ * Available `compression` methods: "brotli", "gzip", "none" (default).
612
+ * @returns The file content. The type of the content (string or Buffer)
613
+ * depends on the `buffer` option (defaults to string if `buffer` is false or not set).
614
+ * @example
615
+ * ```javascript
616
+ * import { readFileSync } from "@visulima/fs";
617
+ * import { join } from "node:path";
618
+ *
619
+ * try {
620
+ * // Read a regular text file
621
+ * const content = readFileSync(join("path", "to", "my-file.txt"));
622
+ * console.log("File content:", content);
623
+ *
624
+ * // Read a file as a Buffer
625
+ * const bufferContent = readFileSync(join("path", "to", "another-file.bin"), { buffer: true });
626
+ * console.log("Buffer length:", bufferContent.length);
627
+ *
628
+ * // Read and decompress a gzipped file
629
+ * // Assume my-archive.txt.gz exists
630
+ * // const decompressedContent = readFileSync(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
631
+ * // console.log("Decompressed content:", decompressedContent);
632
+ * } catch (error) {
633
+ * console.error("Failed to read file:", error);
634
+ * }
635
+ * ```
636
+ */
637
637
  declare const readFileSync: <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O>;
638
638
  declare function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;
639
639
  declare function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;
640
640
  declare function readJsonSync(path: URL | string, options?: ReadJsonOptions): JsonValue;
641
641
  declare function readJsonSync(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): JsonValue;
642
642
  /**
643
- * Ensures that a directory is empty.
644
- * Deletes directory contents if the directory is not empty.
645
- * If the directory does not exist, it is created.
646
- * The directory itself is not deleted.
647
- * @param dir The path to the directory to empty.
648
- * @param options Optional configuration for the operation. See {@link RetryOptions}.
649
- * @returns A promise that resolves when the directory is empty.
650
- * @example
651
- * ```javascript
652
- * import { emptyDir } from "@visulima/fs";
653
- * import { join } from "node:path";
654
- *
655
- * const clearTempDir = async () => {
656
- * try {
657
- * await emptyDir(join("/tmp", "my-app-temp"));
658
- * console.log("Temporary directory emptied or created.");
659
- * } catch (error) {
660
- * console.error("Failed to empty directory:", error);
661
- * }
662
- * };
663
- *
664
- * clearTempDir();
665
- * ```
666
- */
643
+ * Ensures that a directory is empty.
644
+ * Deletes directory contents if the directory is not empty.
645
+ * If the directory does not exist, it is created.
646
+ * The directory itself is not deleted.
647
+ * @param dir The path to the directory to empty.
648
+ * @param options Optional configuration for the operation. See {@link RetryOptions}.
649
+ * @returns A promise that resolves when the directory is empty.
650
+ * @example
651
+ * ```javascript
652
+ * import { emptyDir } from "@visulima/fs";
653
+ * import { join } from "node:path";
654
+ *
655
+ * const clearTempDir = async () => {
656
+ * try {
657
+ * await emptyDir(join("/tmp", "my-app-temp"));
658
+ * console.log("Temporary directory emptied or created.");
659
+ * } catch (error) {
660
+ * console.error("Failed to empty directory:", error);
661
+ * }
662
+ * };
663
+ *
664
+ * clearTempDir();
665
+ * ```
666
+ */
667
667
  declare const emptyDir: (dir: URL | string, options?: RetryOptions) => Promise<void>;
668
668
  /**
669
- * Ensures that a directory is empty.
670
- * Deletes directory contents if the directory is not empty.
671
- * If the directory does not exist, it is created.
672
- * The directory itself is not deleted.
673
- * @param dir The path to the directory to empty.
674
- * @param options Optional configuration for the operation. See {@link RetryOptions}.
675
- * @example
676
- * ```javascript
677
- * import { emptyDirSync } from "@visulima/fs";
678
- * import { join } from "node:path";
679
- *
680
- * try {
681
- * emptyDirSync(join("/tmp", "my-app-temp"));
682
- * console.log("Temporary directory emptied or created.");
683
- * } catch (error) {
684
- * console.error("Failed to empty directory:", error);
685
- * }
686
- * ```
687
- */
669
+ * Ensures that a directory is empty.
670
+ * Deletes directory contents if the directory is not empty.
671
+ * If the directory does not exist, it is created.
672
+ * The directory itself is not deleted.
673
+ * @param dir The path to the directory to empty.
674
+ * @param options Optional configuration for the operation. See {@link RetryOptions}.
675
+ * @example
676
+ * ```javascript
677
+ * import { emptyDirSync } from "@visulima/fs";
678
+ * import { join } from "node:path";
679
+ *
680
+ * try {
681
+ * emptyDirSync(join("/tmp", "my-app-temp"));
682
+ * console.log("Temporary directory emptied or created.");
683
+ * } catch (error) {
684
+ * console.error("Failed to empty directory:", error);
685
+ * }
686
+ * ```
687
+ */
688
688
  declare const emptyDirSync: (dir: URL | string, options?: RetryOptions) => void;
689
689
  /**
690
- * Asynchronously removes a file or directory (recursively).
691
- * If the path does not exist, it does nothing.
692
- * @param path The path to the file or directory to remove.
693
- * @param options Optional configuration for the operation. See {@link RetryOptions}.
694
- * @returns A promise that resolves when the path has been removed.
695
- * @example
696
- * ```javascript
697
- * import { remove } from "@visulima/fs";
698
- * import { join } from "node:path";
699
- *
700
- * const deleteFileOrDir = async () => {
701
- * try {
702
- * await remove(join("/tmp", "my-file.txt"));
703
- * console.log("File /tmp/my-file.txt removed.");
704
- *
705
- * await remove(join("/tmp", "my-empty-dir"));
706
- * console.log("Directory /tmp/my-empty-dir removed.");
707
- *
708
- * await remove(join("/tmp", "my-dir-with-contents"));
709
- * console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
710
- * } catch (error) {
711
- * console.error("Failed to remove path:", error);
712
- * }
713
- * };
714
- *
715
- * deleteFileOrDir();
716
- * ```
717
- */
690
+ * Asynchronously removes a file or directory (recursively).
691
+ * If the path does not exist, it does nothing.
692
+ * @param path The path to the file or directory to remove.
693
+ * @param options Optional configuration for the operation. See {@link RetryOptions}.
694
+ * @returns A promise that resolves when the path has been removed.
695
+ * @example
696
+ * ```javascript
697
+ * import { remove } from "@visulima/fs";
698
+ * import { join } from "node:path";
699
+ *
700
+ * const deleteFileOrDir = async () => {
701
+ * try {
702
+ * await remove(join("/tmp", "my-file.txt"));
703
+ * console.log("File /tmp/my-file.txt removed.");
704
+ *
705
+ * await remove(join("/tmp", "my-empty-dir"));
706
+ * console.log("Directory /tmp/my-empty-dir removed.");
707
+ *
708
+ * await remove(join("/tmp", "my-dir-with-contents"));
709
+ * console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
710
+ * } catch (error) {
711
+ * console.error("Failed to remove path:", error);
712
+ * }
713
+ * };
714
+ *
715
+ * deleteFileOrDir();
716
+ * ```
717
+ */
718
718
  declare const remove: (path: URL | string, options?: RetryOptions) => Promise<void>;
719
719
  /**
720
- * Synchronously removes a file or directory (recursively).
721
- * If the path does not exist, it does nothing.
722
- * @param path The path to the file or directory to remove.
723
- * @param options Optional configuration for the operation. See {@link RetryOptions}.
724
- * @example
725
- * ```javascript
726
- * import { removeSync } from "@visulima/fs";
727
- * import { join } from "node:path";
728
- *
729
- * try {
730
- * removeSync(join("/tmp", "my-file.txt"));
731
- * console.log("File /tmp/my-file.txt removed.");
732
- *
733
- * removeSync(join("/tmp", "my-empty-dir"));
734
- * console.log("Directory /tmp/my-empty-dir removed.");
735
- *
736
- * removeSync(join("/tmp", "my-dir-with-contents"));
737
- * console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
738
- * } catch (error) {
739
- * console.error("Failed to remove path:", error);
740
- * }
741
- * ```
742
- */
720
+ * Synchronously removes a file or directory (recursively).
721
+ * If the path does not exist, it does nothing.
722
+ * @param path The path to the file or directory to remove.
723
+ * @param options Optional configuration for the operation. See {@link RetryOptions}.
724
+ * @example
725
+ * ```javascript
726
+ * import { removeSync } from "@visulima/fs";
727
+ * import { join } from "node:path";
728
+ *
729
+ * try {
730
+ * removeSync(join("/tmp", "my-file.txt"));
731
+ * console.log("File /tmp/my-file.txt removed.");
732
+ *
733
+ * removeSync(join("/tmp", "my-empty-dir"));
734
+ * console.log("Directory /tmp/my-empty-dir removed.");
735
+ *
736
+ * removeSync(join("/tmp", "my-dir-with-contents"));
737
+ * console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
738
+ * } catch (error) {
739
+ * console.error("Failed to remove path:", error);
740
+ * }
741
+ * ```
742
+ */
743
743
  declare const removeSync: (path: URL | string, options?: RetryOptions) => void;
744
744
  /**
745
- * Supported filesystem types
746
- */
745
+ * Supported filesystem types
746
+ */
747
747
  type FileSystemType = "win32" | "unix" | "darwin" | "fat32" | "auto";
748
748
  /**
749
- * Options for the sanitize function
750
- */
749
+ * Options for the sanitize function
750
+ */
751
751
  interface SanitizeOptions {
752
752
  /**
753
- * Target filesystem type for sanitization rules
754
- * - "win32": Windows filesystem rules (reserved names, Windows forbidden chars, no trailing periods/spaces)
755
- * - "unix": Unix/Linux filesystem rules (only / and null forbidden)
756
- * - "darwin": macOS filesystem rules (same as unix)
757
- * - "fat32": FAT32 filesystem rules (Windows rules + no leading/trailing spaces/periods in name part)
758
- * - "auto": Automatically detect from process.platform
759
- * @default "auto"
760
- */
753
+ * Target filesystem type for sanitization rules
754
+ * - "win32": Windows filesystem rules (reserved names, Windows forbidden chars, no trailing periods/spaces)
755
+ * - "unix": Unix/Linux filesystem rules (only / and null forbidden)
756
+ * - "darwin": macOS filesystem rules (same as unix)
757
+ * - "fat32": FAT32 filesystem rules (Windows rules + no leading/trailing spaces/periods in name part)
758
+ * - "auto": Automatically detect from process.platform
759
+ * @default "auto"
760
+ */
761
761
  filesystem?: FileSystemType;
762
762
  /**
763
- * Maximum length of the sanitized name
764
- * @default 128
765
- */
763
+ * Maximum length of the sanitized name
764
+ * @default 128
765
+ */
766
766
  maxLength?: number;
767
767
  }
768
768
  /**
769
- * Sanitizes a filename by removing or replacing forbidden characters.
770
- * @param name The filename to sanitize.
771
- * @param options Optional configuration.
772
- * @returns The sanitized filename, or "unnamed" if the result would be empty.
773
- */
769
+ * Sanitizes a filename by removing or replacing forbidden characters.
770
+ * @param name The filename to sanitize.
771
+ * @param options Optional configuration.
772
+ * @returns The sanitized filename, or "unnamed" if the result would be empty.
773
+ */
774
774
  declare const sanitize: (name: string, options?: Partial<SanitizeOptions>) => string;
775
775
  /**
776
- * Asynchronously writes data to a file, replacing the file if it already exists.
777
- * This function includes safeguards like writing to a temporary file first and then renaming, and handling permissions.
778
- * @param path The path to the file to write. Can be a file URL or a string path.
779
- * @param content The data to write. Can be a string, Buffer, ArrayBuffer, or ArrayBufferView.
780
- * @param options Optional configuration for writing the file. See {@link WriteFileOptions}.
781
- * @returns A promise that resolves when the file has been written.
782
- * @example
783
- * ```javascript
784
- * import { writeFile } from "@visulima/fs";
785
- * import { join } from "node:path";
786
- *
787
- * const writeMyFile = async () => {
788
- * try {
789
- * await writeFile(join("/tmp", "my-new-file.txt"), "Hello World!");
790
- * console.log("File written successfully.");
791
- *
792
- * await writeFile(join("/tmp", "another-file.txt"), "Some other content", { encoding: 'utf16le', mode: 0o600 });
793
- * console.log("Another file written with specific options.");
794
- * } catch (error) {
795
- * console.error("Failed to write file:", error);
796
- * }
797
- * };
798
- *
799
- * writeMyFile();
800
- * ```
801
- */
776
+ * Asynchronously writes data to a file, replacing the file if it already exists.
777
+ * This function includes safeguards like writing to a temporary file first and then renaming, and handling permissions.
778
+ * @param path The path to the file to write. Can be a file URL or a string path.
779
+ * @param content The data to write. Can be a string, Buffer, ArrayBuffer, or ArrayBufferView.
780
+ * @param options Optional configuration for writing the file. See {@link WriteFileOptions}.
781
+ * @returns A promise that resolves when the file has been written.
782
+ * @example
783
+ * ```javascript
784
+ * import { writeFile } from "@visulima/fs";
785
+ * import { join } from "node:path";
786
+ *
787
+ * const writeMyFile = async () => {
788
+ * try {
789
+ * await writeFile(join("/tmp", "my-new-file.txt"), "Hello World!");
790
+ * console.log("File written successfully.");
791
+ *
792
+ * await writeFile(join("/tmp", "another-file.txt"), "Some other content", { encoding: 'utf16le', mode: 0o600 });
793
+ * console.log("Another file written with specific options.");
794
+ * } catch (error) {
795
+ * console.error("Failed to write file:", error);
796
+ * }
797
+ * };
798
+ *
799
+ * writeMyFile();
800
+ * ```
801
+ */
802
802
  declare const writeFile: (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions) => Promise<void>;
803
803
  /**
804
- * Synchronously writes data to a file, replacing the file if it already exists.
805
- * This function includes safeguards like writing to a temporary file first and then renaming, and handling permissions.
806
- * @param path The path to the file to write. Can be a file URL or a string path.
807
- * @param content The data to write. Can be a string, Buffer, ArrayBuffer, or ArrayBufferView.
808
- * @param options Optional configuration for writing the file. See {@link WriteFileOptions}.
809
- * @returns void
810
- * @example
811
- * ```javascript
812
- * import { writeFileSync } from "@visulima/fs";
813
- * import { join } from "node:path";
814
- *
815
- * const writeMyFileSync = () => {
816
- * try {
817
- * writeFileSync(join("/tmp", "my-new-file-sync.txt"), "Hello World Synchronously!");
818
- * console.log("File written successfully (sync).");
819
- *
820
- * writeFileSync(join("/tmp", "another-file-sync.txt"), "Some other sync content", { encoding: 'utf16le', mode: 0o600 });
821
- * console.log("Another file written with specific options (sync).");
822
- * } catch (error) {
823
- * console.error("Failed to write file (sync):", error);
824
- * }
825
- * };
826
- *
827
- * writeMyFileSync();
828
- * ```
829
- */
804
+ * Synchronously writes data to a file, replacing the file if it already exists.
805
+ * This function includes safeguards like writing to a temporary file first and then renaming, and handling permissions.
806
+ * @param path The path to the file to write. Can be a file URL or a string path.
807
+ * @param content The data to write. Can be a string, Buffer, ArrayBuffer, or ArrayBufferView.
808
+ * @param options Optional configuration for writing the file. See {@link WriteFileOptions}.
809
+ * @returns void
810
+ * @example
811
+ * ```javascript
812
+ * import { writeFileSync } from "@visulima/fs";
813
+ * import { join } from "node:path";
814
+ *
815
+ * const writeMyFileSync = () => {
816
+ * try {
817
+ * writeFileSync(join("/tmp", "my-new-file-sync.txt"), "Hello World Synchronously!");
818
+ * console.log("File written successfully (sync).");
819
+ *
820
+ * writeFileSync(join("/tmp", "another-file-sync.txt"), "Some other sync content", { encoding: 'utf16le', mode: 0o600 });
821
+ * console.log("Another file written with specific options (sync).");
822
+ * } catch (error) {
823
+ * console.error("Failed to write file (sync):", error);
824
+ * }
825
+ * };
826
+ *
827
+ * writeMyFileSync();
828
+ * ```
829
+ */
830
830
  declare const writeFileSync: (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions) => void;
831
831
  /**
832
- * Asynchronously writes an object to a JSON file.
833
- * Handles indentation detection, custom stringifiers, and gracefully manages existing files.
834
- * @param path The path to the JSON file to write. Can be a file URL or a string path.
835
- * @param data The data to serialize and write. Can be any JavaScript value that can be stringified by `JSON.stringify` or a custom stringifier.
836
- * @param options Optional configuration for writing the JSON file. See {@link WriteJsonOptions}.
837
- * @returns A promise that resolves when the JSON file has been written.
838
- * @example
839
- * ```javascript
840
- * import { writeJson } from "@visulima/fs";
841
- * import { join } from "node:path";
842
- *
843
- * const writeMyJson = async () => {
844
- * try {
845
- * await writeJson(join("/tmp", "my-config.json"), { setting: "enabled", value: 123 });
846
- * console.log("JSON file written successfully.");
847
- *
848
- * await writeJson(join("/tmp", "another-config.json"), { user: "test", id: "abc" }, { indent: 2, replacer: ["user"] });
849
- * console.log("Another JSON file written with specific options (indent 2, only 'user' key).");
850
- * } catch (error) {
851
- * console.error("Failed to write JSON file:", error);
852
- * }
853
- * };
854
- *
855
- * writeMyJson();
856
- * ```
857
- */
832
+ * Asynchronously writes an object to a JSON file.
833
+ * Handles indentation detection, custom stringifiers, and gracefully manages existing files.
834
+ * @param path The path to the JSON file to write. Can be a file URL or a string path.
835
+ * @param data The data to serialize and write. Can be any JavaScript value that can be stringified by `JSON.stringify` or a custom stringifier.
836
+ * @param options Optional configuration for writing the JSON file. See {@link WriteJsonOptions}.
837
+ * @returns A promise that resolves when the JSON file has been written.
838
+ * @example
839
+ * ```javascript
840
+ * import { writeJson } from "@visulima/fs";
841
+ * import { join } from "node:path";
842
+ *
843
+ * const writeMyJson = async () => {
844
+ * try {
845
+ * await writeJson(join("/tmp", "my-config.json"), { setting: "enabled", value: 123 });
846
+ * console.log("JSON file written successfully.");
847
+ *
848
+ * await writeJson(join("/tmp", "another-config.json"), { user: "test", id: "abc" }, { indent: 2, replacer: ["user"] });
849
+ * console.log("Another JSON file written with specific options (indent 2, only 'user' key).");
850
+ * } catch (error) {
851
+ * console.error("Failed to write JSON file:", error);
852
+ * }
853
+ * };
854
+ *
855
+ * writeMyJson();
856
+ * ```
857
+ */
858
858
  declare const writeJson: (path: URL | string, data: unknown, options?: WriteJsonOptions) => Promise<void>;
859
859
  /**
860
- * Synchronously writes an object to a JSON file.
861
- * Handles indentation detection, custom stringifiers, and gracefully manages existing files.
862
- * @param path The path to the JSON file to write. Can be a file URL or a string path.
863
- * @param data The data to serialize and write. Can be any JavaScript value that can be stringified by `JSON.stringify` or a custom stringifier.
864
- * @param options Optional configuration for writing the JSON file. See {@link WriteJsonOptions}.
865
- * @example
866
- * ```javascript
867
- * import { writeJsonSync } from "@visulima/fs";
868
- * import { join } from "node:path";
869
- *
870
- * const writeMyJsonSync = () => {
871
- * try {
872
- * writeJsonSync(join("/tmp", "my-config-sync.json"), { setting: "enabled", value: 456 });
873
- * console.log("JSON file written successfully (sync).");
874
- *
875
- * writeJsonSync(join("/tmp", "another-config-sync.json"), { user: "testSync", id: "def" }, { indent: 4, replacer: ["id"] });
876
- * console.log("Another JSON file written with specific options (sync, indent 4, only 'id' key).");
877
- * } catch (error) {
878
- * console.error("Failed to write JSON file (sync):", error);
879
- * }
880
- * };
881
- *
882
- * writeMyJsonSync();
883
- * ```
884
- */
860
+ * Synchronously writes an object to a JSON file.
861
+ * Handles indentation detection, custom stringifiers, and gracefully manages existing files.
862
+ * @param path The path to the JSON file to write. Can be a file URL or a string path.
863
+ * @param data The data to serialize and write. Can be any JavaScript value that can be stringified by `JSON.stringify` or a custom stringifier.
864
+ * @param options Optional configuration for writing the JSON file. See {@link WriteJsonOptions}.
865
+ * @example
866
+ * ```javascript
867
+ * import { writeJsonSync } from "@visulima/fs";
868
+ * import { join } from "node:path";
869
+ *
870
+ * const writeMyJsonSync = () => {
871
+ * try {
872
+ * writeJsonSync(join("/tmp", "my-config-sync.json"), { setting: "enabled", value: 456 });
873
+ * console.log("JSON file written successfully (sync).");
874
+ *
875
+ * writeJsonSync(join("/tmp", "another-config-sync.json"), { user: "testSync", id: "def" }, { indent: 4, replacer: ["id"] });
876
+ * console.log("Another JSON file written with specific options (sync, indent 4, only 'id' key).");
877
+ * } catch (error) {
878
+ * console.error("Failed to write JSON file (sync):", error);
879
+ * }
880
+ * };
881
+ *
882
+ * writeMyJsonSync();
883
+ * ```
884
+ */
885
885
  declare const writeJsonSync: (path: URL | string, data: unknown, options?: WriteJsonOptions) => void;
886
886
  /**
887
887
  * Subset of Node.js fs module methods required for case-sensitivity detection.