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

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 (125) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE.md +155 -126
  3. package/dist/eol.d.ts +6 -35
  4. package/dist/error.d.ts +43 -7
  5. package/dist/glob-parent.d.ts +5 -0
  6. package/dist/glob-parent.js +90 -0
  7. package/dist/glob.d.ts +5 -0
  8. package/dist/glob.js +2 -0
  9. package/dist/index.d.ts +81 -36
  10. package/dist/index.js +16 -11
  11. package/dist/ini.d.ts +10 -0
  12. package/dist/ini.js +4 -0
  13. package/dist/is-glob.d.ts +5 -0
  14. package/dist/is-glob.js +9 -0
  15. package/dist/json5.d.ts +12 -0
  16. package/dist/json5.js +4 -0
  17. package/dist/jsonc.d.ts +10 -0
  18. package/dist/jsonc.js +4 -0
  19. package/dist/match.d.ts +5 -0
  20. package/dist/match.js +15 -0
  21. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
  22. package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +12 -0
  23. package/dist/packem_shared/{collect-BnUYRrRI.js → collect-CqQ3eVab.js} +1 -1
  24. package/dist/packem_shared/{collectSync-D5G2RGDI.js → collectSync-noE08NNv.js} +1 -1
  25. package/dist/packem_shared/{emptyDir-Df4Tfjtk.js → emptyDir-DnwENOaV.js} +3 -1
  26. package/dist/packem_shared/{emptyDirSync-BD8-1Ytl.js → emptyDirSync-6WiHBo8a.js} +3 -1
  27. package/dist/packem_shared/glob-DY8l7izD.js +5 -0
  28. package/dist/packem_shared/glob-sync.d-B83kqwUd.d.ts +4 -0
  29. package/dist/packem_shared/globSync-5P2KJf_g.js +5 -0
  30. package/dist/packem_shared/index-C8W8sfzP.js +830 -0
  31. package/dist/packem_shared/index-bhgnhm4u.js +167 -0
  32. package/dist/packem_shared/index-xe4o3cYi.js +1784 -0
  33. package/dist/packem_shared/{parseJson-BedVi91S.js → indexToLineColumn-BUb0GPKl-BF770uX7.js} +1 -62
  34. package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +251 -0
  35. package/dist/packem_shared/{isFsCaseSensitive-D-ayleCy.js → isFsCaseSensitive-DunL7Iry.js} +6 -6
  36. package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +10 -0
  37. package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +72 -0
  38. package/dist/packem_shared/parseJson-BIp89Xjo.js +63 -0
  39. package/dist/packem_shared/readIni-CJ2xfpjB.js +10 -0
  40. package/dist/packem_shared/readIniSync-9LUjaSSp.js +10 -0
  41. package/dist/packem_shared/{readJson-D0G0ndHL.js → readJson-C_rwm-wq.js} +1 -1
  42. package/dist/packem_shared/readJson5-mBoTZppy.js +15 -0
  43. package/dist/packem_shared/readJson5Sync-8WS2yUok.js +15 -0
  44. package/dist/packem_shared/{readJsonSync-B7oicPaL.js → readJsonSync-BMEmCcJ6.js} +1 -1
  45. package/dist/packem_shared/readJsonc-j-OS-APg.js +28 -0
  46. package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +16 -0
  47. package/dist/packem_shared/readToml-B2MHaSes.js +9 -0
  48. package/dist/packem_shared/readTomlSync-DNbK8NEb.js +9 -0
  49. package/dist/packem_shared/{remove-CNkjFFkQ.js → remove-C8_gl3jF.js} +2 -1
  50. package/dist/packem_shared/{removeSync-AnawYpPv.js → removeSync-BJR_wTwN.js} +2 -1
  51. package/dist/packem_shared/types.d-dP-lAGNn.d.ts +145 -0
  52. package/dist/packem_shared/{walk-D5yHruvk.js → walk-CSZgCuDx.js} +10 -3
  53. package/dist/packem_shared/{walkSync-09nKPVw4.js → walkSync-C4Cy28xb.js} +10 -3
  54. package/dist/packem_shared/writeIni-i55QrL8y.js +65 -0
  55. package/dist/packem_shared/writeIniSync-CLqJE5t3.js +64 -0
  56. package/dist/packem_shared/writeJson5-vVmHUQOd.js +53 -0
  57. package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +53 -0
  58. package/dist/packem_shared/writeJsonc-BufH_oC5.js +60 -0
  59. package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +59 -0
  60. package/dist/packem_shared/writeToml-DgTW_-7F.js +8 -0
  61. package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +8 -0
  62. package/dist/size.d.ts +10 -254
  63. package/dist/toml.d.ts +9 -0
  64. package/dist/toml.js +4 -0
  65. package/dist/utils.d.ts +15 -6
  66. package/dist/utils.js +1 -1
  67. package/dist/yaml.d.ts +14 -5
  68. package/package.json +58 -4
  69. package/dist/constants.d.ts +0 -42
  70. package/dist/ensure/ensure-dir-sync.d.ts +0 -14
  71. package/dist/ensure/ensure-dir.d.ts +0 -14
  72. package/dist/ensure/ensure-file-sync.d.ts +0 -15
  73. package/dist/ensure/ensure-file.d.ts +0 -27
  74. package/dist/ensure/ensure-link-sync.d.ts +0 -16
  75. package/dist/ensure/ensure-link.d.ts +0 -16
  76. package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
  77. package/dist/ensure/ensure-symlink.d.ts +0 -23
  78. package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
  79. package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
  80. package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
  81. package/dist/error/already-exists-error.d.ts +0 -39
  82. package/dist/error/directory-error.d.ts +0 -47
  83. package/dist/error/json-error.d.ts +0 -52
  84. package/dist/error/not-empty-error.d.ts +0 -51
  85. package/dist/error/not-found-error.d.ts +0 -44
  86. package/dist/error/permission-error.d.ts +0 -45
  87. package/dist/error/walk-error.d.ts +0 -51
  88. package/dist/find/collect-sync.d.ts +0 -31
  89. package/dist/find/collect.d.ts +0 -35
  90. package/dist/find/find-up-sync.d.ts +0 -42
  91. package/dist/find/find-up.d.ts +0 -46
  92. package/dist/find/utils/glob-to-regexp.d.ts +0 -2
  93. package/dist/find/utils/walk-include.d.ts +0 -2
  94. package/dist/find/walk-sync.d.ts +0 -34
  95. package/dist/find/walk.d.ts +0 -37
  96. package/dist/is-accessible-sync.d.ts +0 -3
  97. package/dist/is-accessible.d.ts +0 -29
  98. package/dist/move/index.d.ts +0 -68
  99. package/dist/move/types.d.ts +0 -36
  100. package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
  101. package/dist/move/utils/internal-move-file.d.ts +0 -3
  102. package/dist/move/utils/validate-same-directory.d.ts +0 -2
  103. package/dist/read/read-file-sync.d.ts +0 -37
  104. package/dist/read/read-file.d.ts +0 -41
  105. package/dist/read/read-json-sync.d.ts +0 -5
  106. package/dist/read/read-json.d.ts +0 -5
  107. package/dist/read/read-yaml-sync.d.ts +0 -4
  108. package/dist/read/read-yaml.d.ts +0 -4
  109. package/dist/remove/empty-dir-sync.d.ts +0 -23
  110. package/dist/remove/empty-dir.d.ts +0 -28
  111. package/dist/remove/remove-sync.d.ts +0 -27
  112. package/dist/remove/remove.d.ts +0 -32
  113. package/dist/sanitize.d.ts +0 -31
  114. package/dist/types.d.ts +0 -304
  115. package/dist/utils/assert-valid-file-contents.d.ts +0 -27
  116. package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
  117. package/dist/utils/parse-json.d.ts +0 -5
  118. package/dist/utils/strip-json-comments.d.ts +0 -44
  119. package/dist/write/utils/to-uint-8-array.d.ts +0 -2
  120. package/dist/write/write-file-sync.d.ts +0 -30
  121. package/dist/write/write-file.d.ts +0 -30
  122. package/dist/write/write-json-sync.d.ts +0 -29
  123. package/dist/write/write-json.d.ts +0 -30
  124. package/dist/write/write-yaml-sync.d.ts +0 -4
  125. package/dist/write/write-yaml.d.ts +0 -4
package/dist/size.d.ts CHANGED
@@ -1,256 +1,12 @@
1
- import { Readable } from "node:stream";
2
- import { URL } from "node:url";
3
- import type { BrotliOptions, ZlibOptions } from "node:zlib";
4
- /**
5
- * Input type for size calculation functions.
6
- * Can be a Buffer, Readable stream, URL object, or string (file path or content).
7
- */
1
+ import { Readable } from 'node:stream';
2
+ import { URL } from 'node:url';
3
+ import { BrotliOptions, ZlibOptions } from 'node:zlib';
8
4
  type SizeInput = Buffer | Readable | URL | string;
9
- /**
10
- * Input type for synchronous size calculation functions.
11
- * Can be a Buffer, URL object, or string (file path or content).
12
- */
13
5
  type SizeInputSync = Buffer | URL | string;
14
- /**
15
- * Asynchronously calculates the gzipped size of the given input.
16
- * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
17
- * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
18
- * @param input The input data to gzip and measure.
19
- * @param [options] Optional Zlib options for gzip compression.
20
- * @returns A promise that resolves with the gzipped size in bytes.
21
- * @example
22
- * ```javascript
23
- * import { gzipSize } from "@visulima/fs";
24
- * import { Readable } from "node:stream";
25
- * import { writeFile, unlink } from "node:fs/promises";
26
- * import { join } from "node:path";
27
- *
28
- * const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
29
- * const filePath = join("temp-file.txt");
30
- *
31
- * async function main() {
32
- * // From Buffer
33
- * const buffer = Buffer.from(text);
34
- * console.log(`Gzip size of buffer: ${await gzipSize(buffer)} bytes`);
35
- *
36
- * // From string (content)
37
- * console.log(`Gzip size of string content: ${await gzipSize(text)} bytes`);
38
- *
39
- * // From file path
40
- * await writeFile(filePath, text);
41
- * console.log(`Gzip size of file: ${await gzipSize(filePath)} bytes`);
42
- *
43
- * // From URL
44
- * const fileUrl = new URL(`file://${filePath}`);
45
- * console.log(`Gzip size of URL: ${await gzipSize(fileUrl)} bytes`);
46
- *
47
- * // From Readable stream
48
- * const stream = Readable.from(text);
49
- * console.log(`Gzip size of stream: ${await gzipSize(stream)} bytes`);
50
- *
51
- * await unlink(filePath); // Clean up temp file
52
- * }
53
- *
54
- * main().catch(console.error);
55
- * ```
56
- */
57
- export declare const gzipSize: (input: SizeInput, options?: ZlibOptions) => Promise<number>;
58
- /**
59
- * Asynchronously calculates the Brotli compressed size of the given input.
60
- * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
61
- * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
62
- * @param input The input data to compress with Brotli and measure.
63
- * @param [options] Optional Zlib options for Brotli compression.
64
- * @returns A promise that resolves with the Brotli compressed size in bytes.
65
- * @example
66
- * ```javascript
67
- * import { brotliSize } from "@visulima/fs";
68
- * import { Readable } from "node:stream";
69
- * import { writeFile, unlink } from "node:fs/promises";
70
- * import { join } from "node:path";
71
- *
72
- * const text = "This is a test string for Brotli compression efficiency.";
73
- * const filePath = join("temp-brotli-file.txt");
74
- *
75
- * async function main() {
76
- * // From Buffer
77
- * const buffer = Buffer.from(text);
78
- * console.log(`Brotli size of buffer: ${await brotliSize(buffer)} bytes`);
79
- *
80
- * // From string (content)
81
- * console.log(`Brotli size of string content: ${await brotliSize(text)} bytes`);
82
- *
83
- * // From file path
84
- * await writeFile(filePath, text);
85
- * console.log(`Brotli size of file: ${await brotliSize(filePath)} bytes`);
86
- *
87
- * // From URL
88
- * const fileUrl = new URL(`file://${filePath}`);
89
- * console.log(`Brotli size of URL: ${await brotliSize(fileUrl)} bytes`);
90
- *
91
- * // From Readable stream
92
- * const stream = Readable.from(text);
93
- * console.log(`Brotli size of stream: ${await brotliSize(stream)} bytes`);
94
- *
95
- * await unlink(filePath); // Clean up temp file
96
- * }
97
- *
98
- * main().catch(console.error);
99
- * ```
100
- */
101
- export declare const brotliSize: (input: SizeInput, options?: BrotliOptions) => Promise<number>;
102
- /**
103
- * Asynchronously calculates the raw (uncompressed) size of the given input.
104
- * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
105
- * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
106
- * @param input The input data to measure.
107
- * @returns A promise that resolves with the raw size in bytes.
108
- * @example
109
- * ```javascript
110
- * import { rawSize } from "@visulima/fs";
111
- * import { Readable } from "node:stream";
112
- * import { writeFile, unlink } from "node:fs/promises";
113
- * import { join } from "node:path";
114
- *
115
- * const text = "Hello, World!";
116
- * const filePath = join("temp-raw-file.txt");
117
- *
118
- * async function main() {
119
- * // From Buffer
120
- * const buffer = Buffer.from(text);
121
- * console.log(`Raw size of buffer: ${await rawSize(buffer)} bytes`);
122
- *
123
- * // From string (content)
124
- * console.log(`Raw size of string content: ${await rawSize(text)} bytes`);
125
- *
126
- * // From file path
127
- * await writeFile(filePath, text);
128
- * console.log(`Raw size of file: ${await rawSize(filePath)} bytes`);
129
- *
130
- * // From URL
131
- * const fileUrl = new URL(`file://${filePath}`);
132
- * console.log(`Raw size of URL: ${await rawSize(fileUrl)} bytes`);
133
- *
134
- * // From Readable stream
135
- * const stream = Readable.from(text);
136
- * console.log(`Raw size of stream: ${await rawSize(stream)} bytes`);
137
- *
138
- * await unlink(filePath); // Clean up temp file
139
- * }
140
- *
141
- * main().catch(console.error);
142
- * ```
143
- */
144
- export declare const rawSize: (input: SizeInput) => Promise<number>;
145
- /**
146
- * Synchronously calculates the gzipped size of the given input.
147
- * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
148
- * Note: For Readable streams or very large files, consider using the asynchronous `gzipSize` function for better performance and to avoid blocking.
149
- * @param input The input data to gzip and measure.
150
- * @param [options] Optional Zlib options for gzip compression.
151
- * @returns The gzipped size in bytes.
152
- * @example
153
- * ```javascript
154
- * import { gzipSizeSync } from "@visulima/fs";
155
- * import { writeFileSync, unlinkSync } from "node:fs";
156
- * import { join } from "node:path";
157
- *
158
- * const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
159
- * const filePath = join("temp-sync-file.txt");
160
- *
161
- * // From Buffer
162
- * const buffer = Buffer.from(text);
163
- * console.log(`Sync Gzip size of buffer: ${gzipSizeSync(buffer)} bytes`);
164
- *
165
- * // From string (content)
166
- * console.log(`Sync Gzip size of string content: ${gzipSizeSync(text)} bytes`);
167
- *
168
- * // From file path
169
- * try {
170
- * writeFileSync(filePath, text);
171
- * console.log(`Sync Gzip size of file: ${gzipSizeSync(filePath)} bytes`);
172
- *
173
- * // From URL
174
- * const fileUrl = new URL(`file://${filePath}`);
175
- * console.log(`Sync Gzip size of URL: ${gzipSizeSync(fileUrl)} bytes`);
176
- * } finally {
177
- * try { unlinkSync(filePath); } catch {} // Clean up temp file
178
- * }
179
- * ```
180
- */
181
- export declare const gzipSizeSync: (input: SizeInputSync, options?: ZlibOptions) => number;
182
- /**
183
- * Synchronously calculates the Brotli compressed size of the given input.
184
- * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
185
- * Note: For Readable streams or very large files, consider using the asynchronous `brotliSize` function for better performance and to avoid blocking.
186
- * @param input The input data to compress with Brotli and measure.
187
- * @param [options] Optional Zlib options for Brotli compression.
188
- * @returns The Brotli compressed size in bytes.
189
- * @example
190
- * ```javascript
191
- * import { brotliSizeSync } from "@visulima/fs";
192
- * import { writeFileSync, unlinkSync } from "node:fs";
193
- * import { join } from "node:path";
194
- *
195
- * const text = "This is a test string for Brotli compression efficiency, synchronously.";
196
- * const filePath = join("temp-brotli-sync-file.txt");
197
- *
198
- * // From Buffer
199
- * const buffer = Buffer.from(text);
200
- * console.log(`Sync Brotli size of buffer: ${brotliSizeSync(buffer)} bytes`);
201
- *
202
- * // From string (content)
203
- * console.log(`Sync Brotli size of string content: ${brotliSizeSync(text)} bytes`);
204
- *
205
- * // From file path
206
- * try {
207
- * writeFileSync(filePath, text);
208
- * console.log(`Sync Brotli size of file: ${brotliSizeSync(filePath)} bytes`);
209
- *
210
- * // From URL
211
- * const fileUrl = new URL(`file://${filePath}`);
212
- * console.log(`Sync Brotli size of URL: ${brotliSizeSync(fileUrl)} bytes`);
213
- * } finally {
214
- * try { unlinkSync(filePath); } catch {} // Clean up temp file
215
- * }
216
- * ```
217
- */
218
- export declare const brotliSizeSync: (input: SizeInputSync, options?: BrotliOptions) => number;
219
- /**
220
- * Synchronously calculates the raw (uncompressed) size of the given input.
221
- * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
222
- * For file paths, it uses `statSync` to get the file size.
223
- * Note: For Readable streams or very large files, consider using the asynchronous `rawSize` function for better performance and to avoid blocking.
224
- * @param input The input data to measure.
225
- * @returns The raw size in bytes.
226
- * @example
227
- * ```javascript
228
- * import { rawSizeSync } from "@visulima/fs";
229
- * import { writeFileSync, unlinkSync } from "node:fs";
230
- * import { join } from "node:path";
231
- *
232
- * const text = "Hello, Synchronous World!";
233
- * const filePath = join("temp-raw-sync-file.txt");
234
- *
235
- * // From Buffer
236
- * const buffer = Buffer.from(text);
237
- * console.log(`Sync Raw size of buffer: ${rawSizeSync(buffer)} bytes`);
238
- *
239
- * // From string (content)
240
- * console.log(`Sync Raw size of string content: ${rawSizeSync(text)} bytes`);
241
- *
242
- * // From file path
243
- * try {
244
- * writeFileSync(filePath, text);
245
- * console.log(`Sync Raw size of file: ${rawSizeSync(filePath)} bytes`);
246
- *
247
- * // From URL
248
- * const fileUrl = new URL(`file://${filePath}`);
249
- * console.log(`Sync Raw size of URL: ${rawSizeSync(fileUrl)} bytes`);
250
- * } finally {
251
- * try { unlinkSync(filePath); } catch {} // Clean up temp file
252
- * }
253
- * ```
254
- */
255
- export declare const rawSizeSync: (input: SizeInputSync) => number;
256
- export {};
6
+ declare const gzipSize: (input: SizeInput, options?: ZlibOptions) => Promise<number>;
7
+ declare const brotliSize: (input: SizeInput, options?: BrotliOptions) => Promise<number>;
8
+ declare const rawSize: (input: SizeInput) => Promise<number>;
9
+ declare const gzipSizeSync: (input: SizeInputSync, options?: ZlibOptions) => number;
10
+ declare const brotliSizeSync: (input: SizeInputSync, options?: BrotliOptions) => number;
11
+ declare const rawSizeSync: (input: SizeInputSync) => number;
12
+ export { brotliSize, brotliSizeSync, gzipSize, gzipSizeSync, rawSize, rawSizeSync };
package/dist/toml.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { C as CompressionType, R as ReadTomlOptions, W as WriteTomlOptions } from "./packem_shared/types.d-dP-lAGNn.js";
2
+ import 'node:fs';
3
+ import 'tinyglobby';
4
+ import './options';
5
+ declare const readToml: <R = Record<string, unknown>>(path: URL | string, options?: ReadTomlOptions<CompressionType>) => Promise<R>;
6
+ declare const readTomlSync: (path: URL | string, options?: ReadTomlOptions<CompressionType>) => Record<string, unknown>;
7
+ declare const writeToml: (path: URL | string, data: Record<string, unknown>, options?: WriteTomlOptions) => Promise<void>;
8
+ declare const writeTomlSync: (path: URL | string, data: Record<string, unknown>, options?: WriteTomlOptions) => void;
9
+ export { type ReadTomlOptions, type WriteTomlOptions, readToml, readTomlSync, writeToml, writeTomlSync };
package/dist/toml.js ADDED
@@ -0,0 +1,4 @@
1
+ export { default as readToml } from './packem_shared/readToml-B2MHaSes.js';
2
+ export { default as readTomlSync } from './packem_shared/readTomlSync-DNbK8NEb.js';
3
+ export { default as writeToml } from './packem_shared/writeToml-DgTW_-7F.js';
4
+ export { default as writeTomlSync } from './packem_shared/writeTomlSync-DiBiE9ja.js';
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,15 @@
1
- export { default as JSONError } from "./error/json-error.d.ts";
2
- export { default as assertValidFileContents } from "./utils/assert-valid-file-contents.d.ts";
3
- export { default as assertValidFileOrDirectoryPath } from "./utils/assert-valid-file-or-directory-path.d.ts";
4
- export { default as parseJson } from "./utils/parse-json.d.ts";
5
- export { default as stripJsonComments } from "./utils/strip-json-comments.d.ts";
6
- export { toPath } from "@visulima/path/utils";
1
+ export { J as JSONError } from "./packem_shared/json-error.d-DgKaeuIf.js";
2
+ import { JsonValue } from 'type-fest';
3
+ import { a as CodeFrameOptions, J as JsonReviver } from "./packem_shared/types.d-dP-lAGNn.js";
4
+ export { toPath } from '@visulima/path/utils';
5
+ import 'node:fs';
6
+ import 'tinyglobby';
7
+ import './options';
8
+ declare const assertValidFileContents: (contents: any) => void;
9
+ declare const assertValidFileOrDirectoryPath: (fileOrDirectoryPath: any) => void;
10
+ declare function parseJson(string: string, filename?: string, options?: CodeFrameOptions): JsonValue;
11
+ declare function parseJson(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): JsonValue;
12
+ declare const stripJsonComments: (jsonString: string, options?: {
13
+ whitespace?: boolean;
14
+ }) => string;
15
+ export { assertValidFileContents, assertValidFileOrDirectoryPath, parseJson, stripJsonComments };
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-BedVi91S.js';
4
+ export { default as parseJson } from './packem_shared/parseJson-BIp89Xjo.js';
5
5
  export { default as stripJsonComments } from './packem_shared/stripJsonComments-vo4k0mpF.js';
6
6
  export { toPath } from '@visulima/path/utils';
package/dist/yaml.d.ts CHANGED
@@ -1,5 +1,14 @@
1
- export { default as readYaml } from "./read/read-yaml.d.ts";
2
- export { default as readYamlSync } from "./read/read-yaml-sync.d.ts";
3
- export type { YamlReplacer } from "./types.d.ts";
4
- export { default as writeYaml } from "./write/write-yaml.d.ts";
5
- export { default as writeYamlSync } from "./write/write-yaml-sync.d.ts";
1
+ import { C as CompressionType, m as ReadYamlOptions, Y as YamlReviver, n as WriteYamlOptions, o as JsonReplacer } from "./packem_shared/types.d-dP-lAGNn.js";
2
+ export { type p as YamlReplacer } from "./packem_shared/types.d-dP-lAGNn.js";
3
+ import 'node:fs';
4
+ import 'tinyglobby';
5
+ import './options';
6
+ declare function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<CompressionType>): Promise<R>;
7
+ declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): Promise<R>;
8
+ declare function readYamlSync(path: URL | string, options?: ReadYamlOptions<CompressionType>): Record<string, unknown>;
9
+ declare function readYamlSync(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): Record<string, unknown>;
10
+ declare function writeYaml(path: URL | string, data: any, options?: WriteYamlOptions): Promise<void>;
11
+ declare function writeYaml(path: URL | string, data: any, replacer?: JsonReplacer, options?: WriteYamlOptions | number | string): Promise<void>;
12
+ declare function writeYamlSync(path: URL | string, data: any, options?: WriteYamlOptions): void;
13
+ declare function writeYamlSync(path: URL | string, data: any, replacer?: JsonReplacer, options?: WriteYamlOptions | number | string): void;
14
+ export { readYaml, readYamlSync, writeYaml, writeYamlSync };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/fs",
3
- "version": "5.0.0-alpha.7",
3
+ "version": "5.0.0-alpha.9",
4
4
  "description": "Human friendly file system utilities for Node.js",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -49,6 +49,12 @@
49
49
  "write-file",
50
50
  "write-safe",
51
51
  "yaml",
52
+ "toml",
53
+ "jsonc",
54
+ "json5",
55
+ "ini",
56
+ "smol-toml",
57
+ "jsonc-parser",
52
58
  "size",
53
59
  "brotli",
54
60
  "gzip"
@@ -96,6 +102,22 @@
96
102
  "types": "./dist/yaml.d.ts",
97
103
  "default": "./dist/yaml.js"
98
104
  },
105
+ "./toml": {
106
+ "types": "./dist/toml.d.ts",
107
+ "default": "./dist/toml.js"
108
+ },
109
+ "./jsonc": {
110
+ "types": "./dist/jsonc.d.ts",
111
+ "default": "./dist/jsonc.js"
112
+ },
113
+ "./json5": {
114
+ "types": "./dist/json5.d.ts",
115
+ "default": "./dist/json5.js"
116
+ },
117
+ "./ini": {
118
+ "types": "./dist/ini.d.ts",
119
+ "default": "./dist/ini.js"
120
+ },
99
121
  "./size": {
100
122
  "types": "./dist/size.d.ts",
101
123
  "default": "./dist/size.js"
@@ -104,6 +126,22 @@
104
126
  "types": "./dist/eol.d.ts",
105
127
  "default": "./dist/eol.js"
106
128
  },
129
+ "./glob": {
130
+ "types": "./dist/glob.d.ts",
131
+ "default": "./dist/glob.js"
132
+ },
133
+ "./glob-parent": {
134
+ "types": "./dist/glob-parent.d.ts",
135
+ "default": "./dist/glob-parent.js"
136
+ },
137
+ "./is-glob": {
138
+ "types": "./dist/is-glob.d.ts",
139
+ "default": "./dist/is-glob.js"
140
+ },
141
+ "./match": {
142
+ "types": "./dist/match.d.ts",
143
+ "default": "./dist/match.js"
144
+ },
107
145
  "./package.json": "./package.json"
108
146
  },
109
147
  "files": [
@@ -113,19 +151,35 @@
113
151
  "LICENSE.md"
114
152
  ],
115
153
  "dependencies": {
116
- "@visulima/path": "3.0.0-alpha.8",
117
- "type-fest": "5.5.0"
154
+ "@visulima/path": "3.0.0-alpha.9",
155
+ "type-fest": "5.6.0"
118
156
  },
119
157
  "peerDependencies": {
158
+ "ini": "^6.0.0",
159
+ "json5": "^2.2.3",
160
+ "jsonc-parser": "^3.3.1",
161
+ "smol-toml": "^1.6.1",
120
162
  "yaml": "2.8.3"
121
163
  },
122
164
  "peerDependenciesMeta": {
165
+ "ini": {
166
+ "optional": true
167
+ },
168
+ "json5": {
169
+ "optional": true
170
+ },
171
+ "jsonc-parser": {
172
+ "optional": true
173
+ },
174
+ "smol-toml": {
175
+ "optional": true
176
+ },
123
177
  "yaml": {
124
178
  "optional": true
125
179
  }
126
180
  },
127
181
  "engines": {
128
- "node": ">=22.13 <=25.x"
182
+ "node": "^22.14.0 || >=24.10.0"
129
183
  },
130
184
  "os": [
131
185
  "darwin",
@@ -1,42 +0,0 @@
1
- /**
2
- * Constant to check if the path is visible to the calling process.
3
- * Corresponds to `node:fs.constants.F_OK`.
4
- */
5
- export declare const F_OK: number;
6
- /**
7
- * Constant to check if the path is readable to the calling process.
8
- * Corresponds to `node:fs.constants.R_OK`.
9
- */
10
- export declare const R_OK: number;
11
- /**
12
- * Constant to check if the path is writable to the calling process.
13
- * Corresponds to `node:fs.constants.W_OK`.
14
- */
15
- export declare const W_OK: number;
16
- /**
17
- * Constant to check if the path is executable by the calling process.
18
- * Corresponds to `node:fs.constants.X_OK`.
19
- */
20
- export declare const X_OK: number;
21
- /**
22
- * A special symbol that can be returned by the matcher function in `findUp` or `findUpSync`
23
- * to stop the search process prematurely.
24
- */
25
- export declare const FIND_UP_STOP: symbol;
26
- /**
27
- * Regular expression for stripping comments from JSON.
28
- * Matches:
29
- * 1. Quoted strings: "example \"escaped\" string"
30
- * 2. Single-line comments: // comment
31
- * 3. Multi-line comments: /* comment *\/
32
- * @example
33
- * const json = `{
34
- * // comment
35
- * "key": "value" // comment
36
- * }`;
37
- * json.replace(INTERNAL_STRIP_JSON_REGEX, (match) =>
38
- * /^"/.test(match) ? match : ''
39
- * );
40
- * // Result: { "key": "value" }
41
- */
42
- export declare const INTERNAL_STRIP_JSON_REGEX: RegExp;
@@ -1,14 +0,0 @@
1
- /**
2
- * Ensures that the directory exists.
3
- * If the directory structure does not exist, it is created. Like mkdir -p.
4
- * @param directory The path to the directory to ensure exists.
5
- * @example
6
- * ```javascript
7
- * import ensureDirSync from "@visulima/fs/ensure/ensure-dir-sync";
8
- *
9
- * ensureDirSync("/tmp/foo/bar/baz");
10
- * // Creates the directory structure /tmp/foo/bar/baz if it doesn't exist
11
- * ```
12
- */
13
- declare const ensureDirSync: (directory: URL | string) => void;
14
- export default ensureDirSync;
@@ -1,14 +0,0 @@
1
- /**
2
- * Ensures that the directory exists.
3
- * If the directory structure does not exist, it is created. Like mkdir -p.
4
- * @param directory The path to the directory to ensure exists.
5
- * @example
6
- * ```javascript
7
- * import ensureDir from "@visulima/fs/ensure/ensure-dir";
8
- *
9
- * await ensureDir("/tmp/foo/bar/baz");
10
- * // Creates the directory structure /tmp/foo/bar/baz if it doesn't exist
11
- * ```
12
- */
13
- declare const ensureDir: (directory: URL | string) => Promise<void>;
14
- export default ensureDir;
@@ -1,15 +0,0 @@
1
- /**
2
- * Ensures that the file exists.
3
- * If the file that is requested to be created is in directories that do not exist,
4
- * these directories are created. If the file already exists, it is NOT MODIFIED.
5
- * @param filePath The path to the file to ensure exists.
6
- * @example
7
- * ```javascript
8
- * import { ensureFileSync } from "@visulima/fs";
9
- *
10
- * ensureFileSync("/tmp/foo/bar/baz.txt");
11
- * // Creates the file /tmp/foo/bar/baz.txt and any missing parent directories if they don't exist
12
- * ```
13
- */
14
- declare const ensureFileSync: (filePath: URL | string) => void;
15
- export default ensureFileSync;
@@ -1,27 +0,0 @@
1
- /**
2
- * Asynchronously ensures that a file exists.
3
- * If the directory structure for the file does not exist, it is created.
4
- * If the file already exists, it is not modified.
5
- * @param filePath The path to the file. Can be a string or a URL object.
6
- * @returns A Promise that resolves when the file has been created or confirmed to exist.
7
- * @throws Will throw an error if the path exists and is not a file.
8
- * @throws Will throw an error if directory or file creation fails for reasons other than the path not existing initially.
9
- * @example
10
- * ```typescript
11
- * import { ensureFile } from "@visulima/fs";
12
- *
13
- * (async () => {
14
- * try {
15
- * await ensureFile("path/to/my/file.txt");
16
- * console.log("File ensured!");
17
- *
18
- * await ensureFile(new URL("file:///path/to/another/file.log"));
19
- * console.log("Another file ensured!");
20
- * } catch (error) {
21
- * console.error("Failed to ensure file:", error);
22
- * }
23
- * })();
24
- * ```
25
- */
26
- declare const ensureFile: (filePath: URL | string) => Promise<void>;
27
- export default ensureFile;
@@ -1,16 +0,0 @@
1
- /**
2
- * Ensures that the hard link exists.
3
- * If the directory structure does not exist, it is created.
4
- * @param source The path to the source file or directory.
5
- * @param destination The path to the destination link.
6
- * @example
7
- * ```javascript
8
- * import { ensureLinkSync } from "@visulima/fs";
9
- * import { join } from "node:path";
10
- *
11
- * // ensure the link /tmp/foo/bar-link.txt points to /tmp/foo/bar.txt
12
- * ensureLinkSync(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "bar-link.txt"));
13
- * ```
14
- */
15
- declare const ensureLinkSync: (source: URL | string, destination: URL | string) => void;
16
- export default ensureLinkSync;
@@ -1,16 +0,0 @@
1
- /**
2
- * Ensures that the hard link exists.
3
- * If the directory structure does not exist, it is created.
4
- * @param source The path to the source file or directory.
5
- * @param destination The path to the destination link.
6
- * @example
7
- * ```javascript
8
- * import { ensureLink } from "@visulima/fs";
9
- * import { join } from "node:path";
10
- *
11
- * // ensure the link /tmp/foo/bar-link.txt points to /tmp/foo/bar.txt
12
- * await ensureLink(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "bar-link.txt"));
13
- * ```
14
- */
15
- declare const ensureLink: (source: URL | string, destination: URL | string) => Promise<void>;
16
- export default ensureLink;
@@ -1,23 +0,0 @@
1
- import type { symlink } from "node:fs";
2
- /**
3
- * Ensures that the link exists, and points to a valid file.
4
- * If the directory structure does not exist, it is created.
5
- * If the link already exists, it is not modified but error is thrown if it is not point to the given target.
6
- * @param target the source file path
7
- * @param linkName the destination link path
8
- * @param type the type of the symlink, or null to use automatic detection
9
- * @returns A void.
10
- * @example
11
- * ```javascript
12
- * import { ensureSymlinkSync } from "@visulima/fs";
13
- * import { join } from "node:path";
14
- *
15
- * // Ensure a symlink /tmp/foo/link-to-bar.txt points to /tmp/foo/bar.txt
16
- * ensureSymlinkSync(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "link-to-bar.txt"));
17
- *
18
- * // Ensure a directory symlink /tmp/foo/link-to-baz-dir points to /tmp/foo/baz-dir
19
- * ensureSymlinkSync(join("/tmp", "foo", "baz-dir"), join("/tmp", "foo", "link-to-baz-dir"), "dir");
20
- * ```
21
- */
22
- declare const ensureSymlinkSync: (target: URL | string, linkName: URL | string, type?: symlink.Type) => void;
23
- export default ensureSymlinkSync;
@@ -1,23 +0,0 @@
1
- import type { symlink as symlinkSync } from "node:fs";
2
- /**
3
- * Ensures that the link exists, and points to a valid file.
4
- * If the directory structure does not exist, it is created.
5
- * If the link already exists, it is not modified but error is thrown if it is not point to the given target.
6
- * @param target the source file path
7
- * @param linkName the destination link path
8
- * @param type the type of the symlink, or null to use automatic detection
9
- * @returns A void promise that resolves once the link exists.
10
- * @example
11
- * ```javascript
12
- * import { ensureSymlink } from "@visulima/fs";
13
- * import { join } from "node:path";
14
- *
15
- * // Ensure a symlink /tmp/foo/link-to-bar.txt points to /tmp/foo/bar.txt
16
- * await ensureSymlink(join("/tmp", "foo", "bar.txt"), join("/tmp", "foo", "link-to-bar.txt"));
17
- *
18
- * // Ensure a directory symlink /tmp/foo/link-to-baz-dir points to /tmp/foo/baz-dir
19
- * await ensureSymlink(join("/tmp", "foo", "baz-dir"), join("/tmp", "foo", "link-to-baz-dir"), "dir");
20
- * ```
21
- */
22
- declare const ensureSymlink: (target: URL | string, linkName: URL | string, type?: symlinkSync.Type) => Promise<void>;
23
- export default ensureSymlink;
@@ -1,7 +0,0 @@
1
- import type { Stats } from "node:fs";
2
- export type PathType = "dir" | "file" | "symlink";
3
- /**
4
- * Get a human-readable file type string.
5
- * @param fileInfo A FileInfo describes a file and is returned by `stat`, `lstat`
6
- */
7
- export declare const getFileInfoType: (fileInfo: Stats) => PathType | undefined;
@@ -1,3 +0,0 @@
1
- import type { Stats } from "node:fs";
2
- declare const isStatsIdentical: (sourceStat: Stats, destinationStat: Stats) => boolean;
3
- export default isStatsIdentical;