@visulima/fs 4.0.3 → 4.0.5

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 (177) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE.md +4 -1
  3. package/dist/constants.d.ts +42 -0
  4. package/dist/ensure/ensure-dir-sync.d.ts +14 -0
  5. package/dist/ensure/ensure-dir.d.ts +14 -0
  6. package/dist/ensure/ensure-file-sync.d.ts +15 -0
  7. package/dist/ensure/ensure-file.d.ts +27 -0
  8. package/dist/ensure/ensure-link-sync.d.ts +16 -0
  9. package/dist/ensure/ensure-link.d.ts +16 -0
  10. package/dist/ensure/ensure-symlink-sync.d.ts +23 -0
  11. package/dist/ensure/ensure-symlink.d.ts +23 -0
  12. package/dist/ensure/utils/get-file-info-type.d.ts +7 -0
  13. package/dist/ensure/utils/is-stats-identical.d.ts +3 -0
  14. package/dist/ensure/utils/resolve-symlink-target.d.ts +2 -0
  15. package/dist/eol.d.ts +35 -7
  16. package/dist/eol.js +26 -3
  17. package/dist/error/already-exists-error.d.ts +39 -0
  18. package/dist/error/directory-error.d.ts +47 -0
  19. package/dist/error/json-error.d.ts +52 -0
  20. package/dist/error/not-empty-error.d.ts +51 -0
  21. package/dist/error/not-found-error.d.ts +44 -0
  22. package/dist/error/permission-error.d.ts +45 -0
  23. package/dist/error/walk-error.d.ts +51 -0
  24. package/dist/error.d.ts +7 -50
  25. package/dist/error.js +7 -1
  26. package/dist/find/collect-sync.d.ts +31 -0
  27. package/dist/find/collect.d.ts +35 -0
  28. package/dist/find/find-up-sync.d.ts +42 -0
  29. package/dist/find/find-up.d.ts +46 -0
  30. package/dist/find/utils/glob-to-regex.d.ts +2 -0
  31. package/dist/find/utils/walk-include.d.ts +2 -0
  32. package/dist/find/walk-sync.d.ts +26 -0
  33. package/dist/find/walk.d.ts +29 -0
  34. package/dist/index.d.ts +34 -136
  35. package/dist/index.js +32 -1
  36. package/dist/is-accessible-sync.d.ts +3 -0
  37. package/dist/is-accessible.d.ts +29 -0
  38. package/dist/move/index.d.ts +70 -0
  39. package/dist/move/types.d.ts +38 -0
  40. package/dist/move/utils/internal-move-file-sync.d.ts +3 -0
  41. package/dist/move/utils/internal-move-file.d.ts +3 -0
  42. package/dist/move/utils/validate-same-directory.d.ts +2 -0
  43. package/dist/packem_shared/AlreadyExistsError-D5BGeeNR.js +27 -0
  44. package/dist/packem_shared/DirectoryError-CaUV2Pbk.js +27 -0
  45. package/dist/packem_shared/F_OK-BalxCn9n.js +8 -0
  46. package/dist/packem_shared/JSONError-BkHRnInH.js +26 -0
  47. package/dist/packem_shared/NotEmptyError-mOHWXE0m.js +27 -0
  48. package/dist/packem_shared/NotFoundError-D4llRgRs.js +27 -0
  49. package/dist/packem_shared/PermissionError-1qs0skfo.js +27 -0
  50. package/dist/packem_shared/WalkError-DUdQd6FT.js +24 -0
  51. package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +7 -0
  52. package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +7 -0
  53. package/dist/packem_shared/collect-DcBwsYYd.js +14 -0
  54. package/dist/packem_shared/collectSync-Bkjf9Dbm.js +14 -0
  55. package/dist/packem_shared/emptyDir-CYB5Tict.js +43 -0
  56. package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +41 -0
  57. package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +53 -0
  58. package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +53 -0
  59. package/dist/packem_shared/ensureFile-BUtXGlGT.js +47 -0
  60. package/dist/packem_shared/ensureFileSync-C8hASR-1.js +47 -0
  61. package/dist/packem_shared/ensureLink-BPnAG5-P.js +54 -0
  62. package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +54 -0
  63. package/dist/packem_shared/ensureSymlink-BGz6W-Wa.js +73 -0
  64. package/dist/packem_shared/ensureSymlinkSync-C5Gk8QYi.js +74 -0
  65. package/dist/packem_shared/findUp-Lv9mZCIQ.js +85 -0
  66. package/dist/packem_shared/findUpSync-BsK4Nrrq.js +85 -0
  67. package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +14 -0
  68. package/dist/packem_shared/index-CHM-in-V.js +100 -0
  69. package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +3 -0
  70. package/dist/packem_shared/isAccessible-iOp0Bou6.js +38 -0
  71. package/dist/packem_shared/isAccessibleSync-38BmiIcx.js +38 -0
  72. package/dist/packem_shared/isFsCaseSensitive-D-ayleCy.js +62 -0
  73. package/dist/packem_shared/move-BD6JbYSu.js +134 -0
  74. package/dist/packem_shared/parseJson-CqUuRguZ.js +231 -0
  75. package/dist/packem_shared/readFile-XVOjAw8r.js +65 -0
  76. package/dist/packem_shared/readFileSync-B9Zg5PSF.js +53 -0
  77. package/dist/packem_shared/readJson-Dra2m6s-.js +22 -0
  78. package/dist/packem_shared/readJsonSync-B6Dl1I_6.js +22 -0
  79. package/dist/packem_shared/readYaml-Bu1nsexB.js +10 -0
  80. package/dist/packem_shared/readYamlSync-Di88aMME.js +10 -0
  81. package/dist/packem_shared/remove-_oDY3uKo.js +38 -0
  82. package/dist/packem_shared/removeSync-DETRj7Qn.js +38 -0
  83. package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +16 -0
  84. package/dist/packem_shared/stripJsonComments-21XWVDwP.js +19 -0
  85. package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +19 -0
  86. package/dist/packem_shared/walk-BhTbpr3y.js +115 -0
  87. package/dist/packem_shared/walk-include-CZco7BvN.js +16 -0
  88. package/dist/packem_shared/walkSync-DDBq95s8.js +114 -0
  89. package/dist/packem_shared/writeFile-NT1fLEEe.js +83 -0
  90. package/dist/packem_shared/writeFileSync-Bj5UDSf0.js +83 -0
  91. package/dist/packem_shared/writeJson-DQLdAi0d.js +50 -0
  92. package/dist/packem_shared/writeJsonSync-DvTCjVUi.js +50 -0
  93. package/dist/packem_shared/writeYaml-BMY0kOPf.js +24 -0
  94. package/dist/packem_shared/writeYamlSync-DqPu8cCd.js +24 -0
  95. package/dist/read/read-file-sync.d.ts +37 -0
  96. package/dist/read/read-file.d.ts +41 -0
  97. package/dist/read/read-json-sync.d.ts +5 -0
  98. package/dist/read/read-json.d.ts +5 -0
  99. package/dist/read/read-yaml-sync.d.ts +4 -0
  100. package/dist/read/read-yaml.d.ts +4 -0
  101. package/dist/remove/empty-dir-sync.d.ts +24 -0
  102. package/dist/remove/empty-dir.d.ts +28 -0
  103. package/dist/remove/remove-sync.d.ts +28 -0
  104. package/dist/remove/remove.d.ts +32 -0
  105. package/dist/size.d.ts +245 -12
  106. package/dist/size.js +144 -1
  107. package/dist/types.d.ts +299 -0
  108. package/dist/utils/assert-valid-file-contents.d.ts +27 -0
  109. package/dist/utils/assert-valid-file-or-directory-path.d.ts +26 -0
  110. package/dist/utils/parse-json.d.ts +5 -0
  111. package/dist/utils/strip-json-comments.d.ts +44 -0
  112. package/dist/utils.d.ts +6 -19
  113. package/dist/utils.js +6 -1
  114. package/dist/write/utils/to-uint-8-array.d.ts +2 -0
  115. package/dist/write/write-file-sync.d.ts +30 -0
  116. package/dist/write/write-file.d.ts +30 -0
  117. package/dist/write/write-json-sync.d.ts +30 -0
  118. package/dist/write/write-json.d.ts +30 -0
  119. package/dist/write/write-yaml-sync.d.ts +4 -0
  120. package/dist/write/write-yaml.d.ts +4 -0
  121. package/dist/yaml.d.ts +5 -17
  122. package/dist/yaml.js +4 -1
  123. package/package.json +2 -3
  124. package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +0 -1
  125. package/dist/packem_shared/DirectoryError-ddlbUV8C.js +0 -1
  126. package/dist/packem_shared/F_OK-CAwY1qU7.js +0 -1
  127. package/dist/packem_shared/JSONError-D7h6PNWc.js +0 -4
  128. package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +0 -1
  129. package/dist/packem_shared/NotFoundError-BPiW0icm.js +0 -1
  130. package/dist/packem_shared/PermissionError-B1Emi5a9.js +0 -1
  131. package/dist/packem_shared/WalkError-BsngoIKJ.js +0 -1
  132. package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +0 -1
  133. package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +0 -1
  134. package/dist/packem_shared/collect-DO31RsLs.js +0 -1
  135. package/dist/packem_shared/collectSync-Cy7ULmjZ.js +0 -1
  136. package/dist/packem_shared/emptyDir-zBLHyPsJ.js +0 -1
  137. package/dist/packem_shared/emptyDirSync-DZ8nTo6g.js +0 -1
  138. package/dist/packem_shared/ensureDir-CwcwvbZ0.js +0 -1
  139. package/dist/packem_shared/ensureDirSync-DsFhH5oQ.js +0 -1
  140. package/dist/packem_shared/ensureFile-DwcEQVDX.js +0 -1
  141. package/dist/packem_shared/ensureFileSync-KnrH51Ox.js +0 -1
  142. package/dist/packem_shared/ensureLink-5rjQGEBb.js +0 -1
  143. package/dist/packem_shared/ensureLinkSync-CYXpscf2.js +0 -1
  144. package/dist/packem_shared/ensureSymlink-GATTbE5c.js +0 -1
  145. package/dist/packem_shared/ensureSymlinkSync-CvXgTFrl.js +0 -1
  146. package/dist/packem_shared/findUp-Di7Az07S.js +0 -1
  147. package/dist/packem_shared/findUpSync-iV97v14Q.js +0 -1
  148. package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +0 -1
  149. package/dist/packem_shared/index-CYIVJA0W.js +0 -1
  150. package/dist/packem_shared/is-stats-identical-CohsLtWy.js +0 -1
  151. package/dist/packem_shared/isAccessible-CDFxsAAo.js +0 -1
  152. package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +0 -1
  153. package/dist/packem_shared/isFsCaseSensitive-Drl8fHLV.js +0 -1
  154. package/dist/packem_shared/json-error-ZPgZIXcg.d.ts +0 -11
  155. package/dist/packem_shared/move-Bz4gSIjp.js +0 -1
  156. package/dist/packem_shared/parseJson-Cj4v3qzl.js +0 -6
  157. package/dist/packem_shared/readFile-CbxFM_zp.js +0 -1
  158. package/dist/packem_shared/readFileSync-B9iv2Sb8.js +0 -1
  159. package/dist/packem_shared/readJson-BgC3msx-.js +0 -1
  160. package/dist/packem_shared/readJsonSync-DHO1vjAG.js +0 -1
  161. package/dist/packem_shared/readYaml-D5mtfANg.js +0 -1
  162. package/dist/packem_shared/readYamlSync-D0igCVDE.js +0 -1
  163. package/dist/packem_shared/remove-BUqZUj1W.js +0 -1
  164. package/dist/packem_shared/removeSync-BbT4vmDi.js +0 -1
  165. package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +0 -1
  166. package/dist/packem_shared/stripJsonComments-DbMjL4qv.js +0 -1
  167. package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +0 -1
  168. package/dist/packem_shared/types-T308NKwz.d.ts +0 -90
  169. package/dist/packem_shared/walk-ZrZngpc4.js +0 -1
  170. package/dist/packem_shared/walk-include-DCiVAwMP.js +0 -1
  171. package/dist/packem_shared/walkSync-BQa4NKSG.js +0 -1
  172. package/dist/packem_shared/writeFile-D5OYEMHu.js +0 -1
  173. package/dist/packem_shared/writeFileSync-CO4ySqUn.js +0 -1
  174. package/dist/packem_shared/writeJson-DfmgiY_s.js +0 -4
  175. package/dist/packem_shared/writeJsonSync-Ck1pmmj_.js +0 -4
  176. package/dist/packem_shared/writeYaml-BJeyUpyY.js +0 -1
  177. package/dist/packem_shared/writeYamlSync-D87XCS7Y.js +0 -1
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration.
3
+ * @example
4
+ * ```javascript
5
+ * import { WalkError } from "@visulima/fs/error";
6
+ * import { walk } from "@visulima/fs";
7
+ * import { join } from "node:path";
8
+ *
9
+ * const processDirectory = async () => {
10
+ * const dirToWalk = join("/tmp", "non-existent-or-permission-denied-dir");
11
+ * try {
12
+ * // Forcing the scenario: walk might throw a WalkError if it encounters an issue
13
+ * // like a directory it cannot read during the walk process.
14
+ * const simulateWalkError = async (rootDir) => {
15
+ * // Let's say readdir inside walk fails for a subdirectory.
16
+ * const underlyingError = new Error("Permission denied reading subdirectory");
17
+ * throw new WalkError(underlyingError, rootDir);
18
+ * }
19
+ * // This is conceptual. In a real scenario, 'walk' itself would throw.
20
+ * // for await (const entry of walk(dirToWalk)) {
21
+ * // console.log(entry.path);
22
+ * // }
23
+ * await simulateWalkError(dirToWalk);
24
+ * } catch (error) {
25
+ * if (error instanceof WalkError) {
26
+ * console.error(`Error during directory walk of "${error.root}": ${error.message}`);
27
+ * if (error.cause) {
28
+ * console.error(`Underlying cause: ${error.cause}`);
29
+ * }
30
+ * } else {
31
+ * console.error("An unexpected error occurred:", error);
32
+ * }
33
+ * }
34
+ * };
35
+ *
36
+ * processDirectory();
37
+ * ```
38
+ */
39
+ declare class WalkError extends Error {
40
+ /** File path of the root that's being walked. */
41
+ root: string;
42
+ /**
43
+ * Constructs a new instance.
44
+ * @param cause The underlying error or reason for the walk failure.
45
+ * @param root The root directory path where the walk operation started or encountered the error.
46
+ */
47
+ constructor(cause: unknown, root: string);
48
+ get name(): string;
49
+ set name(_name: string);
50
+ }
51
+ export default WalkError;
package/dist/error.d.ts CHANGED
@@ -1,50 +1,7 @@
1
- export { J as JSONError } from './packem_shared/json-error-ZPgZIXcg.js';
2
-
3
- declare class AlreadyExistsError extends Error {
4
- constructor(message: string);
5
- get code(): string;
6
- set code(_name: string);
7
- get name(): string;
8
- set name(_name: string);
9
- }
10
-
11
- declare class DirectoryError extends Error {
12
- constructor(message: string);
13
- get code(): string;
14
- set code(_name: string);
15
- get name(): string;
16
- set name(_name: string);
17
- }
18
-
19
- declare class NotEmptyError extends Error {
20
- constructor(message: string);
21
- get code(): string;
22
- set code(_name: string);
23
- get name(): string;
24
- set name(_name: string);
25
- }
26
-
27
- declare class NotFoundError extends Error {
28
- constructor(message: string);
29
- get code(): string;
30
- set code(_name: string);
31
- get name(): string;
32
- set name(_name: string);
33
- }
34
-
35
- declare class PermissionError extends Error {
36
- constructor(message: string);
37
- get code(): string;
38
- set code(_name: string);
39
- get name(): string;
40
- set name(_name: string);
41
- }
42
-
43
- declare class WalkError extends Error {
44
- root: string;
45
- constructor(cause: unknown, root: string);
46
- get name(): string;
47
- set name(_name: string);
48
- }
49
-
50
- export { AlreadyExistsError, DirectoryError, NotEmptyError, NotFoundError, PermissionError, WalkError };
1
+ export { default as AlreadyExistsError } from "./error/already-exists-error.d.ts";
2
+ export { default as DirectoryError } from "./error/directory-error.d.ts";
3
+ export { default as JSONError } from "./error/json-error.d.ts";
4
+ export { default as NotEmptyError } from "./error/not-empty-error.d.ts";
5
+ export { default as NotFoundError } from "./error/not-found-error.d.ts";
6
+ export { default as PermissionError } from "./error/permission-error.d.ts";
7
+ export { default as WalkError } from "./error/walk-error.d.ts";
package/dist/error.js CHANGED
@@ -1 +1,7 @@
1
- import{default as t}from"./packem_shared/AlreadyExistsError-CEu6_Tjb.js";import{default as a}from"./packem_shared/DirectoryError-ddlbUV8C.js";import{default as s}from"./packem_shared/JSONError-D7h6PNWc.js";import{default as l}from"./packem_shared/NotEmptyError-DMh1o7UL.js";import{default as E}from"./packem_shared/NotFoundError-BPiW0icm.js";import{default as u}from"./packem_shared/PermissionError-B1Emi5a9.js";import{default as i}from"./packem_shared/WalkError-BsngoIKJ.js";export{t as AlreadyExistsError,a as DirectoryError,s as JSONError,l as NotEmptyError,E as NotFoundError,u as PermissionError,i as WalkError};
1
+ export { default as AlreadyExistsError } from './packem_shared/AlreadyExistsError-D5BGeeNR.js';
2
+ export { default as DirectoryError } from './packem_shared/DirectoryError-CaUV2Pbk.js';
3
+ export { default as JSONError } from './packem_shared/JSONError-BkHRnInH.js';
4
+ export { default as NotEmptyError } from './packem_shared/NotEmptyError-mOHWXE0m.js';
5
+ export { default as NotFoundError } from './packem_shared/NotFoundError-D4llRgRs.js';
6
+ export { default as PermissionError } from './packem_shared/PermissionError-1qs0skfo.js';
7
+ export { default as WalkError } from './packem_shared/WalkError-DUdQd6FT.js';
@@ -0,0 +1,31 @@
1
+ import type { WalkOptions } from "../types.d.ts";
2
+ /**
3
+ * Synchronously collects all file paths within a directory that match the specified criteria.
4
+ * By default, it searches for JavaScript and TypeScript file extensions.
5
+ * @param directory The root directory to start collecting files from.
6
+ * @param options Optional configuration to control the collection process. See {@link WalkOptions}.
7
+ * @returns An array of absolute file paths.
8
+ * @example
9
+ * ```javascript
10
+ * import { collectSync } from "@visulima/fs";
11
+ * import { join } from "node:path";
12
+ *
13
+ * // Collect all .txt and .md files in /tmp/docs, up to 2 levels deep
14
+ * const files = collectSync(join("/tmp", "docs"), {
15
+ * extensions: ["txt", "md"],
16
+ * maxDepth: 2,
17
+ * includeDirs: false, // Only collect files
18
+ * });
19
+ * console.log(files);
20
+ * // Example output: ['/tmp/docs/file1.txt', '/tmp/docs/subdir/report.md']
21
+ *
22
+ * // Collect all .js files, excluding anything in node_modules
23
+ * const jsFiles = collectSync(join("/tmp", "project"), {
24
+ * extensions: ["js"],
25
+ * skip: [/node_modules/],
26
+ * });
27
+ * console.log(jsFiles);
28
+ * ```
29
+ */
30
+ declare const collectSync: (directory: string, options?: WalkOptions) => string[];
31
+ export default collectSync;
@@ -0,0 +1,35 @@
1
+ import type { WalkOptions } from "../types.d.ts";
2
+ /**
3
+ * Asynchronously collects all file paths within a directory that match the specified criteria.
4
+ * By default, it searches for JavaScript and TypeScript file extensions.
5
+ * @param directory The root directory to start collecting files from.
6
+ * @param options Optional configuration to control the collection process. See {@link WalkOptions}.
7
+ * @returns A promise that resolves to an array of absolute file paths.
8
+ * @example
9
+ * ```javascript
10
+ * import { collect } from "@visulima/fs";
11
+ * import { join } from "node:path";
12
+ *
13
+ * const collectFiles = async () => {
14
+ * // Collect all .txt and .md files in /tmp/docs, up to 2 levels deep
15
+ * const files = await collect(join("/tmp", "docs"), {
16
+ * extensions: ["txt", "md"],
17
+ * maxDepth: 2,
18
+ * includeDirs: false, // Only collect files
19
+ * });
20
+ * console.log(files);
21
+ * // Example output: ['/tmp/docs/file1.txt', '/tmp/docs/subdir/report.md']
22
+ *
23
+ * // Collect all .js files, excluding anything in node_modules
24
+ * const jsFiles = await collect(join("/tmp", "project"), {
25
+ * extensions: ["js"],
26
+ * skip: [/node_modules/],
27
+ * });
28
+ * console.log(jsFiles);
29
+ * };
30
+ *
31
+ * collectFiles();
32
+ * ```
33
+ */
34
+ declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
35
+ export default collect;
@@ -0,0 +1,42 @@
1
+ import type { FindUpNameSync, FindUpOptions } from "../types.d.ts";
2
+ /**
3
+ * Synchronously finds a file or directory by walking up parent directories.
4
+ * @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`.
5
+ * @param options Optional configuration for the search. See {@link FindUpOptions}.
6
+ * @returns The absolute path of the first found file/directory, or `undefined` if not found.
7
+ * @example
8
+ * ```javascript
9
+ * import { findUpSync } from "@visulima/fs";
10
+ * import { join } from "node:path";
11
+ *
12
+ * // Find the closest package.json, starting from /tmp/foo/bar/baz
13
+ * const projectRoot = findUpSync("package.json", {
14
+ * cwd: join("/tmp", "foo", "bar", "baz"),
15
+ * type: "file",
16
+ * });
17
+ * console.log(projectRoot); // e.g., /tmp/foo/package.json or undefined
18
+ *
19
+ * // Find the closest .git directory or a README.md file
20
+ * const gitDirOrReadme = findUpSync([".git", "README.md"], {
21
+ * cwd: join("/tmp", "foo", "bar"),
22
+ * });
23
+ * console.log(gitDirOrReadme);
24
+ *
25
+ * // Find using a custom function, stopping at /tmp
26
+ * const customFound = findUpSync(
27
+ * (directory) => {
28
+ * if (directory === join("/tmp", "foo")) {
29
+ * return "found-it-here.txt"; // Pretend this file exists in /tmp/foo
30
+ * }
31
+ * return undefined;
32
+ * },
33
+ * {
34
+ * cwd: join("/tmp", "foo", "bar", "baz"),
35
+ * stopAt: join("/tmp"),
36
+ * }
37
+ * );
38
+ * console.log(customFound);
39
+ * ```
40
+ */
41
+ declare const findUpSync: (name: FindUpNameSync, options?: FindUpOptions) => string | undefined;
42
+ export default findUpSync;
@@ -0,0 +1,46 @@
1
+ import type { FindUpName, FindUpOptions } from "../types.d.ts";
2
+ /**
3
+ * Asynchronously finds a file or directory by walking up parent directories.
4
+ * @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`.
5
+ * @param options Optional configuration for the search. See {@link FindUpOptions}.
6
+ * @returns A promise that resolves to the absolute path of the first found file/directory, or `undefined` if not found.
7
+ * @example
8
+ * ```javascript
9
+ * import { findUp } from "@visulima/fs";
10
+ * import { join } from "node:path";
11
+ *
12
+ * const findProjectRoot = async () => {
13
+ * // Find the closest package.json, starting from /tmp/foo/bar/baz
14
+ * const projectRoot = await findUp("package.json", {
15
+ * cwd: join("/tmp", "foo", "bar", "baz"),
16
+ * type: "file",
17
+ * });
18
+ * console.log(projectRoot); // e.g., /tmp/foo/package.json or undefined
19
+ *
20
+ * // Find the closest .git directory or a README.md file
21
+ * const gitDirOrReadme = await findUp([".git", "README.md"], {
22
+ * cwd: join("/tmp", "foo", "bar"),
23
+ * });
24
+ * console.log(gitDirOrReadme);
25
+ *
26
+ * // Find using a custom function, stopping at /tmp
27
+ * const customFound = await findUp(
28
+ * (directory) => {
29
+ * if (directory === join("/tmp", "foo")) {
30
+ * return "found-it-here.txt"; // Pretend this file exists in /tmp/foo
31
+ * }
32
+ * return undefined;
33
+ * },
34
+ * {
35
+ * cwd: join("/tmp", "foo", "bar", "baz"),
36
+ * stopAt: join("/tmp"),
37
+ * }
38
+ * );
39
+ * console.log(customFound);
40
+ * };
41
+ *
42
+ * findProjectRoot();
43
+ * ```
44
+ */
45
+ declare const findUp: (name: FindUpName, options?: FindUpOptions) => Promise<string | undefined>;
46
+ export default findUp;
@@ -0,0 +1,2 @@
1
+ declare const globToRegExp: (glob: string) => RegExp;
2
+ export default globToRegExp;
@@ -0,0 +1,2 @@
1
+ declare const walkInclude: (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]) => boolean;
2
+ export default walkInclude;
@@ -0,0 +1,26 @@
1
+ import type { WalkEntry, WalkOptions } from "../types.d.ts";
2
+ /**
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 {@link walk} function.
5
+ * @param directory The root directory to start walking from.
6
+ * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
7
+ * @returns An iterable iterator yielding {@link WalkEntry} objects for each matching file or directory.
8
+ * @example
9
+ * ```javascript
10
+ * import { walkSync } from "@visulima/fs";
11
+ * import { join } from "node:path";
12
+ *
13
+ * // Walk through /tmp/my-project, looking for .ts files, max depth 2
14
+ * for (const entry of walkSync(join("/tmp", "my-project"), { extensions: ["ts"], maxDepth: 2 })) {
15
+ * console.log(`Found: ${entry.path} (Type: ${entry.isFile() ? 'file' : 'directory'})`);
16
+ * }
17
+ *
18
+ * // Walk, including only directories, and skip any node_modules folders
19
+ * for (const entry of walkSync(join("/tmp", "another-project"), { includeFiles: false, skip: [/node_modules/] })) {
20
+ * if (entry.isDirectory()) {
21
+ * console.log(`Directory: ${entry.path}`);
22
+ * }
23
+ * }
24
+ * ```
25
+ */
26
+ export default function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
@@ -0,0 +1,29 @@
1
+ import type { WalkEntry, WalkOptions } from "../types.d.ts";
2
+ /**
3
+ * Asynchronously walks the file tree rooted at `directory`, yielding each file or directory that matches the criteria specified in `options`.
4
+ * @param directory The root directory to start walking from.
5
+ * @param options Optional configuration to control the walking process. See {@link WalkOptions}.
6
+ * @returns An async iterable iterator yielding {@link WalkEntry} objects for each matching file or directory.
7
+ * @example
8
+ * ```javascript
9
+ * import { walk } from "@visulima/fs";
10
+ * import { join } from "node:path";
11
+ *
12
+ * const printEntries = async () => {
13
+ * // Walk through /tmp/my-project, looking for .ts files, max depth 2
14
+ * for await (const entry of walk(join("/tmp", "my-project"), { extensions: ["ts"], maxDepth: 2 })) {
15
+ * console.log(`Found: ${entry.path} (Type: ${entry.isFile() ? 'file' : 'directory'})`);
16
+ * }
17
+ *
18
+ * // Walk, including only directories, and skip any node_modules folders
19
+ * for await (const entry of walk(join("/tmp", "another-project"), { includeFiles: false, skip: [/node_modules/] })) {
20
+ * if (entry.isDirectory()) {
21
+ * console.log(`Directory: ${entry.path}`);
22
+ * }
23
+ * }
24
+ * };
25
+ *
26
+ * printEntries();
27
+ * ```
28
+ */
29
+ export default function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
package/dist/index.d.ts CHANGED
@@ -1,136 +1,34 @@
1
- import { W as WalkOptions, F as FindUpName, a as FindUpOptions, b as FindUpNameSync, c as WalkEntry, R as ReadFileOptions, C as ContentType, d as ReadJsonOptions, J as JsonReviver, e as RetryOptions, f as WriteFileOptions, g as WriteJsonOptions } from './packem_shared/types-T308NKwz.js';
2
- export { l as CodeFrameLocation, m as CodeFrameOptions, i as FIND_UP_STOP, h as F_OK, n as FindUpNameFnResult, o as FindUpNameSyncFnResult, p as JsonReplacer, j as R_OK, q as ReadFileEncoding, k as W_OK, X as X_OK } from './packem_shared/types-T308NKwz.js';
3
- import { symlink } from 'node:fs';
4
- export { CRLF, EOL, LF, detect, format } from './eol.js';
5
- import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
6
- import { JsonValue } from 'type-fest';
7
- import fs from 'fs';
8
- import 'yaml';
9
-
10
- declare const ensureDir: (directory: URL | string) => Promise<void>;
11
-
12
- declare const ensureDirSync: (directory: URL | string) => void;
13
-
14
- declare const ensureFile: (filePath: URL | string) => Promise<void>;
15
-
16
- declare const ensureFileSync: (filePath: URL | string) => void;
17
-
18
- declare const ensureLink: (source: URL | string, destination: URL | string) => Promise<void>;
19
-
20
- declare const ensureLinkSync: (source: URL | string, destination: URL | string) => void;
21
-
22
- declare const ensureSymlink: (target: URL | string, linkName: URL | string, type?: symlink.Type) => Promise<void>;
23
-
24
- declare const ensureSymlinkSync: (target: URL | string, linkName: URL | string, type?: symlink.Type) => void;
25
-
26
- declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
27
-
28
- declare const collectSync: (directory: string, options?: WalkOptions) => string[];
29
-
30
- declare const findUp: (name: FindUpName, options?: FindUpOptions) => Promise<string | undefined>;
31
-
32
- declare const findUpSync: (name: FindUpNameSync, options?: FindUpOptions) => string | undefined;
33
-
34
- declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
35
-
36
- declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
37
-
38
- declare function isAccessible(path: URL | string, mode?: number): Promise<boolean>;
39
-
40
- declare function isAccessibleSync(path: URL | string, mode?: number): boolean;
41
-
42
- type FilePermissions = number;
43
- type Options = {
44
- cwd?: URL | string;
45
- readonly directoryMode?: FilePermissions;
46
- readonly overwrite?: boolean;
47
- };
48
-
49
- declare const move: (sourcePath: string, destinationPath: string, options?: Options) => Promise<void>;
50
- declare const moveSync: (sourcePath: string, destinationPath: string, options?: Options) => void;
51
- declare const rename: (source: string, destination: string, options?: Options) => Promise<void>;
52
- declare const renameSync: (source: string, destination: string, options?: Options) => void;
53
-
54
- declare const decompressionMethods$1: {
55
- readonly brotli: typeof brotliDecompress;
56
- readonly gzip: typeof unzip;
57
- readonly none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => void;
58
- };
59
- declare const readFile: <O extends ReadFileOptions<keyof typeof decompressionMethods$1> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O>>;
60
-
61
- declare const decompressionMethods: {
62
- readonly brotli: typeof brotliDecompressSync;
63
- readonly gzip: typeof unzipSync;
64
- readonly none: (buffer: Buffer) => Buffer<ArrayBufferLike>;
65
- };
66
- declare const readFileSync: <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O>;
67
-
68
- declare function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;
69
- declare function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;
70
-
71
- declare function readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;
72
- declare function readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;
73
-
74
- declare const emptyDir: (dir: URL | string, options?: RetryOptions) => Promise<void>;
75
-
76
- declare const emptyDirSync: (dir: URL | string, options?: RetryOptions) => void;
77
-
78
- declare const remove: (path: URL | string, options?: RetryOptions) => Promise<void>;
79
-
80
- declare const removeSync: (path: URL | string, options?: RetryOptions) => void;
81
-
82
- declare const writeFile: (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions) => Promise<void>;
83
-
84
- declare const writeFileSync: (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions) => void;
85
-
86
- declare const writeJson: (path: URL | string, data: unknown, options?: WriteJsonOptions) => Promise<void>;
87
-
88
- declare const writeJsonSync: (path: URL | string, data: unknown, options?: WriteJsonOptions) => void;
89
-
90
- /**
91
- * Subset of Node.js fs module methods required for case-sensitivity detection.
92
- * This allows custom fs implementations to be passed for testing purposes.
93
- */
94
- type FsSubset = {
95
- existsSync: typeof fs.existsSync;
96
- writeFileSync: typeof fs.writeFileSync;
97
- unlinkSync: typeof fs.unlinkSync;
98
- };
99
- /**
100
- * Detects whether the filesystem is case-sensitive.
101
- *
102
- * Uses a fast, I/O-free primary method that checks if the specified directory
103
- * path can be accessed with inverted case. Falls back to writing a temporary
104
- * file if the primary method is inconclusive.
105
- *
106
- * Different mount points can have different case-sensitivity settings, so this
107
- * function checks the filesystem where the specified directory resides.
108
- *
109
- * @param directoryPath - The directory path to check. Defaults to
110
- * `process.cwd()`. Different mount points can have different case-sensitivity.
111
- * @param fsInstance - Custom filesystem implementation (primarily for
112
- * testing). Defaults to Node.js `fs` module.
113
- * @param useCache - Whether to cache the result per directory. Defaults to
114
- * `true`. When enabled, subsequent calls for the same directory return
115
- * instantly without re-checking.
116
- * @returns `true` if the filesystem is case-sensitive, `false` otherwise
117
- *
118
- * @example
119
- * ```ts
120
- * import { isFsCaseSensitive } from 'is-fs-case-sensitive'
121
- *
122
- * // Check current working directory's filesystem
123
- * if (isFsCaseSensitive()) {
124
- * console.log('Case-sensitive filesystem (likely Linux)')
125
- * } else {
126
- * console.log('Case-insensitive filesystem (likely macOS/Windows)')
127
- * }
128
- *
129
- * // Check specific directory
130
- * const isHomeCaseSensitive = isFsCaseSensitive('/home/user')
131
- * ```
132
- */
133
- declare const isFsCaseSensitive: (directoryPath?: string, fsInstance?: FsSubset, useCache?: boolean) => boolean;
134
-
135
- export { ContentType, FindUpName, FindUpNameSync, FindUpOptions, JsonReviver, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, collect, collectSync, emptyDir, emptyDirSync, ensureDir, ensureDirSync, ensureFile, ensureFileSync, ensureLink, ensureLinkSync, ensureSymlink, ensureSymlinkSync, findUp, findUpSync, isAccessible, isAccessibleSync, isFsCaseSensitive, move, moveSync, readFile, readFileSync, readJson, readJsonSync, remove, removeSync, rename, renameSync, walk, walkSync, writeFile, writeFileSync, writeJson, writeJsonSync };
136
- export type { Options as MoveOptions };
1
+ export { F_OK, FIND_UP_STOP, R_OK, W_OK, X_OK } from "./constants.d.ts";
2
+ export { default as ensureDir } from "./ensure/ensure-dir.d.ts";
3
+ export { default as ensureDirSync } from "./ensure/ensure-dir-sync.d.ts";
4
+ export { default as ensureFile } from "./ensure/ensure-file.d.ts";
5
+ export { default as ensureFileSync } from "./ensure/ensure-file-sync.d.ts";
6
+ export { default as ensureLink } from "./ensure/ensure-link.d.ts";
7
+ export { default as ensureLinkSync } from "./ensure/ensure-link-sync.d.ts";
8
+ export { default as ensureSymlink } from "./ensure/ensure-symlink.d.ts";
9
+ export { default as ensureSymlinkSync } from "./ensure/ensure-symlink-sync.d.ts";
10
+ export { CRLF, detect, EOL, format, LF } from "./eol.d.ts";
11
+ export { default as collect } from "./find/collect.d.ts";
12
+ export { default as collectSync } from "./find/collect-sync.d.ts";
13
+ export { default as findUp } from "./find/find-up.d.ts";
14
+ export { default as findUpSync } from "./find/find-up-sync.d.ts";
15
+ export { default as walk } from "./find/walk.d.ts";
16
+ export { default as walkSync } from "./find/walk-sync.d.ts";
17
+ export { default as isAccessible } from "./is-accessible.d.ts";
18
+ export { default as isAccessibleSync } from "./is-accessible-sync.d.ts";
19
+ export { move, moveSync, rename, renameSync } from "./move/index.d.ts";
20
+ export type { Options as MoveOptions } from "./move/types.d.ts";
21
+ export { default as readFile } from "./read/read-file.d.ts";
22
+ export { default as readFileSync } from "./read/read-file-sync.d.ts";
23
+ export { default as readJson } from "./read/read-json.d.ts";
24
+ export { default as readJsonSync } from "./read/read-json-sync.d.ts";
25
+ export { default as emptyDir } from "./remove/empty-dir.d.ts";
26
+ export { default as emptyDirSync } from "./remove/empty-dir-sync.d.ts";
27
+ export { default as remove } from "./remove/remove.d.ts";
28
+ export { default as removeSync } from "./remove/remove-sync.d.ts";
29
+ export type { CodeFrameLocation, CodeFrameOptions, ContentType, FindUpName, FindUpNameFnResult, FindUpNameSync, FindUpNameSyncFnResult, FindUpOptions, JsonReplacer, JsonReviver, ReadFileEncoding, ReadFileOptions, ReadJsonOptions, WalkEntry, WalkOptions, WriteFileOptions, WriteJsonOptions, } from "./types.d.ts";
30
+ export { default as writeFile } from "./write/write-file.d.ts";
31
+ export { default as writeFileSync } from "./write/write-file-sync.d.ts";
32
+ export { default as writeJson } from "./write/write-json.d.ts";
33
+ export { default as writeJsonSync } from "./write/write-json-sync.d.ts";
34
+ export { isFsCaseSensitive } from "is-fs-case-sensitive";
package/dist/index.js CHANGED
@@ -1 +1,32 @@
1
- import{FIND_UP_STOP as o,F_OK as t,R_OK as a,W_OK as f,X_OK as s}from"./packem_shared/F_OK-CAwY1qU7.js";import{default as m}from"./packem_shared/ensureDir-CwcwvbZ0.js";import{default as p}from"./packem_shared/ensureDirSync-DsFhH5oQ.js";import{default as d}from"./packem_shared/ensureFile-DwcEQVDX.js";import{default as i}from"./packem_shared/ensureFileSync-KnrH51Ox.js";import{default as y}from"./packem_shared/ensureLink-5rjQGEBb.js";import{default as F}from"./packem_shared/ensureLinkSync-CYXpscf2.js";import{default as w}from"./packem_shared/ensureSymlink-GATTbE5c.js";import{default as _}from"./packem_shared/ensureSymlinkSync-CvXgTFrl.js";import{CRLF as D,EOL as L,LF as J,detect as K,format as U}from"./eol.js";import{default as A}from"./packem_shared/collect-DO31RsLs.js";import{default as P}from"./packem_shared/collectSync-Cy7ULmjZ.js";import{default as E}from"./packem_shared/findUp-Di7Az07S.js";import{default as N}from"./packem_shared/findUpSync-iV97v14Q.js";import{default as W}from"./packem_shared/walk-ZrZngpc4.js";import{default as g}from"./packem_shared/walkSync-BQa4NKSG.js";import{default as j}from"./packem_shared/isAccessible-CDFxsAAo.js";import{default as z}from"./packem_shared/isAccessibleSync-5nzZWgin.js";import{move as G,moveSync as H,rename as M,renameSync as Q}from"./packem_shared/move-Bz4gSIjp.js";import{default as Y}from"./packem_shared/readFile-CbxFM_zp.js";import{default as $}from"./packem_shared/readFileSync-B9iv2Sb8.js";import{default as re}from"./packem_shared/readJson-BgC3msx-.js";import{default as te}from"./packem_shared/readJsonSync-DHO1vjAG.js";import{default as fe}from"./packem_shared/emptyDir-zBLHyPsJ.js";import{default as le}from"./packem_shared/emptyDirSync-DZ8nTo6g.js";import{default as ne}from"./packem_shared/remove-BUqZUj1W.js";import{default as ue}from"./packem_shared/removeSync-BbT4vmDi.js";import{default as xe}from"./packem_shared/writeFile-D5OYEMHu.js";import{default as ce}from"./packem_shared/writeFileSync-CO4ySqUn.js";import{default as Se}from"./packem_shared/writeJson-DfmgiY_s.js";import{default as ke}from"./packem_shared/writeJsonSync-Ck1pmmj_.js";import{isFsCaseSensitive as Oe}from"./packem_shared/isFsCaseSensitive-Drl8fHLV.js";export{D as CRLF,L as EOL,o as FIND_UP_STOP,t as F_OK,J as LF,a as R_OK,f as W_OK,s as X_OK,A as collect,P as collectSync,K as detect,fe as emptyDir,le as emptyDirSync,m as ensureDir,p as ensureDirSync,d as ensureFile,i as ensureFileSync,y as ensureLink,F as ensureLinkSync,w as ensureSymlink,_ as ensureSymlinkSync,E as findUp,N as findUpSync,U as format,j as isAccessible,z as isAccessibleSync,Oe as isFsCaseSensitive,G as move,H as moveSync,Y as readFile,$ as readFileSync,re as readJson,te as readJsonSync,ne as remove,ue as removeSync,M as rename,Q as renameSync,W as walk,g as walkSync,xe as writeFile,ce as writeFileSync,Se as writeJson,ke as writeJsonSync};
1
+ export { FIND_UP_STOP, F_OK, R_OK, W_OK, X_OK } from './packem_shared/F_OK-BalxCn9n.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-BGz6W-Wa.js';
9
+ export { default as ensureSymlinkSync } from './packem_shared/ensureSymlinkSync-C5Gk8QYi.js';
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-Lv9mZCIQ.js';
14
+ export { default as findUpSync } from './packem_shared/findUpSync-BsK4Nrrq.js';
15
+ export { default as walk } from './packem_shared/walk-BhTbpr3y.js';
16
+ export { default as walkSync } from './packem_shared/walkSync-DDBq95s8.js';
17
+ export { default as isAccessible } from './packem_shared/isAccessible-iOp0Bou6.js';
18
+ export { default as isAccessibleSync } from './packem_shared/isAccessibleSync-38BmiIcx.js';
19
+ export { move, moveSync, rename, renameSync } from './packem_shared/move-BD6JbYSu.js';
20
+ export { default as readFile } from './packem_shared/readFile-XVOjAw8r.js';
21
+ export { default as readFileSync } from './packem_shared/readFileSync-B9Zg5PSF.js';
22
+ export { default as readJson } from './packem_shared/readJson-Dra2m6s-.js';
23
+ export { default as readJsonSync } from './packem_shared/readJsonSync-B6Dl1I_6.js';
24
+ export { default as emptyDir } from './packem_shared/emptyDir-CYB5Tict.js';
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 { default as writeFile } from './packem_shared/writeFile-NT1fLEEe.js';
29
+ export { default as writeFileSync } from './packem_shared/writeFileSync-Bj5UDSf0.js';
30
+ export { default as writeJson } from './packem_shared/writeJson-DQLdAi0d.js';
31
+ export { default as writeJsonSync } from './packem_shared/writeJsonSync-DvTCjVUi.js';
32
+ export { isFsCaseSensitive } from './packem_shared/isFsCaseSensitive-D-ayleCy.js';
@@ -0,0 +1,3 @@
1
+ /** Returns a boolean indicating if the path is accessible or not. */
2
+ declare function isAccessibleSync(path: URL | string, mode?: number): boolean;
3
+ export default isAccessibleSync;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Asynchronously tests a user's permissions for the file or directory specified by path.
3
+ * Returns a Promise that resolves to `true` if the accessibility check is successful, `false` otherwise.
4
+ * @param path The path to the file or directory. Can be a string or a URL object.
5
+ * @param mode The accessibility checks to perform. Defaults to `F_OK` (check for existence).
6
+ * Other possible values include `R_OK` (check for read access), `W_OK` (check for write access),
7
+ * and `X_OK` (check for execute/search access). Multiple modes can be combined using bitwise OR.
8
+ * @returns A Promise that resolves to a boolean indicating if the path is accessible with the specified mode.
9
+ * @example
10
+ * ```typescript
11
+ * import { isAccessible, F_OK, R_OK } from "@visulima/fs";
12
+ *
13
+ * (async () => {
14
+ * if (await isAccessible("myFile.txt")) {
15
+ * console.log("myFile.txt exists");
16
+ * }
17
+ *
18
+ * if (await isAccessible("myFile.txt", R_OK)) {
19
+ * console.log("myFile.txt is readable");
20
+ * }
21
+ *
22
+ * if (await isAccessible("myDirectory", F_OK | R_OK | W_OK)) {
23
+ * console.log("myDirectory exists, is readable and writable");
24
+ * }
25
+ * })();
26
+ * ```
27
+ */
28
+ declare function isAccessible(path: URL | string, mode?: number): Promise<boolean>;
29
+ export default isAccessible;