@visulima/fs 5.0.0-alpha.1 → 5.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +177 -0
- package/LICENSE.md +157 -128
- package/dist/eol.d.ts +6 -35
- package/dist/error.d.ts +43 -7
- package/dist/error.js +1 -1
- package/dist/glob-parent.d.ts +5 -0
- package/dist/glob-parent.js +90 -0
- package/dist/glob.d.ts +5 -0
- package/dist/glob.js +2 -0
- package/dist/index.d.ts +81 -36
- package/dist/index.js +32 -27
- package/dist/ini.d.ts +10 -0
- package/dist/ini.js +4 -0
- package/dist/is-glob.d.ts +5 -0
- package/dist/is-glob.js +9 -0
- package/dist/json5.d.ts +12 -0
- package/dist/json5.js +4 -0
- package/dist/jsonc.d.ts +10 -0
- package/dist/jsonc.js +4 -0
- package/dist/match.d.ts +5 -0
- package/dist/match.js +15 -0
- package/dist/packem_shared/{WalkError-DUdQd6FT.js → WalkError-DER5A43G.js} +1 -1
- package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
- package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +12 -0
- package/dist/packem_shared/{collect-DcBwsYYd.js → collect-CqQ3eVab.js} +1 -1
- package/dist/packem_shared/{collectSync-Bkjf9Dbm.js → collectSync-noE08NNv.js} +1 -1
- package/dist/packem_shared/{emptyDir-CYB5Tict.js → emptyDir-DnwENOaV.js} +5 -2
- package/dist/packem_shared/{emptyDirSync-BD8-1Ytl.js → emptyDirSync-6WiHBo8a.js} +3 -1
- package/dist/packem_shared/{ensureDir-C_kuQ5Ik.js → ensureDir-DNlPftys.js} +2 -2
- package/dist/packem_shared/{ensureDirSync-CI5g-uBI.js → ensureDirSync-DcPZFMy5.js} +2 -2
- package/dist/packem_shared/{ensureFile-BUtXGlGT.js → ensureFile-BRQpUOUM.js} +2 -2
- package/dist/packem_shared/{ensureFileSync-C8hASR-1.js → ensureFileSync-SBY7A9-C.js} +2 -2
- package/dist/packem_shared/{ensureLink-BPnAG5-P.js → ensureLink-DJQeauEn.js} +4 -3
- package/dist/packem_shared/{ensureLinkSync-B-Z7X0ub.js → ensureLinkSync-D9RVAglV.js} +4 -3
- package/dist/packem_shared/{ensureSymlink-U5B6J0BN.js → ensureSymlink-CoRYDRwr.js} +10 -3
- package/dist/packem_shared/{ensureSymlinkSync-DHnZj-9F.js → ensureSymlinkSync-CFimFlgh.js} +10 -3
- package/dist/packem_shared/{findUp-BSnyGqer.js → findUp-YcNLKdfV.js} +3 -4
- package/dist/packem_shared/{findUpSync-jRHbSCMV.js → findUpSync-BfA5fheN.js} +1 -3
- package/dist/packem_shared/glob-DY8l7izD.js +5 -0
- package/dist/packem_shared/glob-sync.d-BlGjS68e.d.ts +4 -0
- package/dist/packem_shared/globSync-5P2KJf_g.js +5 -0
- package/dist/packem_shared/index-C8W8sfzP.js +830 -0
- package/dist/packem_shared/index-bhgnhm4u.js +167 -0
- package/dist/packem_shared/index-xe4o3cYi.js +1784 -0
- package/dist/packem_shared/{parseJson-C8xb-3LR.js → indexToLineColumn-BUb0GPKl-BF770uX7.js} +8 -68
- package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +251 -0
- package/dist/packem_shared/{isFsCaseSensitive-D-ayleCy.js → isFsCaseSensitive-DunL7Iry.js} +6 -6
- package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +10 -0
- package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +72 -0
- package/dist/packem_shared/parseJson-BIp89Xjo.js +63 -0
- package/dist/packem_shared/{readFileSync-6GEIrOnl.js → readFileSync-gm9yfIhh.js} +2 -1
- package/dist/packem_shared/readIni-CJ2xfpjB.js +10 -0
- package/dist/packem_shared/readIniSync-9LUjaSSp.js +10 -0
- package/dist/packem_shared/{readJson-vddQ97Ll.js → readJson-C_rwm-wq.js} +1 -1
- package/dist/packem_shared/readJson5-mBoTZppy.js +15 -0
- package/dist/packem_shared/readJson5Sync-8WS2yUok.js +15 -0
- package/dist/packem_shared/{readJsonSync-DzeAdYZl.js → readJsonSync-BMEmCcJ6.js} +2 -2
- package/dist/packem_shared/readJsonc-j-OS-APg.js +28 -0
- package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +16 -0
- package/dist/packem_shared/readToml-B2MHaSes.js +9 -0
- package/dist/packem_shared/readTomlSync-DNbK8NEb.js +9 -0
- package/dist/packem_shared/{readYamlSync-DMV4U-gi.js → readYamlSync-BKX-PAfq.js} +1 -1
- package/dist/packem_shared/{remove-_oDY3uKo.js → remove-C8_gl3jF.js} +2 -1
- package/dist/packem_shared/{removeSync-DETRj7Qn.js → removeSync-BJR_wTwN.js} +2 -1
- package/dist/packem_shared/{sanitize-lOzE6k2A.js → sanitize-BZoLN9Fg.js} +3 -3
- package/dist/packem_shared/types.d-CYpAhWov.d.ts +145 -0
- package/dist/packem_shared/{walk-BhTbpr3y.js → walk-CSZgCuDx.js} +19 -10
- package/dist/packem_shared/{walkSync-DDBq95s8.js → walkSync-C4Cy28xb.js} +25 -16
- package/dist/packem_shared/{writeFile-DSHERs0Z.js → writeFile-B8HX0JIQ.js} +1 -3
- package/dist/packem_shared/{writeFileSync-CJp1kXQR.js → writeFileSync-DB8vv8xR.js} +1 -3
- package/dist/packem_shared/writeIni-i55QrL8y.js +65 -0
- package/dist/packem_shared/writeIniSync-CLqJE5t3.js +64 -0
- package/dist/packem_shared/{writeJson-C0OfLDbe.js → writeJson-Bo7C2UHw.js} +1 -1
- package/dist/packem_shared/writeJson5-vVmHUQOd.js +53 -0
- package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +53 -0
- package/dist/packem_shared/{writeJsonSync-Cs21FE7v.js → writeJsonSync-BKZ_9Acr.js} +1 -1
- package/dist/packem_shared/writeJsonc-BufH_oC5.js +60 -0
- package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +59 -0
- package/dist/packem_shared/writeToml-DgTW_-7F.js +8 -0
- package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +8 -0
- package/dist/packem_shared/{writeYaml-n4xzYN9a.js → writeYaml-BWCOome-.js} +3 -3
- package/dist/packem_shared/{writeYamlSync-DnOEnP10.js → writeYamlSync-DBVnXmuY.js} +3 -3
- package/dist/size.d.ts +10 -254
- package/dist/size.js +6 -4
- package/dist/toml.d.ts +9 -0
- package/dist/toml.js +4 -0
- package/dist/utils.d.ts +15 -6
- package/dist/utils.js +1 -1
- package/dist/yaml.d.ts +14 -5
- package/dist/yaml.js +3 -3
- package/package.json +60 -6
- 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/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
|
@@ -23,7 +23,7 @@ const {
|
|
|
23
23
|
import { d as detectIndent } from './index-CHM-in-V.js';
|
|
24
24
|
import { R_OK } from './F_OK-MldBaGxb.js';
|
|
25
25
|
import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
|
|
26
|
-
import writeFileSync from './writeFileSync-
|
|
26
|
+
import writeFileSync from './writeFileSync-DB8vv8xR.js';
|
|
27
27
|
|
|
28
28
|
const writeJsonSync = (path, data, options = {}) => {
|
|
29
29
|
const { detectIndent: detectIndent$1, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: " ", ...options };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
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
|
+
readFile
|
|
22
|
+
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
23
|
+
import { d as detectIndent } from './index-CHM-in-V.js';
|
|
24
|
+
import { R_OK } from './F_OK-MldBaGxb.js';
|
|
25
|
+
import isAccessible from './isAccessible-DuVrTNFV.js';
|
|
26
|
+
import { b as buildJsoncOutput } from './jsonc-merge-C6jWcfWh.js';
|
|
27
|
+
import writeFile from './writeFile-B8HX0JIQ.js';
|
|
28
|
+
|
|
29
|
+
const readExisting = async (path, detectIndent$1, fallbackIndent) => {
|
|
30
|
+
let existingText;
|
|
31
|
+
let indent = fallbackIndent;
|
|
32
|
+
let trailingNewline = "\n";
|
|
33
|
+
const accessible = await isAccessible(path, R_OK);
|
|
34
|
+
if (!accessible) {
|
|
35
|
+
return { indent, trailingNewline };
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
existingText = await readFile(path, "utf8");
|
|
39
|
+
if (detectIndent$1) {
|
|
40
|
+
const { indent: detectedIndent } = detectIndent(existingText);
|
|
41
|
+
if (detectedIndent) {
|
|
42
|
+
indent = detectedIndent;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
trailingNewline = existingText.endsWith("\n") ? "\n" : "";
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (error.code !== "ENOENT") {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { existingText, indent, trailingNewline };
|
|
52
|
+
};
|
|
53
|
+
const writeJsonc = async (path, data, options = {}) => {
|
|
54
|
+
const { detectIndent, formattingOptions, indent: indentOption, preserveComments = true, replacer, ...writeOptions } = { indent: " ", ...options };
|
|
55
|
+
const { existingText, indent, trailingNewline } = await readExisting(path, detectIndent, indentOption);
|
|
56
|
+
const output = buildJsoncOutput(existingText, data, preserveComments, indent, trailingNewline, formattingOptions, replacer);
|
|
57
|
+
await writeFile(path, output, writeOptions);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { writeJsonc as default };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
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
|
+
} = __cjs_getBuiltinModule("node:fs");
|
|
23
|
+
import { d as detectIndent } from './index-CHM-in-V.js';
|
|
24
|
+
import { R_OK } from './F_OK-MldBaGxb.js';
|
|
25
|
+
import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
|
|
26
|
+
import { b as buildJsoncOutput } from './jsonc-merge-C6jWcfWh.js';
|
|
27
|
+
import writeFileSync from './writeFileSync-DB8vv8xR.js';
|
|
28
|
+
|
|
29
|
+
const readExistingSync = (path, detectIndent$1, fallbackIndent) => {
|
|
30
|
+
let existingText;
|
|
31
|
+
let indent = fallbackIndent;
|
|
32
|
+
let trailingNewline = "\n";
|
|
33
|
+
if (!isAccessibleSync(path, R_OK)) {
|
|
34
|
+
return { indent, trailingNewline };
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
existingText = readFileSync(path, "utf8");
|
|
38
|
+
if (detectIndent$1) {
|
|
39
|
+
const { indent: detectedIndent } = detectIndent(existingText);
|
|
40
|
+
if (detectedIndent) {
|
|
41
|
+
indent = detectedIndent;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
trailingNewline = existingText.endsWith("\n") ? "\n" : "";
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error.code !== "ENOENT") {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { existingText, indent, trailingNewline };
|
|
51
|
+
};
|
|
52
|
+
const writeJsoncSync = (path, data, options = {}) => {
|
|
53
|
+
const { detectIndent, formattingOptions, indent: indentOption, preserveComments = true, replacer, ...writeOptions } = { indent: " ", ...options };
|
|
54
|
+
const { existingText, indent, trailingNewline } = readExistingSync(path, detectIndent, indentOption);
|
|
55
|
+
const output = buildJsoncOutput(existingText, data, preserveComments, indent, trailingNewline, formattingOptions, replacer);
|
|
56
|
+
writeFileSync(path, output, writeOptions);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { writeJsoncSync as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stringify } from 'yaml';
|
|
2
|
-
import writeFile from './writeFile-
|
|
2
|
+
import writeFile from './writeFile-B8HX0JIQ.js';
|
|
3
3
|
|
|
4
4
|
async function writeYaml(path, data, replacer, options) {
|
|
5
5
|
let stringifyOptions;
|
|
@@ -9,10 +9,10 @@ async function writeYaml(path, data, replacer, options) {
|
|
|
9
9
|
stringifyOptions = replacer;
|
|
10
10
|
effectiveReplacer = stringifyOptions.replacer;
|
|
11
11
|
space = stringifyOptions.space;
|
|
12
|
-
} else if (typeof options === "object"
|
|
12
|
+
} else if (typeof options === "object") {
|
|
13
13
|
stringifyOptions = options;
|
|
14
14
|
effectiveReplacer = replacer;
|
|
15
|
-
space = stringifyOptions.space
|
|
15
|
+
space = stringifyOptions.space;
|
|
16
16
|
} else {
|
|
17
17
|
effectiveReplacer = replacer;
|
|
18
18
|
space = options;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stringify } from 'yaml';
|
|
2
|
-
import writeFileSync from './writeFileSync-
|
|
2
|
+
import writeFileSync from './writeFileSync-DB8vv8xR.js';
|
|
3
3
|
|
|
4
4
|
function writeYamlSync(path, data, replacer, options) {
|
|
5
5
|
let stringifyOptions;
|
|
@@ -9,10 +9,10 @@ function writeYamlSync(path, data, replacer, options) {
|
|
|
9
9
|
stringifyOptions = replacer;
|
|
10
10
|
effectiveReplacer = stringifyOptions.replacer;
|
|
11
11
|
space = stringifyOptions.space;
|
|
12
|
-
} else if (typeof options === "object"
|
|
12
|
+
} else if (typeof options === "object") {
|
|
13
13
|
stringifyOptions = options;
|
|
14
14
|
effectiveReplacer = replacer;
|
|
15
|
-
space = stringifyOptions.space
|
|
15
|
+
space = stringifyOptions.space;
|
|
16
16
|
} else {
|
|
17
17
|
effectiveReplacer = replacer;
|
|
18
18
|
space = options;
|
package/dist/size.d.ts
CHANGED
|
@@ -1,256 +1,12 @@
|
|
|
1
|
-
import { Readable } from
|
|
2
|
-
import { URL } from
|
|
3
|
-
import
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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/size.js
CHANGED
|
@@ -36,10 +36,10 @@ const {
|
|
|
36
36
|
URL
|
|
37
37
|
} = __cjs_getBuiltinModule("node:url");
|
|
38
38
|
const {
|
|
39
|
-
gzipSync,
|
|
40
39
|
brotliCompressSync,
|
|
41
|
-
|
|
42
|
-
createGzip
|
|
40
|
+
gzipSync,
|
|
41
|
+
createGzip,
|
|
42
|
+
createBrotliCompress
|
|
43
43
|
} = __cjs_getBuiltinModule("node:zlib");
|
|
44
44
|
import { toPath } from '@visulima/path/utils';
|
|
45
45
|
|
|
@@ -67,7 +67,9 @@ const getCompressedStreamSizeEfficient = async (stream, createCompressor) => {
|
|
|
67
67
|
compressor.on("data", (chunk) => {
|
|
68
68
|
totalSize += chunk.length;
|
|
69
69
|
});
|
|
70
|
-
compressor.on("end", () =>
|
|
70
|
+
compressor.on("end", () => {
|
|
71
|
+
resolve2(totalSize);
|
|
72
|
+
});
|
|
71
73
|
compressor.on("error", reject);
|
|
72
74
|
stream.on("error", reject);
|
|
73
75
|
stream.pipe(compressor);
|
package/dist/toml.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { a as CompressionType, h as ReadTomlOptions, i as WriteTomlOptions } from "./packem_shared/types.d-CYpAhWov.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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export { J as JSONError } from "./packem_shared/json-error.d-DgKaeuIf.js";
|
|
2
|
+
import { JsonValue } from 'type-fest';
|
|
3
|
+
import { C as CodeFrameOptions, J as JsonReviver } from "./packem_shared/types.d-CYpAhWov.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-
|
|
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
|
-
|
|
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-CYpAhWov.js";
|
|
2
|
+
export { type c as YamlReplacer } from "./packem_shared/types.d-CYpAhWov.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/dist/yaml.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as readYaml } from './packem_shared/readYaml-D5q2a0e1.js';
|
|
2
|
-
export { default as readYamlSync } from './packem_shared/readYamlSync-
|
|
3
|
-
export { default as writeYaml } from './packem_shared/writeYaml-
|
|
4
|
-
export { default as writeYamlSync } from './packem_shared/writeYamlSync-
|
|
2
|
+
export { default as readYamlSync } from './packem_shared/readYamlSync-BKX-PAfq.js';
|
|
3
|
+
export { default as writeYaml } from './packem_shared/writeYaml-BWCOome-.js';
|
|
4
|
+
export { default as writeYamlSync } from './packem_shared/writeYamlSync-DBVnXmuY.js';
|