@visulima/fs 5.0.0-alpha.3 → 5.0.0-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +377 -0
- package/LICENSE.md +208 -131
- package/dist/eol.d.ts +31 -30
- package/dist/eol.js +3 -26
- package/dist/error.d.ts +273 -7
- package/dist/error.js +1 -7
- package/dist/glob-parent.d.ts +35 -0
- package/dist/glob-parent.js +1 -0
- package/dist/glob.d.ts +4 -0
- package/dist/glob.js +1 -0
- package/dist/index.d.ts +857 -36
- package/dist/index.js +1 -33
- package/dist/ini.d.ts +70 -0
- package/dist/ini.js +1 -0
- package/dist/is-glob.d.ts +34 -0
- package/dist/is-glob.js +1 -0
- package/dist/json5.d.ts +36 -0
- package/dist/json5.js +1 -0
- package/dist/jsonc.d.ts +65 -0
- package/dist/jsonc.js +1 -0
- package/dist/match.d.ts +80 -0
- package/dist/match.js +1 -0
- package/dist/packem_shared/AlreadyExistsError-DEb3UWja.js +1 -0
- package/dist/packem_shared/DirectoryError-BtwSTLmT.js +1 -0
- package/dist/packem_shared/F_OK-CAwY1qU7.js +1 -0
- package/dist/packem_shared/JSONError-Cvp9ycba.js +4 -0
- package/dist/packem_shared/NotEmptyError-DZ1Ix089.js +1 -0
- package/dist/packem_shared/NotFoundError-CnRY6lVp.js +1 -0
- package/dist/packem_shared/PermissionError-DJ_2VWEj.js +1 -0
- package/dist/packem_shared/WalkError-B8qTd-v-.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +1 -0
- package/dist/packem_shared/assertValidFileContents-CbIN7sy7.js +1 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js +1 -0
- package/dist/packem_shared/build-rm-options-avnusYx-.js +1 -0
- package/dist/packem_shared/collect-VHN_VRLN.js +1 -0
- package/dist/packem_shared/collectSync-C28T6vrY.js +1 -0
- package/dist/packem_shared/emptyDir-C7lyd1lW.js +1 -0
- package/dist/packem_shared/emptyDirSync-B8EYpmO9.js +1 -0
- package/dist/packem_shared/ensureDir-DGarVZw8.js +1 -0
- package/dist/packem_shared/ensureDirSync-CsgPrsDH.js +1 -0
- package/dist/packem_shared/ensureFile-CMugWljp.js +1 -0
- package/dist/packem_shared/ensureFileSync-CJYTEx2r.js +1 -0
- package/dist/packem_shared/ensureLink-ChShf3lf.js +1 -0
- package/dist/packem_shared/ensureLinkSync-DPpq0I2Z.js +1 -0
- package/dist/packem_shared/ensureSymlink-y4FZjfxA.js +1 -0
- package/dist/packem_shared/ensureSymlinkSync-TcHssCH7.js +1 -0
- package/dist/packem_shared/findUp-D49u53m9.js +1 -0
- package/dist/packem_shared/findUpSync-C2oAKTw1.js +1 -0
- package/dist/packem_shared/get-file-info-type-DzWpohDB.js +1 -0
- package/dist/packem_shared/glob-D_7bct6p.js +1 -0
- package/dist/packem_shared/glob-sync.d-BgJM6l8W.d.ts +54 -0
- package/dist/packem_shared/globSync-f-4jVwn9.js +1 -0
- package/dist/packem_shared/index-B2MhYg3r.js +1 -0
- package/dist/packem_shared/index-BHy3Kcr7.js +11 -0
- package/dist/packem_shared/index-BspkXADC.js +1 -0
- package/dist/packem_shared/index-CChvzByK.js +1 -0
- package/dist/packem_shared/indexToLineColumn-BRSZFC6I-B2OZwR8G.js +6 -0
- package/dist/packem_shared/ini-preserve-D1DopDLd.js +4 -0
- package/dist/packem_shared/is-stats-identical-l1GRN4Qu.js +1 -0
- package/dist/packem_shared/isAccessible-DV2K-m2B.js +1 -0
- package/dist/packem_shared/isAccessibleSync-BCjiSxHj.js +1 -0
- package/dist/packem_shared/isFsCaseSensitive-j6UlSSM7.js +1 -0
- package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
- package/dist/packem_shared/jsonc-merge-Bkw73TLW.js +2 -0
- package/dist/packem_shared/move-CvE-ntXL.js +1 -0
- package/dist/packem_shared/parseJson-vUriP0eD.js +1 -0
- package/dist/packem_shared/readFile-ZXEXbVU5.js +1 -0
- package/dist/packem_shared/readFileSync-DseCu8sg.js +1 -0
- package/dist/packem_shared/readIni-CQK8HYxE.js +1 -0
- package/dist/packem_shared/readIniSync-l9LoYPoP.js +1 -0
- package/dist/packem_shared/readJson-T0hatQjC.js +1 -0
- package/dist/packem_shared/readJson5-CHbnB73J.js +1 -0
- package/dist/packem_shared/readJson5Sync-BsyhQYi8.js +1 -0
- package/dist/packem_shared/readJsonSync-Drti0sPY.js +1 -0
- package/dist/packem_shared/readJsonc-1woJjNLd.js +1 -0
- package/dist/packem_shared/readJsoncSync-TILCPRUQ.js +1 -0
- package/dist/packem_shared/readToml-Dawx4pqK.js +1 -0
- package/dist/packem_shared/readTomlSync-hnDlOU7g.js +1 -0
- package/dist/packem_shared/readYaml-DuXAtLKY.js +1 -0
- package/dist/packem_shared/readYamlSync-KlhBWm72.js +1 -0
- package/dist/packem_shared/remove-DmEfBrzp.js +1 -0
- package/dist/packem_shared/removeSync--c4qlu32.js +1 -0
- package/dist/packem_shared/resolve-symlink-target-CWrn0v4P.js +1 -0
- package/dist/packem_shared/sanitize-DGZ3w-_w.js +1 -0
- package/dist/packem_shared/stripJsonComments-gXl-1fAs.js +1 -0
- package/dist/packem_shared/to-uint-8-array-BBchIT6g.js +1 -0
- package/dist/packem_shared/types.d-C1ygRkw1.d.ts +1660 -0
- package/dist/packem_shared/walk-CxKfBzrV.js +1 -0
- package/dist/packem_shared/walk-include-BXhGSn6t.js +1 -0
- package/dist/packem_shared/walkSync-JkSkFL-F.js +1 -0
- package/dist/packem_shared/writeFile-CM-OVzxG.js +1 -0
- package/dist/packem_shared/writeFileSync-CNaAkXSP.js +1 -0
- package/dist/packem_shared/writeIni-B1NVnZkX.js +4 -0
- package/dist/packem_shared/writeIniSync-CwS1da1r.js +4 -0
- package/dist/packem_shared/writeJson-DC1V8Afe.js +4 -0
- package/dist/packem_shared/writeJson5--_qaVjxW.js +4 -0
- package/dist/packem_shared/writeJson5Sync-DPOk8wWz.js +4 -0
- package/dist/packem_shared/writeJsonSync-CUt49Wp1.js +4 -0
- package/dist/packem_shared/writeJsonc-DXuAO3_X.js +4 -0
- package/dist/packem_shared/writeJsoncSync-BEeqh1ry.js +4 -0
- package/dist/packem_shared/writeToml-BFD91-Sv.js +1 -0
- package/dist/packem_shared/writeTomlSync-D30hzuuu.js +1 -0
- package/dist/packem_shared/writeYaml-BD9JVGkk.js +1 -0
- package/dist/packem_shared/writeYamlSync-BobkRsmd.js +1 -0
- package/dist/size.d.ts +246 -246
- package/dist/size.js +1 -144
- package/dist/toml.d.ts +63 -0
- package/dist/toml.js +1 -0
- package/dist/utils.d.ts +103 -6
- package/dist/utils.js +1 -6
- package/dist/yaml.d.ts +13 -5
- package/dist/yaml.js +1 -4
- package/package.json +69 -18
- package/dist/constants.d.ts +0 -42
- package/dist/ensure/ensure-dir-sync.d.ts +0 -14
- package/dist/ensure/ensure-dir.d.ts +0 -14
- package/dist/ensure/ensure-file-sync.d.ts +0 -15
- package/dist/ensure/ensure-file.d.ts +0 -27
- package/dist/ensure/ensure-link-sync.d.ts +0 -16
- package/dist/ensure/ensure-link.d.ts +0 -16
- package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
- package/dist/ensure/ensure-symlink.d.ts +0 -23
- package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
- package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
- package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
- package/dist/error/already-exists-error.d.ts +0 -39
- package/dist/error/directory-error.d.ts +0 -47
- package/dist/error/json-error.d.ts +0 -52
- package/dist/error/not-empty-error.d.ts +0 -51
- package/dist/error/not-found-error.d.ts +0 -44
- package/dist/error/permission-error.d.ts +0 -45
- package/dist/error/walk-error.d.ts +0 -51
- package/dist/find/collect-sync.d.ts +0 -31
- package/dist/find/collect.d.ts +0 -35
- package/dist/find/find-up-sync.d.ts +0 -42
- package/dist/find/find-up.d.ts +0 -46
- package/dist/find/utils/glob-to-regexp.d.ts +0 -2
- package/dist/find/utils/walk-include.d.ts +0 -2
- package/dist/find/walk-sync.d.ts +0 -34
- package/dist/find/walk.d.ts +0 -37
- package/dist/is-accessible-sync.d.ts +0 -3
- package/dist/is-accessible.d.ts +0 -29
- package/dist/move/index.d.ts +0 -68
- package/dist/move/types.d.ts +0 -36
- package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
- package/dist/move/utils/internal-move-file.d.ts +0 -3
- package/dist/move/utils/validate-same-directory.d.ts +0 -2
- package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
- package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
- package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
- package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
- package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
- package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
- package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
- package/dist/packem_shared/WalkError-DUdQd6FT.js +0 -24
- package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
- package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
- package/dist/packem_shared/collect-DcBwsYYd.js +0 -14
- package/dist/packem_shared/collectSync-Bkjf9Dbm.js +0 -14
- package/dist/packem_shared/emptyDir-CYB5Tict.js +0 -43
- package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +0 -41
- package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +0 -53
- package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +0 -53
- package/dist/packem_shared/ensureFile-BUtXGlGT.js +0 -47
- package/dist/packem_shared/ensureFileSync-C8hASR-1.js +0 -47
- package/dist/packem_shared/ensureLink-BPnAG5-P.js +0 -54
- package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +0 -54
- package/dist/packem_shared/ensureSymlink-U5B6J0BN.js +0 -73
- package/dist/packem_shared/ensureSymlinkSync-DHnZj-9F.js +0 -74
- package/dist/packem_shared/findUp-BSnyGqer.js +0 -85
- package/dist/packem_shared/findUpSync-jRHbSCMV.js +0 -85
- package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
- package/dist/packem_shared/index-CHM-in-V.js +0 -100
- package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
- package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
- package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
- package/dist/packem_shared/isFsCaseSensitive-D-ayleCy.js +0 -62
- package/dist/packem_shared/move-DbpW5_vA.js +0 -134
- package/dist/packem_shared/parseJson-C8xb-3LR.js +0 -231
- package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
- package/dist/packem_shared/readFileSync-6GEIrOnl.js +0 -53
- package/dist/packem_shared/readJson-vddQ97Ll.js +0 -22
- package/dist/packem_shared/readJsonSync-DzeAdYZl.js +0 -22
- package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
- package/dist/packem_shared/readYamlSync-DMV4U-gi.js +0 -10
- package/dist/packem_shared/remove-_oDY3uKo.js +0 -38
- package/dist/packem_shared/removeSync-DETRj7Qn.js +0 -38
- package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
- package/dist/packem_shared/sanitize-lOzE6k2A.js +0 -205
- package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
- package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
- package/dist/packem_shared/walk-BhTbpr3y.js +0 -115
- package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
- package/dist/packem_shared/walkSync-DDBq95s8.js +0 -114
- package/dist/packem_shared/writeFile-DSHERs0Z.js +0 -83
- package/dist/packem_shared/writeFileSync-CJp1kXQR.js +0 -83
- package/dist/packem_shared/writeJson-C0OfLDbe.js +0 -50
- package/dist/packem_shared/writeJsonSync-Cs21FE7v.js +0 -50
- package/dist/packem_shared/writeYaml-n4xzYN9a.js +0 -24
- package/dist/packem_shared/writeYamlSync-DnOEnP10.js +0 -24
- package/dist/read/read-file-sync.d.ts +0 -37
- package/dist/read/read-file.d.ts +0 -41
- package/dist/read/read-json-sync.d.ts +0 -5
- package/dist/read/read-json.d.ts +0 -5
- package/dist/read/read-yaml-sync.d.ts +0 -4
- package/dist/read/read-yaml.d.ts +0 -4
- package/dist/remove/empty-dir-sync.d.ts +0 -23
- package/dist/remove/empty-dir.d.ts +0 -28
- package/dist/remove/remove-sync.d.ts +0 -27
- package/dist/remove/remove.d.ts +0 -32
- package/dist/sanitize.d.ts +0 -31
- package/dist/types.d.ts +0 -304
- package/dist/utils/assert-valid-file-contents.d.ts +0 -27
- package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
- package/dist/utils/parse-json.d.ts +0 -5
- package/dist/utils/strip-json-comments.d.ts +0 -44
- package/dist/write/utils/to-uint-8-array.d.ts +0 -2
- package/dist/write/write-file-sync.d.ts +0 -30
- package/dist/write/write-file.d.ts +0 -30
- package/dist/write/write-json-sync.d.ts +0 -29
- package/dist/write/write-json.d.ts +0 -30
- package/dist/write/write-yaml-sync.d.ts +0 -4
- package/dist/write/write-yaml.d.ts +0 -4
package/dist/size.js
CHANGED
|
@@ -1,144 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
readFileSync,
|
|
22
|
-
statSync,
|
|
23
|
-
existsSync
|
|
24
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
25
|
-
const {
|
|
26
|
-
readFile
|
|
27
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
28
|
-
const {
|
|
29
|
-
isAbsolute,
|
|
30
|
-
resolve
|
|
31
|
-
} = __cjs_getBuiltinModule("node:path");
|
|
32
|
-
const {
|
|
33
|
-
Readable
|
|
34
|
-
} = __cjs_getBuiltinModule("node:stream");
|
|
35
|
-
const {
|
|
36
|
-
URL
|
|
37
|
-
} = __cjs_getBuiltinModule("node:url");
|
|
38
|
-
const {
|
|
39
|
-
gzipSync,
|
|
40
|
-
brotliCompressSync,
|
|
41
|
-
createBrotliCompress,
|
|
42
|
-
createGzip
|
|
43
|
-
} = __cjs_getBuiltinModule("node:zlib");
|
|
44
|
-
import { toPath } from '@visulima/path/utils';
|
|
45
|
-
|
|
46
|
-
const fileExists = (input) => {
|
|
47
|
-
if (isAbsolute(input)) {
|
|
48
|
-
return existsSync(input);
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
return existsSync(resolve(input));
|
|
52
|
-
} catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const getStreamSizeEfficient = async (stream) => {
|
|
57
|
-
let totalSize = 0;
|
|
58
|
-
for await (const chunk of stream) {
|
|
59
|
-
totalSize += Buffer.from(chunk).length;
|
|
60
|
-
}
|
|
61
|
-
return totalSize;
|
|
62
|
-
};
|
|
63
|
-
const getCompressedStreamSizeEfficient = async (stream, createCompressor) => {
|
|
64
|
-
let totalSize = 0;
|
|
65
|
-
const compressor = createCompressor();
|
|
66
|
-
return await new Promise((resolve2, reject) => {
|
|
67
|
-
compressor.on("data", (chunk) => {
|
|
68
|
-
totalSize += chunk.length;
|
|
69
|
-
});
|
|
70
|
-
compressor.on("end", () => resolve2(totalSize));
|
|
71
|
-
compressor.on("error", reject);
|
|
72
|
-
stream.on("error", reject);
|
|
73
|
-
stream.pipe(compressor);
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
const processInputEfficiently = async (input, processor, streamProcessor) => {
|
|
77
|
-
if (input instanceof URL || typeof input === "string") {
|
|
78
|
-
const path = toPath(input);
|
|
79
|
-
if (fileExists(path)) {
|
|
80
|
-
const fileStream = Readable.from(await readFile(path));
|
|
81
|
-
return await streamProcessor(fileStream);
|
|
82
|
-
}
|
|
83
|
-
if (typeof input === "string") {
|
|
84
|
-
return processor(Buffer.from(input));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (input instanceof Readable) {
|
|
88
|
-
return await streamProcessor(input);
|
|
89
|
-
}
|
|
90
|
-
return processor(input);
|
|
91
|
-
};
|
|
92
|
-
const gzipSize = async (input, options) => {
|
|
93
|
-
const streamProcessor = async (stream) => await getCompressedStreamSizeEfficient(stream, () => createGzip(options));
|
|
94
|
-
const bufferProcessor = (data) => gzipSync(data, options).length;
|
|
95
|
-
return await processInputEfficiently(input, bufferProcessor, streamProcessor);
|
|
96
|
-
};
|
|
97
|
-
const brotliSize = async (input, options) => {
|
|
98
|
-
const streamProcessor = async (stream) => await getCompressedStreamSizeEfficient(stream, () => createBrotliCompress(options));
|
|
99
|
-
const bufferProcessor = (data) => brotliCompressSync(data, options).length;
|
|
100
|
-
return await processInputEfficiently(input, bufferProcessor, streamProcessor);
|
|
101
|
-
};
|
|
102
|
-
const rawSize = async (input) => {
|
|
103
|
-
const streamProcessor = async (stream) => await getStreamSizeEfficient(stream);
|
|
104
|
-
const bufferProcessor = (data) => data.length;
|
|
105
|
-
return await processInputEfficiently(input, bufferProcessor, streamProcessor);
|
|
106
|
-
};
|
|
107
|
-
const gzipSizeSync = (input, options) => {
|
|
108
|
-
if (input instanceof URL || typeof input === "string") {
|
|
109
|
-
const path = toPath(input);
|
|
110
|
-
if (fileExists(path)) {
|
|
111
|
-
return gzipSync(readFileSync(path), options).length;
|
|
112
|
-
}
|
|
113
|
-
if (typeof input === "string") {
|
|
114
|
-
return gzipSync(Buffer.from(input), options).length;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return gzipSync(input, options).length;
|
|
118
|
-
};
|
|
119
|
-
const brotliSizeSync = (input, options) => {
|
|
120
|
-
if (input instanceof URL || typeof input === "string") {
|
|
121
|
-
const path = toPath(input);
|
|
122
|
-
if (fileExists(path)) {
|
|
123
|
-
return brotliCompressSync(readFileSync(path), options).length;
|
|
124
|
-
}
|
|
125
|
-
if (typeof input === "string") {
|
|
126
|
-
return brotliCompressSync(Buffer.from(input), options).length;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return brotliCompressSync(input, options).length;
|
|
130
|
-
};
|
|
131
|
-
const rawSizeSync = (input) => {
|
|
132
|
-
if (input instanceof URL || typeof input === "string") {
|
|
133
|
-
const path = toPath(input);
|
|
134
|
-
if (fileExists(path)) {
|
|
135
|
-
return statSync(path).size;
|
|
136
|
-
}
|
|
137
|
-
if (typeof input === "string") {
|
|
138
|
-
return Buffer.from(input).length;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return input.length;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export { brotliSize, brotliSizeSync, gzipSize, gzipSizeSync, rawSize, rawSizeSync };
|
|
1
|
+
import{createRequire as S}from"node:module";import{toPath as c}from"@visulima/path/utils";const z=S(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,o=t=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[n,e]=i.versions.node.split(".").map(Number);if(n>22||n===22&&e>=3||n===20&&e>=16)return i.getBuiltinModule(t)}return z(t)},{readFileSync:d,statSync:_,existsSync:y}=o("node:fs"),{readFile:b}=o("node:fs/promises"),{isAbsolute:B,resolve:j}=o("node:path"),{Readable:m}=o("node:stream"),{URL:f}=o("node:url"),{brotliCompressSync:s,gzipSync:a,createGzip:v,createBrotliCompress:R}=o("node:zlib"),l=t=>{if(B(t))return y(t);try{return y(j(t))}catch{return!1}},q=async t=>{let n=0;for await(const e of t)n+=Buffer.from(e).length;return n},h=async(t,n)=>{let e=0;const r=n();return await new Promise((u,p)=>{r.on("data",w=>{e+=w.length}),r.on("end",()=>{u(e)}),r.on("error",p),t.on("error",p),t.pipe(r)})},g=async(t,n,e)=>{if(t instanceof f||typeof t=="string"){const r=c(t);if(l(r)){const u=m.from(await b(r));return await e(u)}if(typeof t=="string")return n(Buffer.from(t))}return t instanceof m?await e(t):n(t)},x=async(t,n)=>await g(t,e=>a(e,n).length,async e=>await h(e,()=>v(n))),C=async(t,n)=>await g(t,e=>s(e,n).length,async e=>await h(e,()=>R(n))),F=async t=>await g(t,n=>n.length,async n=>await q(n)),M=(t,n)=>{if(t instanceof f||typeof t=="string"){const e=c(t);if(l(e))return a(d(e),n).length;if(typeof t=="string")return a(Buffer.from(t),n).length}return a(t,n).length},A=(t,n)=>{if(t instanceof f||typeof t=="string"){const e=c(t);if(l(e))return s(d(e),n).length;if(typeof t=="string")return s(Buffer.from(t),n).length}return s(t,n).length},G=t=>{if(t instanceof f||typeof t=="string"){const n=c(t);if(l(n))return _(n).size;if(typeof t=="string")return Buffer.from(t).length}return t.length};export{C as brotliSize,A as brotliSizeSync,x as gzipSize,M as gzipSizeSync,F as rawSize,G as rawSizeSync};
|
package/dist/toml.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { a as CompressionType, d as ReadTomlOptions, e as WriteTomlOptions } from "./packem_shared/types.d-C1ygRkw1.js";
|
|
2
|
+
import 'node:fs';
|
|
3
|
+
import 'tinyglobby';
|
|
4
|
+
/**
|
|
5
|
+
* Asynchronously reads a TOML file and parses it into an object.
|
|
6
|
+
* @template R The expected type of the parsed TOML object. Defaults to `Record<string, unknown>`.
|
|
7
|
+
* @param path The path to the TOML file to read. Can be a file URL or a string path.
|
|
8
|
+
* @param options Optional configuration for reading the file. See {@link ReadTomlOptions}.
|
|
9
|
+
* @returns A promise that resolves with the parsed TOML object of type `R`.
|
|
10
|
+
* @example
|
|
11
|
+
* ```javascript
|
|
12
|
+
* import { readToml } from "@visulima/fs/toml";
|
|
13
|
+
* import { join } from "node:path";
|
|
14
|
+
*
|
|
15
|
+
* const config = await readToml(join("path", "to", "config.toml"));
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const readToml: <R = Record<string, unknown>>(path: URL | string, options?: ReadTomlOptions<CompressionType>) => Promise<R>;
|
|
19
|
+
/**
|
|
20
|
+
* Synchronously reads a TOML file and parses it into an object.
|
|
21
|
+
* @template R The expected type of the parsed TOML object. Defaults to `Record<string, unknown>`.
|
|
22
|
+
* @param path The path to the TOML file to read. Can be a file URL or a string path.
|
|
23
|
+
* @param options Optional configuration for reading the file. See {@link ReadTomlOptions}.
|
|
24
|
+
* @returns The parsed TOML object of type `R`.
|
|
25
|
+
* @example
|
|
26
|
+
* ```javascript
|
|
27
|
+
* import { readTomlSync } from "@visulima/fs/toml";
|
|
28
|
+
* import { join } from "node:path";
|
|
29
|
+
*
|
|
30
|
+
* const config = readTomlSync(join("path", "to", "config.toml"));
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare const readTomlSync: (path: URL | string, options?: ReadTomlOptions<CompressionType>) => Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Asynchronously writes an object to a TOML file.
|
|
36
|
+
* @param path The path to the TOML file to write. Can be a file URL or a string path.
|
|
37
|
+
* @param data The data to serialize. Must be a plain object compatible with `smol-toml.stringify`.
|
|
38
|
+
* @param options Optional configuration for writing the TOML file. See {@link WriteTomlOptions}.
|
|
39
|
+
* @returns A promise that resolves when the TOML file has been written.
|
|
40
|
+
* @example
|
|
41
|
+
* ```javascript
|
|
42
|
+
* import { writeToml } from "@visulima/fs/toml";
|
|
43
|
+
* import { join } from "node:path";
|
|
44
|
+
*
|
|
45
|
+
* await writeToml(join("/tmp", "config.toml"), { name: "app", version: 1 });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare const writeToml: (path: URL | string, data: Record<string, unknown>, options?: WriteTomlOptions) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Synchronously writes an object to a TOML file.
|
|
51
|
+
* @param path The path to the TOML file to write. Can be a file URL or a string path.
|
|
52
|
+
* @param data The data to serialize. Must be a plain object compatible with `smol-toml.stringify`.
|
|
53
|
+
* @param options Optional configuration for writing the TOML file. See {@link WriteTomlOptions}.
|
|
54
|
+
* @example
|
|
55
|
+
* ```javascript
|
|
56
|
+
* import { writeTomlSync } from "@visulima/fs/toml";
|
|
57
|
+
* import { join } from "node:path";
|
|
58
|
+
*
|
|
59
|
+
* writeTomlSync(join("/tmp", "config.toml"), { name: "app", version: 1 });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare const writeTomlSync: (path: URL | string, data: Record<string, unknown>, options?: WriteTomlOptions) => void;
|
|
63
|
+
export { type ReadTomlOptions, type WriteTomlOptions, readToml, readTomlSync, writeToml, writeTomlSync };
|
package/dist/toml.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as r}from"./packem_shared/readToml-Dawx4pqK.js";import{default as t}from"./packem_shared/readTomlSync-hnDlOU7g.js";import{default as l}from"./packem_shared/writeToml-BFD91-Sv.js";import{default as d}from"./packem_shared/writeTomlSync-D30hzuuu.js";export{r as readToml,t as readTomlSync,l as writeToml,d as writeTomlSync};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,103 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export { J as JSONError } from "./packem_shared/json-error.d-DVILOyHc.js";
|
|
2
|
+
import { JsonValue } from 'type-fest';
|
|
3
|
+
import { C as CodeFrameOptions, J as JsonReviver } from "./packem_shared/types.d-C1ygRkw1.js";
|
|
4
|
+
export { toPath } from '@visulima/path/utils';
|
|
5
|
+
import 'node:fs';
|
|
6
|
+
import 'tinyglobby';
|
|
7
|
+
/**
|
|
8
|
+
* Asserts that the provided contents are valid for writing to a file.
|
|
9
|
+
* Valid contents can be a string, an ArrayBuffer, or an ArrayBuffer view (e.g., Uint8Array).
|
|
10
|
+
* @param contents The file contents to validate.
|
|
11
|
+
* @throws {TypeError} If the contents are not a string, ArrayBuffer, or ArrayBuffer view.
|
|
12
|
+
* @example
|
|
13
|
+
* ```javascript
|
|
14
|
+
* import { assertValidFileContents } from "@visulima/fs"; // Assuming this util is exported
|
|
15
|
+
*
|
|
16
|
+
* try {
|
|
17
|
+
* assertValidFileContents("Hello, world!");
|
|
18
|
+
* assertValidFileContents(new Uint8Array([72, 101, 108, 108, 111])); // "Hello"
|
|
19
|
+
* assertValidFileContents(new ArrayBuffer(8));
|
|
20
|
+
* console.log("File contents are valid.");
|
|
21
|
+
* } catch (error) {
|
|
22
|
+
* console.error(error.message); // File contents must be a string, ArrayBuffer, or ArrayBuffer view.
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* try {
|
|
26
|
+
* assertValidFileContents(123); // Invalid content type
|
|
27
|
+
* } catch (error) {
|
|
28
|
+
* console.error(error.message); // File contents must be a string, ArrayBuffer, or ArrayBuffer view.
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare const assertValidFileContents: (contents: any) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Asserts that the provided path is a valid file or directory path.
|
|
35
|
+
* A valid path must be a non-empty string or a URL instance.
|
|
36
|
+
* @param fileOrDirectoryPath The path to validate.
|
|
37
|
+
* @throws {TypeError} If the path is not a non-empty string or a URL.
|
|
38
|
+
* @example
|
|
39
|
+
* ```javascript
|
|
40
|
+
* import { assertValidFileOrDirectoryPath } from "@visulima/fs"; // Assuming this util is exported
|
|
41
|
+
*
|
|
42
|
+
* try {
|
|
43
|
+
* assertValidFileOrDirectoryPath("/path/to/file.txt");
|
|
44
|
+
* assertValidFileOrDirectoryPath(new URL("file:///path/to/file.txt"));
|
|
45
|
+
* console.log("Path is valid.");
|
|
46
|
+
* } catch (error) {
|
|
47
|
+
* console.error(error.message); // Path must be a non-empty string or URL.
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* try {
|
|
51
|
+
* assertValidFileOrDirectoryPath(""); // Invalid path
|
|
52
|
+
* } catch (error) {
|
|
53
|
+
* console.error(error.message); // Path must be a non-empty string or URL.
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare const assertValidFileOrDirectoryPath: (fileOrDirectoryPath: any) => void;
|
|
58
|
+
declare function parseJson(string: string, filename?: string, options?: CodeFrameOptions): JsonValue;
|
|
59
|
+
declare function parseJson(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): JsonValue;
|
|
60
|
+
/**
|
|
61
|
+
* Strips comments from a JSON string.
|
|
62
|
+
* Handles both single-line (//) and multi-line (/* ... *&#47;) comments.
|
|
63
|
+
* @param jsonString The JSON string possibly containing comments.
|
|
64
|
+
* @param [options] Optional configuration for stripping comments.
|
|
65
|
+
* @param [options.whitespace] If `true` (default), comments are replaced with whitespace to preserve line numbers and character positions. If `false`, comments are removed entirely.
|
|
66
|
+
* @returns The JSON string with comments stripped.
|
|
67
|
+
* @example
|
|
68
|
+
* ```javascript
|
|
69
|
+
* import { stripJsonComments } from "@visulima/fs"; // Assuming this util is exported
|
|
70
|
+
*
|
|
71
|
+
* const jsonWithComments = `{
|
|
72
|
+
* // This is a single-line comment
|
|
73
|
+
* "name": "John Doe",
|
|
74
|
+
* "age": 30, /* This is a
|
|
75
|
+
* multi-line comment */
|
|
76
|
+
* "city": "New York"
|
|
77
|
+
* }`;
|
|
78
|
+
*
|
|
79
|
+
* const stripped = stripJsonComments(jsonWithComments);
|
|
80
|
+
* console.log(stripped);
|
|
81
|
+
* // Output (with whitespace=true):
|
|
82
|
+
* // {
|
|
83
|
+
* //
|
|
84
|
+
* // "name": "John Doe",
|
|
85
|
+
* // "age": 30, /*
|
|
86
|
+
* //
|
|
87
|
+
* // "city": "New York"
|
|
88
|
+
* // }
|
|
89
|
+
*
|
|
90
|
+
* const strippedWithoutWhitespace = stripJsonComments(jsonWithComments, { whitespace: false });
|
|
91
|
+
* console.log(strippedWithoutWhitespace);
|
|
92
|
+
* // Output (with whitespace=false):
|
|
93
|
+
* // {
|
|
94
|
+
* // "name": "John Doe",
|
|
95
|
+
* // "age": 30,
|
|
96
|
+
* // "city": "New York"
|
|
97
|
+
* // }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare const stripJsonComments: (jsonString: string, options?: {
|
|
101
|
+
whitespace?: boolean;
|
|
102
|
+
}) => string;
|
|
103
|
+
export { assertValidFileContents, assertValidFileOrDirectoryPath, parseJson, stripJsonComments };
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as assertValidFileContents } from './packem_shared/assertValidFileContents-BmcLtsGd.js';
|
|
3
|
-
export { default as assertValidFileOrDirectoryPath } from './packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
4
|
-
export { default as parseJson } from './packem_shared/parseJson-C8xb-3LR.js';
|
|
5
|
-
export { default as stripJsonComments } from './packem_shared/stripJsonComments-vo4k0mpF.js';
|
|
6
|
-
export { toPath } from '@visulima/path/utils';
|
|
1
|
+
import{default as e}from"./packem_shared/JSONError-Cvp9ycba.js";import{default as a}from"./packem_shared/assertValidFileContents-CbIN7sy7.js";import{default as f}from"./packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js";import{default as m}from"./packem_shared/parseJson-vUriP0eD.js";import{default as d}from"./packem_shared/stripJsonComments-gXl-1fAs.js";import{toPath as x}from"@visulima/path/utils";export{e as JSONError,a as assertValidFileContents,f as assertValidFileOrDirectoryPath,m as parseJson,d as stripJsonComments,x as toPath};
|
package/dist/yaml.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { a as CompressionType, R as ReadYamlOptions, Y as YamlReviver, W as WriteYamlOptions, b as JsonReplacer } from "./packem_shared/types.d-C1ygRkw1.js";
|
|
2
|
+
export { type c as YamlReplacer } from "./packem_shared/types.d-C1ygRkw1.js";
|
|
3
|
+
import 'node:fs';
|
|
4
|
+
import 'tinyglobby';
|
|
5
|
+
declare function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<CompressionType>): Promise<R>;
|
|
6
|
+
declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): Promise<R>;
|
|
7
|
+
declare function readYamlSync(path: URL | string, options?: ReadYamlOptions<CompressionType>): Record<string, unknown>;
|
|
8
|
+
declare function readYamlSync(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): Record<string, unknown>;
|
|
9
|
+
declare function writeYaml(path: URL | string, data: any, options?: WriteYamlOptions): Promise<void>;
|
|
10
|
+
declare function writeYaml(path: URL | string, data: any, replacer?: JsonReplacer, options?: WriteYamlOptions | number | string): Promise<void>;
|
|
11
|
+
declare function writeYamlSync(path: URL | string, data: any, options?: WriteYamlOptions): void;
|
|
12
|
+
declare function writeYamlSync(path: URL | string, data: any, replacer?: JsonReplacer, options?: WriteYamlOptions | number | string): void;
|
|
13
|
+
export { readYaml, readYamlSync, writeYaml, writeYamlSync };
|
package/dist/yaml.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
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';
|
|
1
|
+
import{default as r}from"./packem_shared/readYaml-DuXAtLKY.js";import{default as f}from"./packem_shared/readYamlSync-KlhBWm72.js";import{default as m}from"./packem_shared/writeYaml-BD9JVGkk.js";import{default as d}from"./packem_shared/writeYamlSync-BobkRsmd.js";export{r as readYaml,f as readYamlSync,m as writeYaml,d as writeYamlSync};
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/fs",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.31",
|
|
4
4
|
"description": "Human friendly file system utilities for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
7
|
+
"brotli",
|
|
7
8
|
"detect-newline",
|
|
8
9
|
"dir",
|
|
9
10
|
"directory",
|
|
10
|
-
"eol",
|
|
11
11
|
"empty-dir",
|
|
12
12
|
"ensure",
|
|
13
|
-
"ensure-file",
|
|
14
13
|
"ensure-dir",
|
|
14
|
+
"ensure-file",
|
|
15
15
|
"ensure-link",
|
|
16
16
|
"ensure-symlink",
|
|
17
|
+
"eol",
|
|
17
18
|
"file",
|
|
18
19
|
"files",
|
|
19
20
|
"filesystem",
|
|
@@ -23,10 +24,14 @@
|
|
|
23
24
|
"folder",
|
|
24
25
|
"fs",
|
|
25
26
|
"fs-safe",
|
|
27
|
+
"gzip",
|
|
28
|
+
"ini",
|
|
29
|
+
"json",
|
|
30
|
+
"json5",
|
|
31
|
+
"jsonc",
|
|
32
|
+
"jsonc-parser",
|
|
26
33
|
"look",
|
|
27
34
|
"look-up",
|
|
28
|
-
"json",
|
|
29
|
-
"read-json",
|
|
30
35
|
"match",
|
|
31
36
|
"package",
|
|
32
37
|
"parent",
|
|
@@ -34,12 +39,16 @@
|
|
|
34
39
|
"path",
|
|
35
40
|
"read",
|
|
36
41
|
"read-file",
|
|
42
|
+
"read-json",
|
|
37
43
|
"read-yaml",
|
|
38
44
|
"resolve",
|
|
39
45
|
"safe",
|
|
40
46
|
"search",
|
|
41
|
-
"
|
|
47
|
+
"size",
|
|
48
|
+
"smol-toml",
|
|
42
49
|
"standard",
|
|
50
|
+
"std",
|
|
51
|
+
"toml",
|
|
43
52
|
"up",
|
|
44
53
|
"visulima",
|
|
45
54
|
"walk",
|
|
@@ -48,15 +57,10 @@
|
|
|
48
57
|
"write-dir",
|
|
49
58
|
"write-file",
|
|
50
59
|
"write-safe",
|
|
51
|
-
"yaml"
|
|
52
|
-
"size",
|
|
53
|
-
"brotli",
|
|
54
|
-
"gzip"
|
|
60
|
+
"yaml"
|
|
55
61
|
],
|
|
56
|
-
"homepage": "https://
|
|
57
|
-
"bugs":
|
|
58
|
-
"url": "https://github.com/visulima/visulima/issues"
|
|
59
|
-
},
|
|
62
|
+
"homepage": "https://visulima.com/packages/fs/",
|
|
63
|
+
"bugs": "https://github.com/visulima/visulima/issues",
|
|
60
64
|
"repository": {
|
|
61
65
|
"type": "git",
|
|
62
66
|
"url": "git+https://github.com/visulima/visulima.git",
|
|
@@ -96,6 +100,22 @@
|
|
|
96
100
|
"types": "./dist/yaml.d.ts",
|
|
97
101
|
"default": "./dist/yaml.js"
|
|
98
102
|
},
|
|
103
|
+
"./toml": {
|
|
104
|
+
"types": "./dist/toml.d.ts",
|
|
105
|
+
"default": "./dist/toml.js"
|
|
106
|
+
},
|
|
107
|
+
"./jsonc": {
|
|
108
|
+
"types": "./dist/jsonc.d.ts",
|
|
109
|
+
"default": "./dist/jsonc.js"
|
|
110
|
+
},
|
|
111
|
+
"./json5": {
|
|
112
|
+
"types": "./dist/json5.d.ts",
|
|
113
|
+
"default": "./dist/json5.js"
|
|
114
|
+
},
|
|
115
|
+
"./ini": {
|
|
116
|
+
"types": "./dist/ini.d.ts",
|
|
117
|
+
"default": "./dist/ini.js"
|
|
118
|
+
},
|
|
99
119
|
"./size": {
|
|
100
120
|
"types": "./dist/size.d.ts",
|
|
101
121
|
"default": "./dist/size.js"
|
|
@@ -104,6 +124,22 @@
|
|
|
104
124
|
"types": "./dist/eol.d.ts",
|
|
105
125
|
"default": "./dist/eol.js"
|
|
106
126
|
},
|
|
127
|
+
"./glob": {
|
|
128
|
+
"types": "./dist/glob.d.ts",
|
|
129
|
+
"default": "./dist/glob.js"
|
|
130
|
+
},
|
|
131
|
+
"./glob-parent": {
|
|
132
|
+
"types": "./dist/glob-parent.d.ts",
|
|
133
|
+
"default": "./dist/glob-parent.js"
|
|
134
|
+
},
|
|
135
|
+
"./is-glob": {
|
|
136
|
+
"types": "./dist/is-glob.d.ts",
|
|
137
|
+
"default": "./dist/is-glob.js"
|
|
138
|
+
},
|
|
139
|
+
"./match": {
|
|
140
|
+
"types": "./dist/match.d.ts",
|
|
141
|
+
"default": "./dist/match.js"
|
|
142
|
+
},
|
|
107
143
|
"./package.json": "./package.json"
|
|
108
144
|
},
|
|
109
145
|
"files": [
|
|
@@ -113,19 +149,34 @@
|
|
|
113
149
|
"LICENSE.md"
|
|
114
150
|
],
|
|
115
151
|
"dependencies": {
|
|
116
|
-
"@visulima/path": "3.0.0-alpha.
|
|
117
|
-
"type-fest": "^5.3.1"
|
|
152
|
+
"@visulima/path": "3.0.0-alpha.12"
|
|
118
153
|
},
|
|
119
154
|
"peerDependencies": {
|
|
120
|
-
"
|
|
155
|
+
"ini": "^7.0.0",
|
|
156
|
+
"json5": "^2.2.3",
|
|
157
|
+
"jsonc-parser": "^3.3.1",
|
|
158
|
+
"smol-toml": "^1.6.1",
|
|
159
|
+
"yaml": "2.9.0"
|
|
121
160
|
},
|
|
122
161
|
"peerDependenciesMeta": {
|
|
162
|
+
"ini": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
"json5": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
168
|
+
"jsonc-parser": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"smol-toml": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
123
174
|
"yaml": {
|
|
124
175
|
"optional": true
|
|
125
176
|
}
|
|
126
177
|
},
|
|
127
178
|
"engines": {
|
|
128
|
-
"node": "
|
|
179
|
+
"node": "^22.14.0 || >=24.10.0"
|
|
129
180
|
},
|
|
130
181
|
"os": [
|
|
131
182
|
"darwin",
|
package/dist/constants.d.ts
DELETED
|
@@ -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;
|