@visulima/fs 5.0.0-alpha.6 → 5.0.0-alpha.7

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 (46) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/error/walk-error.d.ts +1 -1
  3. package/dist/error.js +1 -1
  4. package/dist/find/walk-sync.d.ts +1 -1
  5. package/dist/index.js +25 -25
  6. package/dist/packem_shared/{WalkError-DUdQd6FT.js → WalkError-DER5A43G.js} +1 -1
  7. package/dist/packem_shared/{collect-DcBwsYYd.js → collect-BnUYRrRI.js} +1 -1
  8. package/dist/packem_shared/{collectSync-Bkjf9Dbm.js → collectSync-D5G2RGDI.js} +1 -1
  9. package/dist/packem_shared/{emptyDir-CYB5Tict.js → emptyDir-Df4Tfjtk.js} +2 -1
  10. package/dist/packem_shared/{ensureDir-C_kuQ5Ik.js → ensureDir-DNlPftys.js} +2 -2
  11. package/dist/packem_shared/{ensureDirSync-CI5g-uBI.js → ensureDirSync-DcPZFMy5.js} +2 -2
  12. package/dist/packem_shared/{ensureFile-BUtXGlGT.js → ensureFile-BRQpUOUM.js} +2 -2
  13. package/dist/packem_shared/{ensureFileSync-C8hASR-1.js → ensureFileSync-SBY7A9-C.js} +2 -2
  14. package/dist/packem_shared/{ensureLink-BPnAG5-P.js → ensureLink-DJQeauEn.js} +4 -3
  15. package/dist/packem_shared/{ensureLinkSync-B-Z7X0ub.js → ensureLinkSync-D9RVAglV.js} +4 -3
  16. package/dist/packem_shared/{ensureSymlink-U5B6J0BN.js → ensureSymlink-CoRYDRwr.js} +10 -3
  17. package/dist/packem_shared/{ensureSymlinkSync-DHnZj-9F.js → ensureSymlinkSync-CFimFlgh.js} +10 -3
  18. package/dist/packem_shared/{findUp-BSnyGqer.js → findUp-YcNLKdfV.js} +3 -4
  19. package/dist/packem_shared/{findUpSync-jRHbSCMV.js → findUpSync-BfA5fheN.js} +1 -3
  20. package/dist/packem_shared/{parseJson-Cnex0kz2.js → parseJson-BedVi91S.js} +15 -14
  21. package/dist/packem_shared/{readFileSync-6GEIrOnl.js → readFileSync-gm9yfIhh.js} +2 -1
  22. package/dist/packem_shared/{readJson-CJF1t7xB.js → readJson-D0G0ndHL.js} +1 -1
  23. package/dist/packem_shared/{readJsonSync-ciofT7AF.js → readJsonSync-B7oicPaL.js} +2 -2
  24. package/dist/packem_shared/{readYamlSync-DMV4U-gi.js → readYamlSync-BKX-PAfq.js} +1 -1
  25. package/dist/packem_shared/{remove-_oDY3uKo.js → remove-CNkjFFkQ.js} +1 -1
  26. package/dist/packem_shared/{removeSync-DETRj7Qn.js → removeSync-AnawYpPv.js} +1 -1
  27. package/dist/packem_shared/{sanitize-lOzE6k2A.js → sanitize-BZoLN9Fg.js} +3 -3
  28. package/dist/packem_shared/{walk-BhTbpr3y.js → walk-D5yHruvk.js} +9 -7
  29. package/dist/packem_shared/{walkSync-DDBq95s8.js → walkSync-09nKPVw4.js} +15 -13
  30. package/dist/packem_shared/{writeFile-DSHERs0Z.js → writeFile-B8HX0JIQ.js} +1 -3
  31. package/dist/packem_shared/{writeFileSync-CJp1kXQR.js → writeFileSync-DB8vv8xR.js} +1 -3
  32. package/dist/packem_shared/{writeJson-C0OfLDbe.js → writeJson-Bo7C2UHw.js} +1 -1
  33. package/dist/packem_shared/{writeJsonSync-Cs21FE7v.js → writeJsonSync-BKZ_9Acr.js} +1 -1
  34. package/dist/packem_shared/{writeYaml-n4xzYN9a.js → writeYaml-BWCOome-.js} +3 -3
  35. package/dist/packem_shared/{writeYamlSync-DnOEnP10.js → writeYamlSync-DBVnXmuY.js} +3 -3
  36. package/dist/read/read-file-sync.d.ts +1 -1
  37. package/dist/read/read-json-sync.d.ts +2 -2
  38. package/dist/read/read-yaml-sync.d.ts +2 -2
  39. package/dist/size.js +3 -1
  40. package/dist/types.d.ts +8 -8
  41. package/dist/utils/parse-json.d.ts +2 -2
  42. package/dist/utils.js +1 -1
  43. package/dist/write/write-yaml-sync.d.ts +2 -2
  44. package/dist/write/write-yaml.d.ts +2 -2
  45. package/dist/yaml.js +3 -3
  46. package/package.json +2 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## @visulima/fs [5.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/fs@5.0.0-alpha.6...@visulima/fs@5.0.0-alpha.7) (2026-04-08)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **fs:** prevent walk/walkSync from crashing on symlinks pointing to files ([e6338b0](https://github.com/visulima/visulima/commit/e6338b0c169048240762d22fe14152e370f7e862))
6
+ * **fs:** properly fix eslint errors in code ([da36de3](https://github.com/visulima/visulima/commit/da36de37493cdd65aa28505d5fbdd671ce842663))
7
+ * **fs:** remove remaining eslint suppressions with proper code fixes ([cede286](https://github.com/visulima/visulima/commit/cede2869d5a31a3b2cd020f2050dddbfd742a619))
8
+ * **fs:** resolve eslint errors ([817fd4d](https://github.com/visulima/visulima/commit/817fd4d0f5f74debaf222837b94bd1f3a16d66ae))
9
+
10
+ ### Miscellaneous Chores
11
+
12
+ * **filesystem:** remove empty dependency objects from package.json ([76ffc54](https://github.com/visulima/visulima/commit/76ffc545660695dde19130d1c01d9bd1aaf2ca98))
13
+ * **fs:** add tsconfig.eslint.json for type-aware linting ([701b2cb](https://github.com/visulima/visulima/commit/701b2cb4801dbefe12db85ff3c772c6a8a975539))
14
+ * **fs:** apply prettier formatting ([29bc3ed](https://github.com/visulima/visulima/commit/29bc3eda63666c911c8810be20e3b550eaab7377))
15
+ * **fs:** migrate .prettierrc.cjs to prettier.config.js ([fa37870](https://github.com/visulima/visulima/commit/fa37870179d8dbebe210229a9fd00296efac5f4d))
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * **@visulima/path:** upgraded to 3.0.0-alpha.8
21
+ * **@visulima/error:** upgraded to 6.0.0-alpha.8
22
+
1
23
  ## @visulima/fs [5.0.0-alpha.6](https://github.com/visulima/visulima/compare/@visulima/fs@5.0.0-alpha.5...@visulima/fs@5.0.0-alpha.6) (2026-03-26)
2
24
 
3
25
  ### Features
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration.
2
+ * Error thrown in walk or walkSync during iteration.
3
3
  * @example
4
4
  * ```javascript
5
5
  * import { WalkError } from "@visulima/fs/error";
package/dist/error.js CHANGED
@@ -4,4 +4,4 @@ export { default as JSONError } from './packem_shared/JSONError-BkHRnInH.js';
4
4
  export { default as NotEmptyError } from './packem_shared/NotEmptyError-B21RUlVr.js';
5
5
  export { default as NotFoundError } from './packem_shared/NotFoundError-BIp61X6k.js';
6
6
  export { default as PermissionError } from './packem_shared/PermissionError-CjoiJgip.js';
7
- export { default as WalkError } from './packem_shared/WalkError-DUdQd6FT.js';
7
+ export { default as WalkError } from './packem_shared/WalkError-DER5A43G.js';
@@ -1,7 +1,7 @@
1
1
  import type { WalkEntry, WalkOptions } from "../types.d.ts";
2
2
  /**
3
3
  * Synchronously walks the file tree rooted at `directory`, yielding each file or directory that matches the criteria specified in `options`.
4
- * This is the synchronous version of the {@linkcode walk} function.
4
+ * This is the synchronous version of the async walk function.
5
5
  * @param directory The root directory to start walking from.
6
6
  * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
7
7
  * @param options.extensions List of file extensions used to filter entries.
package/dist/index.js CHANGED
@@ -1,33 +1,33 @@
1
1
  export { FIND_UP_STOP, F_OK, R_OK, W_OK, X_OK } from './packem_shared/F_OK-MldBaGxb.js';
2
- export { default as ensureDir } from './packem_shared/ensureDir-C_kuQ5Ik.js';
3
- export { default as ensureDirSync } from './packem_shared/ensureDirSync-CI5g-uBI.js';
4
- export { default as ensureFile } from './packem_shared/ensureFile-BUtXGlGT.js';
5
- export { default as ensureFileSync } from './packem_shared/ensureFileSync-C8hASR-1.js';
6
- export { default as ensureLink } from './packem_shared/ensureLink-BPnAG5-P.js';
7
- export { default as ensureLinkSync } from './packem_shared/ensureLinkSync-B-Z7X0ub.js';
8
- export { default as ensureSymlink } from './packem_shared/ensureSymlink-U5B6J0BN.js';
9
- export { default as ensureSymlinkSync } from './packem_shared/ensureSymlinkSync-DHnZj-9F.js';
2
+ export { default as ensureDir } from './packem_shared/ensureDir-DNlPftys.js';
3
+ export { default as ensureDirSync } from './packem_shared/ensureDirSync-DcPZFMy5.js';
4
+ export { default as ensureFile } from './packem_shared/ensureFile-BRQpUOUM.js';
5
+ export { default as ensureFileSync } from './packem_shared/ensureFileSync-SBY7A9-C.js';
6
+ export { default as ensureLink } from './packem_shared/ensureLink-DJQeauEn.js';
7
+ export { default as ensureLinkSync } from './packem_shared/ensureLinkSync-D9RVAglV.js';
8
+ export { default as ensureSymlink } from './packem_shared/ensureSymlink-CoRYDRwr.js';
9
+ export { default as ensureSymlinkSync } from './packem_shared/ensureSymlinkSync-CFimFlgh.js';
10
10
  export { CRLF, EOL, LF, detect, format } from './eol.js';
11
- export { default as collect } from './packem_shared/collect-DcBwsYYd.js';
12
- export { default as collectSync } from './packem_shared/collectSync-Bkjf9Dbm.js';
13
- export { default as findUp } from './packem_shared/findUp-BSnyGqer.js';
14
- export { default as findUpSync } from './packem_shared/findUpSync-jRHbSCMV.js';
15
- export { default as walk } from './packem_shared/walk-BhTbpr3y.js';
16
- export { default as walkSync } from './packem_shared/walkSync-DDBq95s8.js';
11
+ export { default as collect } from './packem_shared/collect-BnUYRrRI.js';
12
+ export { default as collectSync } from './packem_shared/collectSync-D5G2RGDI.js';
13
+ export { default as findUp } from './packem_shared/findUp-YcNLKdfV.js';
14
+ export { default as findUpSync } from './packem_shared/findUpSync-BfA5fheN.js';
15
+ export { default as walk } from './packem_shared/walk-D5yHruvk.js';
16
+ export { default as walkSync } from './packem_shared/walkSync-09nKPVw4.js';
17
17
  export { default as isAccessible } from './packem_shared/isAccessible-DuVrTNFV.js';
18
18
  export { default as isAccessibleSync } from './packem_shared/isAccessibleSync-DI8mM0fA.js';
19
19
  export { move, moveSync, rename, renameSync } from './packem_shared/move-DbpW5_vA.js';
20
20
  export { default as readFile } from './packem_shared/readFile-Iz7kvCCk.js';
21
- export { default as readFileSync } from './packem_shared/readFileSync-6GEIrOnl.js';
22
- export { default as readJson } from './packem_shared/readJson-CJF1t7xB.js';
23
- export { default as readJsonSync } from './packem_shared/readJsonSync-ciofT7AF.js';
24
- export { default as emptyDir } from './packem_shared/emptyDir-CYB5Tict.js';
21
+ export { default as readFileSync } from './packem_shared/readFileSync-gm9yfIhh.js';
22
+ export { default as readJson } from './packem_shared/readJson-D0G0ndHL.js';
23
+ export { default as readJsonSync } from './packem_shared/readJsonSync-B7oicPaL.js';
24
+ export { default as emptyDir } from './packem_shared/emptyDir-Df4Tfjtk.js';
25
25
  export { default as emptyDirSync } from './packem_shared/emptyDirSync-BD8-1Ytl.js';
26
- export { default as remove } from './packem_shared/remove-_oDY3uKo.js';
27
- export { default as removeSync } from './packem_shared/removeSync-DETRj7Qn.js';
28
- export { sanitize } from './packem_shared/sanitize-lOzE6k2A.js';
29
- export { default as writeFile } from './packem_shared/writeFile-DSHERs0Z.js';
30
- export { default as writeFileSync } from './packem_shared/writeFileSync-CJp1kXQR.js';
31
- export { default as writeJson } from './packem_shared/writeJson-C0OfLDbe.js';
32
- export { default as writeJsonSync } from './packem_shared/writeJsonSync-Cs21FE7v.js';
26
+ export { default as remove } from './packem_shared/remove-CNkjFFkQ.js';
27
+ export { default as removeSync } from './packem_shared/removeSync-AnawYpPv.js';
28
+ export { sanitize } from './packem_shared/sanitize-BZoLN9Fg.js';
29
+ export { default as writeFile } from './packem_shared/writeFile-B8HX0JIQ.js';
30
+ export { default as writeFileSync } from './packem_shared/writeFileSync-DB8vv8xR.js';
31
+ export { default as writeJson } from './packem_shared/writeJson-Bo7C2UHw.js';
32
+ export { default as writeJsonSync } from './packem_shared/writeJsonSync-BKZ_9Acr.js';
33
33
  export { isFsCaseSensitive } from './packem_shared/isFsCaseSensitive-D-ayleCy.js';
@@ -7,7 +7,7 @@ class WalkError extends Error {
7
7
  * @param root The root directory path where the walk operation started or encountered the error.
8
8
  */
9
9
  constructor(cause, root) {
10
- super(`${cause instanceof Error ? cause.message : cause} for path "${root}"`);
10
+ super(`${cause instanceof Error ? cause.message : String(cause)} for path "${root}"`);
11
11
  this.cause = cause;
12
12
  this.root = root;
13
13
  }
@@ -1,4 +1,4 @@
1
- import walk from './walk-BhTbpr3y.js';
1
+ import walk from './walk-D5yHruvk.js';
2
2
 
3
3
  const collect = async (directory, options = {}) => {
4
4
  if (!Array.isArray(options.extensions)) {
@@ -1,4 +1,4 @@
1
- import walkSync from './walkSync-DDBq95s8.js';
1
+ import walkSync from './walkSync-09nKPVw4.js';
2
2
 
3
3
  const collectSync = (directory, options = {}) => {
4
4
  if (!Array.isArray(options.extensions)) {
@@ -35,7 +35,8 @@ const emptyDir = async (dir, options) => {
35
35
  await mkdir(dir, { recursive: true });
36
36
  return;
37
37
  }
38
- for await (const item of await readdir(dir)) {
38
+ const items = await readdir(dir);
39
+ for (const item of items) {
39
40
  await rm(join(toPath(dir), item), { ...options, force: true, recursive: true });
40
41
  }
41
42
  };
@@ -29,7 +29,7 @@ const ensureDir = async (directory) => {
29
29
  try {
30
30
  const fileInfo = await lstat(directory);
31
31
  if (!fileInfo.isDirectory()) {
32
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
32
+ throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`);
33
33
  }
34
34
  return;
35
35
  } catch (error) {
@@ -45,7 +45,7 @@ const ensureDir = async (directory) => {
45
45
  }
46
46
  const fileInfo = await lstat(directory);
47
47
  if (!fileInfo.isDirectory()) {
48
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
48
+ throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`, { cause: error });
49
49
  }
50
50
  }
51
51
  };
@@ -29,7 +29,7 @@ const ensureDirSync = (directory) => {
29
29
  try {
30
30
  const fileInfo = lstatSync(directory);
31
31
  if (!fileInfo.isDirectory()) {
32
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
32
+ throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`);
33
33
  }
34
34
  return;
35
35
  } catch (error) {
@@ -45,7 +45,7 @@ const ensureDirSync = (directory) => {
45
45
  }
46
46
  const fileInfo = lstatSync(directory);
47
47
  if (!fileInfo.isDirectory()) {
48
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
48
+ throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`, { cause: error });
49
49
  }
50
50
  }
51
51
  };
@@ -24,7 +24,7 @@ const {
24
24
  import { dirname } from '@visulima/path';
25
25
  import { toPath } from '@visulima/path/utils';
26
26
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
27
- import ensureDir from './ensureDir-C_kuQ5Ik.js';
27
+ import ensureDir from './ensureDir-DNlPftys.js';
28
28
  import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
29
29
 
30
30
  const ensureFile = async (filePath) => {
@@ -32,7 +32,7 @@ const ensureFile = async (filePath) => {
32
32
  try {
33
33
  const stat = await lstat(filePath);
34
34
  if (!stat.isFile()) {
35
- throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
35
+ throw new Error(`Ensure path exists, expected 'file', got '${String(getFileInfoType(stat))}'`);
36
36
  }
37
37
  } catch (error) {
38
38
  if (error.code === "ENOENT") {
@@ -24,7 +24,7 @@ const {
24
24
  import { dirname } from '@visulima/path';
25
25
  import { toPath } from '@visulima/path/utils';
26
26
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
27
- import ensureDirSync from './ensureDirSync-CI5g-uBI.js';
27
+ import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
28
28
  import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
29
29
 
30
30
  const ensureFileSync = (filePath) => {
@@ -32,7 +32,7 @@ const ensureFileSync = (filePath) => {
32
32
  try {
33
33
  const stat = lstatSync(filePath);
34
34
  if (!stat.isFile()) {
35
- throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
35
+ throw new Error(`Ensure path exists, expected 'file', got '${String(getFileInfoType(stat))}'`);
36
36
  }
37
37
  } catch (error) {
38
38
  if (error.code === "ENOENT") {
@@ -24,7 +24,7 @@ const {
24
24
  import { toNamespacedPath, dirname } from '@visulima/path';
25
25
  import { toPath } from '@visulima/path/utils';
26
26
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
27
- import ensureDir from './ensureDir-C_kuQ5Ik.js';
27
+ import ensureDir from './ensureDir-DNlPftys.js';
28
28
  import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
29
29
 
30
30
  const ensureLink = async (source, destination) => {
@@ -41,8 +41,9 @@ const ensureLink = async (source, destination) => {
41
41
  try {
42
42
  sourceStat = await lstat(source);
43
43
  } catch (error) {
44
- error.message = error.message.replace("lstat", "ensureLink");
45
- throw error;
44
+ const nodeError = error;
45
+ nodeError.message = nodeError.message.replace("lstat", "ensureLink");
46
+ throw nodeError;
46
47
  }
47
48
  if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
48
49
  return;
@@ -24,7 +24,7 @@ const {
24
24
  import { toNamespacedPath, dirname } from '@visulima/path';
25
25
  import { toPath } from '@visulima/path/utils';
26
26
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
27
- import ensureDirSync from './ensureDirSync-CI5g-uBI.js';
27
+ import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
28
28
  import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
29
29
 
30
30
  const ensureLinkSync = (source, destination) => {
@@ -41,8 +41,9 @@ const ensureLinkSync = (source, destination) => {
41
41
  try {
42
42
  sourceStat = lstatSync(source);
43
43
  } catch (error) {
44
- error.message = error.message.replace("lstat", "ensureLink");
45
- throw error;
44
+ const nodeError = error;
45
+ nodeError.message = nodeError.message.replace("lstat", "ensureLink");
46
+ throw nodeError;
46
47
  }
47
48
  if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
48
49
  return;
@@ -26,7 +26,7 @@ const {
26
26
  import { toNamespacedPath, dirname, resolve } from '@visulima/path';
27
27
  import { toPath } from '@visulima/path/utils';
28
28
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
- import ensureDir from './ensureDir-C_kuQ5Ik.js';
29
+ import ensureDir from './ensureDir-DNlPftys.js';
30
30
  import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
31
31
  import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
32
32
  import { r as resolveSymlinkTarget } from './resolve-symlink-target-Kh4GovFf.js';
@@ -51,7 +51,14 @@ const ensureSymlink = async (target, linkName, type) => {
51
51
  const sourceStatInfo = await lstat(targetRealPath);
52
52
  const sourceFilePathType = getFileInfoType(sourceStatInfo);
53
53
  await ensureDir(dirname(linkName));
54
- const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
54
+ let symlinkType = type ?? "file";
55
+ if (!type) {
56
+ if (isWindows) {
57
+ symlinkType = "junction";
58
+ } else {
59
+ symlinkType = sourceFilePathType === "dir" ? "dir" : "file";
60
+ }
61
+ }
55
62
  try {
56
63
  await symlink(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
57
64
  } catch (error) {
@@ -60,7 +67,7 @@ const ensureSymlink = async (target, linkName, type) => {
60
67
  }
61
68
  const linkStatInfo = await lstat(linkName);
62
69
  if (!linkStatInfo.isSymbolicLink()) {
63
- throw new AlreadyExistsError(`A ${getFileInfoType(linkStatInfo)} already exists at the path: ${linkName}`);
70
+ throw new AlreadyExistsError(`A ${String(getFileInfoType(linkStatInfo))} already exists at the path: ${linkName}`);
64
71
  }
65
72
  const linkPath = await readlink(linkName);
66
73
  const linkRealPath = toNamespacedPath(resolve(linkPath));
@@ -26,7 +26,7 @@ const {
26
26
  import { toNamespacedPath, dirname, resolve } from '@visulima/path';
27
27
  import { toPath } from '@visulima/path/utils';
28
28
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
- import ensureDirSync from './ensureDirSync-CI5g-uBI.js';
29
+ import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
30
30
  import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
31
31
  import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
32
32
  import { r as resolveSymlinkTarget } from './resolve-symlink-target-Kh4GovFf.js';
@@ -52,7 +52,14 @@ const ensureSymlinkSync = (target, linkName, type) => {
52
52
  const sourceStatInfo = lstatSync(targetRealPath);
53
53
  const sourceFilePathType = getFileInfoType(sourceStatInfo);
54
54
  ensureDirSync(dirname(linkName));
55
- const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
55
+ let symlinkType = type ?? "file";
56
+ if (!type) {
57
+ if (isWindows) {
58
+ symlinkType = "junction";
59
+ } else {
60
+ symlinkType = sourceFilePathType === "dir" ? "dir" : "file";
61
+ }
62
+ }
56
63
  try {
57
64
  symlinkSync(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
58
65
  } catch (error) {
@@ -61,7 +68,7 @@ const ensureSymlinkSync = (target, linkName, type) => {
61
68
  }
62
69
  const linkStatInfo = lstatSync(linkName);
63
70
  if (!linkStatInfo.isSymbolicLink()) {
64
- throw new AlreadyExistsError(`A ${getFileInfoType(linkStatInfo)} already exists at the path: ${linkName}`);
71
+ throw new AlreadyExistsError(`A ${String(getFileInfoType(linkStatInfo))} already exists at the path: ${linkName}`);
65
72
  }
66
73
  const linkPath = readlinkSync(linkName);
67
74
  const linkRealPath = toNamespacedPath(resolve(linkPath));
@@ -51,12 +51,11 @@ const findUp = async (name, options = {}) => {
51
51
  }
52
52
  return [name];
53
53
  };
54
- if (options.allowSymlinks === void 0) {
55
- options.allowSymlinks = true;
56
- }
54
+ options.allowSymlinks ??= true;
57
55
  const statFunction = options.allowSymlinks ? stat : lstat;
58
56
  while (directory && directory !== stopAt && directory !== root) {
59
- for await (let fileName of await getMatchers(directory)) {
57
+ const matchers = await getMatchers(directory);
58
+ for (let fileName of matchers) {
60
59
  if (fileName === FIND_UP_STOP) {
61
60
  return void 0;
62
61
  }
@@ -51,9 +51,7 @@ const findUpSync = (name, options = {}) => {
51
51
  }
52
52
  return [name];
53
53
  };
54
- if (options.allowSymlinks === void 0) {
55
- options.allowSymlinks = true;
56
- }
54
+ options.allowSymlinks ??= true;
57
55
  const statFunction = options.allowSymlinks ? statSync : lstatSync;
58
56
  while (directory && directory !== stopAt && directory !== root) {
59
57
  for (let fileName of getMatchers(directory)) {
@@ -1,11 +1,11 @@
1
1
  import JSONError from './JSONError-BkHRnInH.js';
2
2
 
3
3
  const normalizeLF = (code) => code.replaceAll(/\r\n|\r(?!\n)|\n/gu, "\n");
4
- const _process = globalThis.process || /* @__PURE__ */ Object.create(null);
4
+ const rawProcess = globalThis.process ?? /* @__PURE__ */ Object.create(null);
5
5
  const processShims = {
6
6
  versions: {}
7
7
  };
8
- const process = /* @__PURE__ */ new Proxy(_process, {
8
+ const process = /* @__PURE__ */ new Proxy(rawProcess, {
9
9
  get(target, property) {
10
10
  if (property in target) {
11
11
  return target[property];
@@ -80,9 +80,9 @@ const codeFrame = (source, loc, options) => {
80
80
  ...options?.color
81
81
  }
82
82
  };
83
- const hasColumns = loc.start && typeof loc.start.column === "number";
83
+ const hasColumns = typeof loc.start.column === "number";
84
84
  let lines = normalizeLF(source).split("\n");
85
- if (typeof config?.tabWidth === "number") {
85
+ if (typeof config.tabWidth === "number") {
86
86
  lines = lines.map((ln) => ln.replaceAll(" ", " ".repeat(config.tabWidth)));
87
87
  }
88
88
  const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);
@@ -91,7 +91,7 @@ const codeFrame = (source, loc, options) => {
91
91
  let frame = lines.slice(start, end).map((line, index) => {
92
92
  const number = start + 1 + index;
93
93
  const hasMarker = markerLines[number];
94
- const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
94
+ const paddedNumber = ` ${String(number)}`.slice(-numberMaxWidth);
95
95
  const lastMarkerLine = !markerLines[number + 1];
96
96
  const gutter = ` ${paddedNumber}${config.showGutter ? " |" : ""}`;
97
97
  if (hasMarker) {
@@ -137,9 +137,10 @@ const binarySearch = (element, array) => {
137
137
  }
138
138
  return m;
139
139
  };
140
+ const LINE_BREAK_REGEX = /\n|\r(?!\n)/;
140
141
  const getLineStartIndexes = (string_) => (
141
142
  // eslint-disable-next-line unicorn/no-array-reduce
142
- string_.split(/\n|\r(?!\n)/).reduce(
143
+ string_.split(LINE_BREAK_REGEX).reduce(
143
144
  (accumulator, current) => {
144
145
  accumulator.push(accumulator.at(-1) + current.length + 1);
145
146
  return accumulator;
@@ -178,25 +179,25 @@ const generateCodeFrame = (source, location, options) => codeFrame(
178
179
  ...options
179
180
  }
180
181
  );
182
+ const JSON_POSITION_REGEX = /in JSON at position (\d+)(?: \(line (\d+) column (\d+)\))?$/;
181
183
  const getErrorLocation = (source, message) => {
182
- const match = /in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/.exec(message);
184
+ const match = JSON_POSITION_REGEX.exec(message);
183
185
  if (!match) {
184
186
  return void 0;
185
187
  }
186
- let { column, index, line } = match.groups;
187
- if (line && column) {
188
- return { column: Number(column), line: Number(line) };
188
+ const [, indexString, lineString, columnString] = match;
189
+ if (lineString && columnString) {
190
+ return { column: Number(columnString), line: Number(lineString) };
189
191
  }
190
- index = Number(index);
192
+ let index = Number(indexString);
191
193
  if (index === source.length) {
192
194
  index = source.length - 1;
193
195
  }
194
196
  return indexToLineColumn(source, index);
195
197
  };
198
+ const UNEXPECTED_TOKEN_REGEX = /(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/;
196
199
  const addCodePointToUnexpectedToken = (message) => message.replace(
197
- // The token is always quoted after Node.js 20, but we handle both cases for compatibility
198
- // eslint-disable-next-line regexp/no-potentially-useless-backreference
199
- /(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,
200
+ UNEXPECTED_TOKEN_REGEX,
200
201
  (_, _quote, token) => `"${token}"(${getCodePoint(token)})`
201
202
  );
202
203
  function parseJson(string, reviver, fileName, options) {
@@ -46,7 +46,8 @@ const readFileSync = (path, options) => {
46
46
  }
47
47
  const { buffer, compression, encoding, flag } = options ?? {};
48
48
  const content = readFileSync$1(path, flag ? { encoding, flag } : { encoding });
49
- const decompressed = decompressionMethods[compression ?? "none"](content);
49
+ const decompress = decompressionMethods[compression ?? "none"];
50
+ const decompressed = decompress(content);
50
51
  return buffer ? decompressed : decompressed.toString();
51
52
  };
52
53
 
@@ -1,5 +1,5 @@
1
1
  import { toPath } from '@visulima/path/utils';
2
- import parseJson from './parseJson-Cnex0kz2.js';
2
+ import parseJson from './parseJson-BedVi91S.js';
3
3
  import readFile from './readFile-Iz7kvCCk.js';
4
4
 
5
5
  async function readJson(path, reviver, options) {
@@ -1,6 +1,6 @@
1
1
  import { toPath } from '@visulima/path/utils';
2
- import parseJson from './parseJson-Cnex0kz2.js';
3
- import readFileSync from './readFileSync-6GEIrOnl.js';
2
+ import parseJson from './parseJson-BedVi91S.js';
3
+ import readFileSync from './readFileSync-gm9yfIhh.js';
4
4
 
5
5
  function readJsonSync(path, reviver, options) {
6
6
  if (typeof reviver === "object") {
@@ -1,5 +1,5 @@
1
1
  import { parse } from 'yaml';
2
- import readFileSync from './readFileSync-6GEIrOnl.js';
2
+ import readFileSync from './readFileSync-gm9yfIhh.js';
3
3
 
4
4
  function readYamlSync(path, reviver, options) {
5
5
  const { buffer, compression, encoding = "utf8", flag, ...parseOptions } = options ?? {};
@@ -30,7 +30,7 @@ const remove = async (path, options = {}) => {
30
30
  } catch {
31
31
  }
32
32
  try {
33
- await rm(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });
33
+ await rm(path, { force: true, maxRetries: options.maxRetries, recursive: true, retryDelay: options.retryDelay });
34
34
  } catch {
35
35
  }
36
36
  };
@@ -30,7 +30,7 @@ const removeSync = (path, options = {}) => {
30
30
  } catch {
31
31
  }
32
32
  try {
33
- rmSync(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });
33
+ rmSync(path, { force: true, maxRetries: options.maxRetries, recursive: true, retryDelay: options.retryDelay });
34
34
  } catch {
35
35
  }
36
36
  };
@@ -73,7 +73,7 @@ const cleanWindowsName = (name) => {
73
73
  const extension = name.slice(lastDotIndex);
74
74
  let cleanedBaseName = baseName;
75
75
  while (cleanedBaseName.length > 0) {
76
- const char = cleanedBaseName[cleanedBaseName.length - 1];
76
+ const char = cleanedBaseName.at(-1);
77
77
  if (char === void 0 || !TRIM_CHARS.has(char)) {
78
78
  break;
79
79
  }
@@ -86,7 +86,7 @@ const cleanWindowsName = (name) => {
86
86
  }
87
87
  let cleaned = name;
88
88
  while (cleaned.length > 0) {
89
- const char = cleaned[cleaned.length - 1];
89
+ const char = cleaned.at(-1);
90
90
  if (char === void 0 || !TRIM_CHARS.has(char)) {
91
91
  break;
92
92
  }
@@ -104,7 +104,7 @@ const isWindowsReservedName = (name) => {
104
104
  }
105
105
  let trimmed = name;
106
106
  while (trimmed.length > 0) {
107
- const char = trimmed[trimmed.length - 1];
107
+ const char = trimmed.at(-1);
108
108
  if (char === void 0 || !TRIM_CHARS.has(char)) {
109
109
  break;
110
110
  }
@@ -24,7 +24,7 @@ const {
24
24
  } = __cjs_getBuiltinModule("node:fs/promises");
25
25
  import { resolve, join, normalize, basename } from '@visulima/path';
26
26
  import { toPath } from '@visulima/path/utils';
27
- import WalkError from './WalkError-DUdQd6FT.js';
27
+ import WalkError from './WalkError-DER5A43G.js';
28
28
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
29
  import { g as globToRegExp, w as walkInclude } from './walk-include-CZco7BvN.js';
30
30
 
@@ -64,26 +64,28 @@ async function* walk(directory, {
64
64
  return;
65
65
  }
66
66
  try {
67
- for await (const entry of await readdir(directory, {
67
+ const entries = await readdir(directory, {
68
68
  withFileTypes: true
69
- })) {
69
+ });
70
+ for (const entry of entries) {
70
71
  let path = join(directory, entry.name);
71
72
  if (entry.isSymbolicLink()) {
72
73
  if (followSymlinks) {
73
74
  path = await realpath(path);
74
75
  } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
75
76
  yield {
76
- isDirectory: entry.isDirectory,
77
- isFile: entry.isFile,
78
- isSymbolicLink: entry.isSymbolicLink,
77
+ isDirectory: () => entry.isDirectory(),
78
+ isFile: () => entry.isFile(),
79
+ isSymbolicLink: () => entry.isSymbolicLink(),
79
80
  name: entry.name,
80
81
  path
81
82
  };
83
+ continue;
82
84
  } else {
83
85
  continue;
84
86
  }
85
87
  }
86
- if (entry.isSymbolicLink() || entry.isDirectory()) {
88
+ if (entry.isDirectory()) {
87
89
  yield* walk(path, {
88
90
  extensions,
89
91
  followSymlinks,
@@ -24,7 +24,7 @@ const {
24
24
  } = __cjs_getBuiltinModule("node:fs");
25
25
  import { resolve, join, normalize, basename } from '@visulima/path';
26
26
  import { toPath } from '@visulima/path/utils';
27
- import WalkError from './WalkError-DUdQd6FT.js';
27
+ import WalkError from './WalkError-DER5A43G.js';
28
28
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
29
  import { g as globToRegExp, w as walkInclude } from './walk-include-CZco7BvN.js';
30
30
 
@@ -32,9 +32,9 @@ const _createWalkEntry = (path) => {
32
32
  const normalizePath = normalize(path);
33
33
  const info = statSync(normalizePath);
34
34
  return {
35
- isDirectory: info.isDirectory,
36
- isFile: info.isFile,
37
- isSymbolicLink: info.isSymbolicLink,
35
+ isDirectory: () => info.isDirectory(),
36
+ isFile: () => info.isFile(),
37
+ isSymbolicLink: () => info.isSymbolicLink(),
38
38
  name: basename(normalizePath),
39
39
  path: normalizePath
40
40
  };
@@ -63,26 +63,28 @@ function* walkSync(directory, {
63
63
  return;
64
64
  }
65
65
  try {
66
- for (const entry of readdirSync(directory, {
66
+ const entries = readdirSync(directory, {
67
67
  withFileTypes: true
68
- })) {
68
+ });
69
+ for (const entry of entries) {
69
70
  let path = join(directory, entry.name);
70
71
  if (entry.isSymbolicLink()) {
71
72
  if (followSymlinks) {
72
73
  path = realpathSync(path);
73
74
  } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
74
75
  yield {
75
- isDirectory: entry.isDirectory,
76
- isFile: entry.isFile,
77
- isSymbolicLink: entry.isSymbolicLink,
76
+ isDirectory: () => entry.isDirectory(),
77
+ isFile: () => entry.isFile(),
78
+ isSymbolicLink: () => entry.isSymbolicLink(),
78
79
  name: entry.name,
79
80
  path: normalize(path)
80
81
  };
82
+ continue;
81
83
  } else {
82
84
  continue;
83
85
  }
84
86
  }
85
- if (entry.isSymbolicLink() || entry.isDirectory()) {
87
+ if (entry.isDirectory()) {
86
88
  yield* walkSync(path, {
87
89
  extensions,
88
90
  followSymlinks,
@@ -95,9 +97,9 @@ function* walkSync(directory, {
95
97
  });
96
98
  } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
97
99
  yield {
98
- isDirectory: entry.isDirectory,
99
- isFile: entry.isFile,
100
- isSymbolicLink: entry.isSymbolicLink,
100
+ isDirectory: () => entry.isDirectory(),
101
+ isFile: () => entry.isFile(),
102
+ isSymbolicLink: () => entry.isSymbolicLink(),
101
103
  name: entry.name,
102
104
  path: normalize(path)
103
105
  };
@@ -58,9 +58,7 @@ const writeFile = async (path, content, options) => {
58
58
  await writeFile$1(temporaryPath, toUint8Array(content), { encoding: options.encoding, flag: options.flag });
59
59
  if (pathExists && !options.overwrite) {
60
60
  stat$1 = await stat(path);
61
- if (options.chown === void 0) {
62
- options.chown = { gid: stat$1.gid, uid: stat$1.uid };
63
- }
61
+ options.chown ??= { gid: stat$1.gid, uid: stat$1.uid };
64
62
  await rename(path, `${path}.bak`);
65
63
  }
66
64
  if (options.chown) {
@@ -58,9 +58,7 @@ const writeFileSync = (path, content, options) => {
58
58
  writeFileSync$1(temporaryPath, toUint8Array(content), { encoding: options.encoding, flag: options.flag });
59
59
  if (pathExists && !options.overwrite) {
60
60
  stat = statSync(path);
61
- if (options.chown === void 0) {
62
- options.chown = { gid: stat.gid, uid: stat.uid };
63
- }
61
+ options.chown ??= { gid: stat.gid, uid: stat.uid };
64
62
  renameSync(path, `${path}.bak`);
65
63
  }
66
64
  if (options.chown) {
@@ -23,7 +23,7 @@ const {
23
23
  import { d as detectIndent } from './index-CHM-in-V.js';
24
24
  import { R_OK } from './F_OK-MldBaGxb.js';
25
25
  import isAccessible from './isAccessible-DuVrTNFV.js';
26
- import writeFile from './writeFile-DSHERs0Z.js';
26
+ import writeFile from './writeFile-B8HX0JIQ.js';
27
27
 
28
28
  const writeJson = async (path, data, options = {}) => {
29
29
  const { detectIndent: detectIndent$1, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: " ", ...options };
@@ -23,7 +23,7 @@ const {
23
23
  import { d as detectIndent } from './index-CHM-in-V.js';
24
24
  import { R_OK } from './F_OK-MldBaGxb.js';
25
25
  import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
26
- import writeFileSync from './writeFileSync-CJp1kXQR.js';
26
+ import writeFileSync from './writeFileSync-DB8vv8xR.js';
27
27
 
28
28
  const writeJsonSync = (path, data, options = {}) => {
29
29
  const { detectIndent: detectIndent$1, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: " ", ...options };
@@ -1,5 +1,5 @@
1
1
  import { stringify } from 'yaml';
2
- import writeFile from './writeFile-DSHERs0Z.js';
2
+ import writeFile from './writeFile-B8HX0JIQ.js';
3
3
 
4
4
  async function writeYaml(path, data, replacer, options) {
5
5
  let stringifyOptions;
@@ -9,10 +9,10 @@ async function writeYaml(path, data, replacer, options) {
9
9
  stringifyOptions = replacer;
10
10
  effectiveReplacer = stringifyOptions.replacer;
11
11
  space = stringifyOptions.space;
12
- } else if (typeof options === "object" && options !== null) {
12
+ } else if (typeof options === "object") {
13
13
  stringifyOptions = options;
14
14
  effectiveReplacer = replacer;
15
- space = stringifyOptions.space ?? (typeof options === "number" || typeof options === "string" ? options : void 0);
15
+ space = stringifyOptions.space;
16
16
  } else {
17
17
  effectiveReplacer = replacer;
18
18
  space = options;
@@ -1,5 +1,5 @@
1
1
  import { stringify } from 'yaml';
2
- import writeFileSync from './writeFileSync-CJp1kXQR.js';
2
+ import writeFileSync from './writeFileSync-DB8vv8xR.js';
3
3
 
4
4
  function writeYamlSync(path, data, replacer, options) {
5
5
  let stringifyOptions;
@@ -9,10 +9,10 @@ function writeYamlSync(path, data, replacer, options) {
9
9
  stringifyOptions = replacer;
10
10
  effectiveReplacer = stringifyOptions.replacer;
11
11
  space = stringifyOptions.space;
12
- } else if (typeof options === "object" && options !== null) {
12
+ } else if (typeof options === "object") {
13
13
  stringifyOptions = options;
14
14
  effectiveReplacer = replacer;
15
- space = stringifyOptions.space ?? (typeof options === "number" || typeof options === "string" ? options : void 0);
15
+ space = stringifyOptions.space;
16
16
  } else {
17
17
  effectiveReplacer = replacer;
18
18
  space = options;
@@ -1,5 +1,5 @@
1
1
  import type { ContentType, ReadFileOptions } from "../types.d.ts";
2
- type DecompressionMethod = (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => void;
2
+ type DecompressionMethod = (buffer: Buffer) => Buffer;
3
3
  declare const decompressionMethods: Record<string, DecompressionMethod>;
4
4
  /**
5
5
  * Synchronously reads the entire contents of a file.
@@ -1,5 +1,5 @@
1
1
  import type { JsonValue } from "type-fest";
2
2
  import type { JsonReviver, ReadJsonOptions } from "../types.d.ts";
3
- declare function readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;
4
- declare function readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;
3
+ declare function readJsonSync(path: URL | string, options?: ReadJsonOptions): JsonValue;
4
+ declare function readJsonSync(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): JsonValue;
5
5
  export default readJsonSync;
@@ -1,4 +1,4 @@
1
1
  import type { CompressionType, ReadYamlOptions, YamlReviver } from "../types.d.ts";
2
- declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<CompressionType>): R;
3
- declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): R;
2
+ declare function readYamlSync(path: URL | string, options?: ReadYamlOptions<CompressionType>): Record<string, unknown>;
3
+ declare function readYamlSync(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): Record<string, unknown>;
4
4
  export default readYamlSync;
package/dist/size.js CHANGED
@@ -67,7 +67,9 @@ const getCompressedStreamSizeEfficient = async (stream, createCompressor) => {
67
67
  compressor.on("data", (chunk) => {
68
68
  totalSize += chunk.length;
69
69
  });
70
- compressor.on("end", () => resolve2(totalSize));
70
+ compressor.on("end", () => {
71
+ resolve2(totalSize);
72
+ });
71
73
  compressor.on("error", reject);
72
74
  stream.on("error", reject);
73
75
  stream.pipe(compressor);
package/dist/types.d.ts CHANGED
@@ -83,11 +83,11 @@ export type ReadFileOptions<C> = {
83
83
  * The encoding to use. Default: `utf8`
84
84
  * @see https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
85
85
  */
86
- encoding?: ReadFileEncoding | undefined;
86
+ encoding?: ReadFileEncoding;
87
87
  /**
88
88
  * The flag used to open the file. Default: `r`
89
89
  */
90
- flag?: number | string | undefined;
90
+ flag?: number | string;
91
91
  };
92
92
  /**
93
93
  * Represents the content type of a read file, which can be a Buffer or a string based on options.
@@ -151,11 +151,11 @@ export type WriteFileOptions = {
151
151
  /**
152
152
  * The encoding to use. Default: `utf8`
153
153
  */
154
- encoding?: BufferEncoding | null | undefined;
154
+ encoding?: BufferEncoding | null;
155
155
  /**
156
156
  * The flag used to write the file. Default: `w`
157
157
  */
158
- flag?: string | undefined;
158
+ flag?: string;
159
159
  /**
160
160
  * The file mode (permission and sticky bits). Default: `0o666`
161
161
  */
@@ -196,7 +196,7 @@ export type WriteJsonOptions = WriteFileOptions & {
196
196
  *
197
197
  * Pass in `undefined` for no formatting.
198
198
  */
199
- indent?: number | string | undefined;
199
+ indent?: number | string;
200
200
  /**
201
201
  * Passed into `JSON.stringify`.
202
202
  */
@@ -265,13 +265,13 @@ export type RetryOptions = {
265
265
  * `true` for operations that support it (like `rm`).
266
266
  * @default 0
267
267
  */
268
- maxRetries?: number | undefined;
268
+ maxRetries?: number;
269
269
  /**
270
270
  * The amount of time in milliseconds to wait between retries.
271
271
  * This option is ignored if the `recursive` option is not `true` for operations that support it.
272
272
  * @default 100
273
273
  */
274
- retryDelay?: number | undefined;
274
+ retryDelay?: number;
275
275
  };
276
276
  /**
277
277
  * Options for reading YAML files.
@@ -294,7 +294,7 @@ export type WriteYamlOptions = CreateNodeOptions & DocumentOptions & ParseOption
294
294
  /**
295
295
  * Passed into `yaml.stringify` as the replacer argument.
296
296
  */
297
- replacer?: YamlReplacer;
297
+ replacer?: JsonReplacer;
298
298
  /**
299
299
  * Passed into `yaml.stringify` as the space argument for indentation.
300
300
  * Can be a number of spaces or a string (e.g., a tab character).
@@ -1,5 +1,5 @@
1
1
  import type { JsonValue } from "type-fest";
2
2
  import type { CodeFrameOptions, JsonReviver } from "../types.d.ts";
3
- declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
4
- declare function parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;
3
+ declare function parseJson(string: string, filename?: string, options?: CodeFrameOptions): JsonValue;
4
+ declare function parseJson(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): JsonValue;
5
5
  export default parseJson;
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default as JSONError } from './packem_shared/JSONError-BkHRnInH.js';
2
2
  export { default as assertValidFileContents } from './packem_shared/assertValidFileContents-BmcLtsGd.js';
3
3
  export { default as assertValidFileOrDirectoryPath } from './packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js';
4
- export { default as parseJson } from './packem_shared/parseJson-Cnex0kz2.js';
4
+ export { default as parseJson } from './packem_shared/parseJson-BedVi91S.js';
5
5
  export { default as stripJsonComments } from './packem_shared/stripJsonComments-vo4k0mpF.js';
6
6
  export { toPath } from '@visulima/path/utils';
@@ -1,4 +1,4 @@
1
- import type { WriteYamlOptions, YamlReplacer } from "../types.d.ts";
1
+ import type { JsonReplacer, WriteYamlOptions } from "../types.d.ts";
2
2
  declare function writeYamlSync(path: URL | string, data: any, options?: WriteYamlOptions): void;
3
- declare function writeYamlSync(path: URL | string, data: any, replacer?: YamlReplacer, options?: WriteYamlOptions | number | string): void;
3
+ declare function writeYamlSync(path: URL | string, data: any, replacer?: JsonReplacer, options?: WriteYamlOptions | number | string): void;
4
4
  export default writeYamlSync;
@@ -1,4 +1,4 @@
1
- import type { WriteYamlOptions, YamlReplacer } from "../types.d.ts";
1
+ import type { JsonReplacer, WriteYamlOptions } from "../types.d.ts";
2
2
  declare function writeYaml(path: URL | string, data: any, options?: WriteYamlOptions): Promise<void>;
3
- declare function writeYaml(path: URL | string, data: any, replacer?: YamlReplacer, options?: WriteYamlOptions | number | string): Promise<void>;
3
+ declare function writeYaml(path: URL | string, data: any, replacer?: JsonReplacer, options?: WriteYamlOptions | number | string): Promise<void>;
4
4
  export default writeYaml;
package/dist/yaml.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as readYaml } from './packem_shared/readYaml-D5q2a0e1.js';
2
- export { default as readYamlSync } from './packem_shared/readYamlSync-DMV4U-gi.js';
3
- export { default as writeYaml } from './packem_shared/writeYaml-n4xzYN9a.js';
4
- export { default as writeYamlSync } from './packem_shared/writeYamlSync-DnOEnP10.js';
2
+ export { default as readYamlSync } from './packem_shared/readYamlSync-BKX-PAfq.js';
3
+ export { default as writeYaml } from './packem_shared/writeYaml-BWCOome-.js';
4
+ export { default as writeYamlSync } from './packem_shared/writeYamlSync-DBVnXmuY.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/fs",
3
- "version": "5.0.0-alpha.6",
3
+ "version": "5.0.0-alpha.7",
4
4
  "description": "Human friendly file system utilities for Node.js",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -113,7 +113,7 @@
113
113
  "LICENSE.md"
114
114
  ],
115
115
  "dependencies": {
116
- "@visulima/path": "3.0.0-alpha.7",
116
+ "@visulima/path": "3.0.0-alpha.8",
117
117
  "type-fest": "5.5.0"
118
118
  },
119
119
  "peerDependencies": {
@@ -124,7 +124,6 @@
124
124
  "optional": true
125
125
  }
126
126
  },
127
- "optionalDependencies": {},
128
127
  "engines": {
129
128
  "node": ">=22.13 <=25.x"
130
129
  },