@fuzdev/fuz_util 0.54.0 → 0.56.0
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/dist/args.d.ts +12 -12
- package/dist/args.js +11 -11
- package/dist/async.d.ts +12 -12
- package/dist/async.js +12 -12
- package/dist/benchmark.d.ts +24 -24
- package/dist/benchmark.js +26 -26
- package/dist/benchmark_baseline.d.ts +17 -11
- package/dist/benchmark_baseline.d.ts.map +1 -1
- package/dist/benchmark_baseline.js +26 -19
- package/dist/benchmark_format.d.ts +15 -15
- package/dist/benchmark_format.js +15 -15
- package/dist/benchmark_stats.d.ts +30 -10
- package/dist/benchmark_stats.d.ts.map +1 -1
- package/dist/benchmark_stats.js +48 -40
- package/dist/benchmark_types.d.ts +7 -7
- package/dist/bytes.d.ts +4 -4
- package/dist/bytes.js +4 -4
- package/dist/dag.d.ts +2 -2
- package/dist/dag.js +2 -2
- package/dist/deep_equal.d.ts +2 -2
- package/dist/deep_equal.js +2 -2
- package/dist/diff.d.ts +17 -17
- package/dist/diff.js +17 -17
- package/dist/dom.d.ts +4 -4
- package/dist/dom.js +4 -4
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.js +1 -1
- package/dist/git.d.ts +1 -1
- package/dist/git.js +1 -1
- package/dist/hash.d.ts +6 -6
- package/dist/hash.js +8 -8
- package/dist/hash_blake3.d.ts +1 -1
- package/dist/hash_blake3.js +1 -1
- package/dist/hex.d.ts +4 -4
- package/dist/hex.js +4 -4
- package/dist/json.d.ts +2 -2
- package/dist/json.js +2 -2
- package/dist/log.d.ts +12 -12
- package/dist/log.js +11 -11
- package/dist/map.d.ts +1 -1
- package/dist/map.js +1 -1
- package/dist/object.d.ts +1 -1
- package/dist/object.js +1 -1
- package/dist/package_json.d.ts +1 -1
- package/dist/package_json.js +1 -1
- package/dist/path.d.ts +5 -5
- package/dist/path.js +5 -5
- package/dist/process.d.ts +22 -22
- package/dist/process.js +22 -22
- package/dist/random.d.ts +2 -2
- package/dist/random.js +2 -2
- package/dist/result.d.ts +6 -6
- package/dist/result.js +6 -6
- package/dist/sort.d.ts +3 -3
- package/dist/sort.js +3 -3
- package/dist/source_json.d.ts +3 -3
- package/dist/source_json.js +3 -3
- package/dist/stats.d.ts +17 -17
- package/dist/stats.js +17 -17
- package/dist/string.d.ts +6 -6
- package/dist/string.js +6 -6
- package/dist/svelte_preprocess_helpers.d.ts +42 -42
- package/dist/svelte_preprocess_helpers.js +42 -42
- package/dist/testing.d.ts +44 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +59 -0
- package/dist/time.d.ts +19 -19
- package/dist/time.js +19 -19
- package/dist/zod.d.ts +16 -16
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +24 -24
- package/package.json +6 -6
- package/src/lib/args.ts +12 -12
- package/src/lib/async.ts +12 -12
- package/src/lib/benchmark.ts +28 -28
- package/src/lib/benchmark_baseline.ts +37 -20
- package/src/lib/benchmark_format.ts +15 -15
- package/src/lib/benchmark_stats.ts +66 -44
- package/src/lib/benchmark_types.ts +7 -7
- package/src/lib/bytes.ts +4 -4
- package/src/lib/dag.ts +2 -2
- package/src/lib/deep_equal.ts +2 -2
- package/src/lib/diff.ts +17 -17
- package/src/lib/dom.ts +4 -4
- package/src/lib/fetch.ts +1 -1
- package/src/lib/git.ts +1 -1
- package/src/lib/hash.ts +8 -8
- package/src/lib/hash_blake3.ts +1 -1
- package/src/lib/hex.ts +4 -4
- package/src/lib/json.ts +2 -2
- package/src/lib/log.ts +12 -12
- package/src/lib/map.ts +1 -1
- package/src/lib/object.ts +1 -1
- package/src/lib/package_json.ts +1 -1
- package/src/lib/path.ts +5 -5
- package/src/lib/process.ts +22 -22
- package/src/lib/random.ts +2 -2
- package/src/lib/result.ts +6 -6
- package/src/lib/sort.ts +3 -3
- package/src/lib/source_json.ts +3 -3
- package/src/lib/stats.ts +17 -17
- package/src/lib/string.ts +6 -6
- package/src/lib/svelte_preprocess_helpers.ts +42 -42
- package/src/lib/testing.ts +80 -0
- package/src/lib/time.ts +19 -19
- package/src/lib/zod.ts +24 -24
package/dist/diff.d.ts
CHANGED
|
@@ -11,17 +11,17 @@ export interface DiffLine {
|
|
|
11
11
|
/**
|
|
12
12
|
* Generate a line-based diff between two strings using LCS algorithm.
|
|
13
13
|
*
|
|
14
|
-
* @param a -
|
|
15
|
-
* @param b -
|
|
16
|
-
* @returns
|
|
14
|
+
* @param a - the original/current content
|
|
15
|
+
* @param b - the new/desired content
|
|
16
|
+
* @returns array of diff lines with type annotations
|
|
17
17
|
*/
|
|
18
18
|
export declare const diff_lines: (a: string, b: string) => Array<DiffLine>;
|
|
19
19
|
/**
|
|
20
20
|
* Filter diff to only include lines within N lines of context around changes.
|
|
21
21
|
*
|
|
22
|
-
* @param diff -
|
|
23
|
-
* @param context_lines -
|
|
24
|
-
* @returns
|
|
22
|
+
* @param diff - the full diff lines
|
|
23
|
+
* @param context_lines - number of context lines to show around changes (default: 3)
|
|
24
|
+
* @returns filtered diff with ellipsis markers for skipped regions
|
|
25
25
|
*/
|
|
26
26
|
export declare const filter_diff_context: (diff: Array<DiffLine>, context_lines?: number) => Array<DiffLine>;
|
|
27
27
|
/**
|
|
@@ -38,24 +38,24 @@ export interface FormatDiffOptions {
|
|
|
38
38
|
/**
|
|
39
39
|
* Format a diff for display.
|
|
40
40
|
*
|
|
41
|
-
* @param diff -
|
|
42
|
-
* @param current_path -
|
|
43
|
-
* @param desired_path -
|
|
44
|
-
* @param options -
|
|
45
|
-
* @returns
|
|
41
|
+
* @param diff - the diff lines to format
|
|
42
|
+
* @param current_path - path label for "current" content
|
|
43
|
+
* @param desired_path - path label for "desired" content
|
|
44
|
+
* @param options - formatting options
|
|
45
|
+
* @returns formatted diff string
|
|
46
46
|
*/
|
|
47
47
|
export declare const format_diff: (diff: Array<DiffLine>, current_path: string, desired_path: string, options?: FormatDiffOptions) => string;
|
|
48
48
|
/**
|
|
49
49
|
* Generate a formatted diff between two strings.
|
|
50
50
|
*
|
|
51
|
-
* Combines diff_lines
|
|
51
|
+
* Combines `diff_lines`, `filter_diff_context`, and `format_diff` for convenience.
|
|
52
52
|
* Returns null if content is binary.
|
|
53
53
|
*
|
|
54
|
-
* @param current -
|
|
55
|
-
* @param desired -
|
|
56
|
-
* @param path -
|
|
57
|
-
* @param options -
|
|
58
|
-
* @returns
|
|
54
|
+
* @param current - current content
|
|
55
|
+
* @param desired - desired content
|
|
56
|
+
* @param path - file path for labels
|
|
57
|
+
* @param options - formatting options
|
|
58
|
+
* @returns formatted diff string, or null if binary
|
|
59
59
|
*/
|
|
60
60
|
export declare const generate_diff: (current: string, desired: string, path: string, options?: FormatDiffOptions) => string | null;
|
|
61
61
|
//# sourceMappingURL=diff.d.ts.map
|
package/dist/diff.js
CHANGED
|
@@ -7,9 +7,9 @@ import { string_is_binary } from './string.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* Generate a line-based diff between two strings using LCS algorithm.
|
|
9
9
|
*
|
|
10
|
-
* @param a -
|
|
11
|
-
* @param b -
|
|
12
|
-
* @returns
|
|
10
|
+
* @param a - the original/current content
|
|
11
|
+
* @param b - the new/desired content
|
|
12
|
+
* @returns array of diff lines with type annotations
|
|
13
13
|
*/
|
|
14
14
|
export const diff_lines = (a, b) => {
|
|
15
15
|
const a_lines = a.split('\n');
|
|
@@ -84,9 +84,9 @@ const compute_lcs = (a, b) => {
|
|
|
84
84
|
/**
|
|
85
85
|
* Filter diff to only include lines within N lines of context around changes.
|
|
86
86
|
*
|
|
87
|
-
* @param diff -
|
|
88
|
-
* @param context_lines -
|
|
89
|
-
* @returns
|
|
87
|
+
* @param diff - the full diff lines
|
|
88
|
+
* @param context_lines - number of context lines to show around changes (default: 3)
|
|
89
|
+
* @returns filtered diff with ellipsis markers for skipped regions
|
|
90
90
|
*/
|
|
91
91
|
export const filter_diff_context = (diff, context_lines = 3) => {
|
|
92
92
|
if (diff.length === 0)
|
|
@@ -131,11 +131,11 @@ const colors = {
|
|
|
131
131
|
/**
|
|
132
132
|
* Format a diff for display.
|
|
133
133
|
*
|
|
134
|
-
* @param diff -
|
|
135
|
-
* @param current_path -
|
|
136
|
-
* @param desired_path -
|
|
137
|
-
* @param options -
|
|
138
|
-
* @returns
|
|
134
|
+
* @param diff - the diff lines to format
|
|
135
|
+
* @param current_path - path label for "current" content
|
|
136
|
+
* @param desired_path - path label for "desired" content
|
|
137
|
+
* @param options - formatting options
|
|
138
|
+
* @returns formatted diff string
|
|
139
139
|
*/
|
|
140
140
|
export const format_diff = (diff, current_path, desired_path, options = {}) => {
|
|
141
141
|
const { prefix = '', use_color = true, max_lines = 50 } = options;
|
|
@@ -165,14 +165,14 @@ export const format_diff = (diff, current_path, desired_path, options = {}) => {
|
|
|
165
165
|
/**
|
|
166
166
|
* Generate a formatted diff between two strings.
|
|
167
167
|
*
|
|
168
|
-
* Combines diff_lines
|
|
168
|
+
* Combines `diff_lines`, `filter_diff_context`, and `format_diff` for convenience.
|
|
169
169
|
* Returns null if content is binary.
|
|
170
170
|
*
|
|
171
|
-
* @param current -
|
|
172
|
-
* @param desired -
|
|
173
|
-
* @param path -
|
|
174
|
-
* @param options -
|
|
175
|
-
* @returns
|
|
171
|
+
* @param current - current content
|
|
172
|
+
* @param desired - desired content
|
|
173
|
+
* @param path - file path for labels
|
|
174
|
+
* @param options - formatting options
|
|
175
|
+
* @returns formatted diff string, or null if binary
|
|
176
176
|
*/
|
|
177
177
|
export const generate_diff = (current, desired, path, options = {}) => {
|
|
178
178
|
// Skip binary files
|
package/dist/dom.d.ts
CHANGED
|
@@ -15,11 +15,11 @@ export declare const inside_editable: (el: Element) => boolean;
|
|
|
15
15
|
export declare const is_interactive: (el: any) => boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Stops an event from bubbling and doing default behavior.
|
|
18
|
-
* @param event
|
|
19
|
-
* @param immediate defaults to `true` to use `stopImmediatePropagation` over `stopPropagation`
|
|
20
|
-
* @param preventDefault defaults to `true`
|
|
18
|
+
* @param event - the event to swallow
|
|
19
|
+
* @param immediate - defaults to `true` to use `stopImmediatePropagation` over `stopPropagation`
|
|
20
|
+
* @param preventDefault - defaults to `true`
|
|
21
|
+
* @returns the swallowed event
|
|
21
22
|
* @mutates event - calls preventDefault(), stopPropagation(), or stopImmediatePropagation()
|
|
22
|
-
* @returns
|
|
23
23
|
*/
|
|
24
24
|
export declare const swallow: <T extends Pick<Event, "preventDefault" | "stopPropagation" | "stopImmediatePropagation">>(event: T, immediate?: boolean, preventDefault?: boolean) => T;
|
|
25
25
|
/**
|
package/dist/dom.js
CHANGED
|
@@ -52,11 +52,11 @@ export const is_interactive = (el) => {
|
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
54
|
* Stops an event from bubbling and doing default behavior.
|
|
55
|
-
* @param event
|
|
56
|
-
* @param immediate defaults to `true` to use `stopImmediatePropagation` over `stopPropagation`
|
|
57
|
-
* @param preventDefault defaults to `true`
|
|
55
|
+
* @param event - the event to swallow
|
|
56
|
+
* @param immediate - defaults to `true` to use `stopImmediatePropagation` over `stopPropagation`
|
|
57
|
+
* @param preventDefault - defaults to `true`
|
|
58
|
+
* @returns the swallowed event
|
|
58
59
|
* @mutates event - calls preventDefault(), stopPropagation(), or stopImmediatePropagation()
|
|
59
|
-
* @returns
|
|
60
60
|
*/
|
|
61
61
|
export const swallow = (event, immediate = true, preventDefault = true) => {
|
|
62
62
|
if (preventDefault)
|
package/dist/fetch.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface FetchValueOptions<TValue, TParams = undefined> {
|
|
|
26
26
|
* (you can still provide headers directly)
|
|
27
27
|
*
|
|
28
28
|
* Unlike `fetch`, this throws on ratelimits (status code 429)
|
|
29
|
-
* to halt whatever is
|
|
29
|
+
* to halt whatever is happening in its tracks to avoid accidental abuse,
|
|
30
30
|
* but returns a `Result` in all other cases.
|
|
31
31
|
* Handling ratelimit headers with more sophistication gets tricky because behavior
|
|
32
32
|
* differs across services.
|
package/dist/fetch.js
CHANGED
|
@@ -14,7 +14,7 @@ const DEFAULT_GITHUB_API_VERSION_HEADER = '2022-11-28';
|
|
|
14
14
|
* (you can still provide headers directly)
|
|
15
15
|
*
|
|
16
16
|
* Unlike `fetch`, this throws on ratelimits (status code 429)
|
|
17
|
-
* to halt whatever is
|
|
17
|
+
* to halt whatever is happening in its tracks to avoid accidental abuse,
|
|
18
18
|
* but returns a `Result` in all other cases.
|
|
19
19
|
* Handling ratelimit headers with more sophistication gets tricky because behavior
|
|
20
20
|
* differs across services.
|
package/dist/git.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface GitWorkspaceStatus {
|
|
|
62
62
|
* Note: This implementation treats submodules the same as regular files.
|
|
63
63
|
* Submodule-specific status codes (lowercase m, ?) are interpreted as changes.
|
|
64
64
|
*
|
|
65
|
-
* @param stdout -
|
|
65
|
+
* @param stdout - the raw output from `git status --porcelain -z`
|
|
66
66
|
* @returns status object with flags for unstaged changes, staged changes, and untracked files
|
|
67
67
|
*/
|
|
68
68
|
export declare const git_parse_workspace_status: (stdout: string | null) => GitWorkspaceStatus;
|
package/dist/git.js
CHANGED
|
@@ -82,7 +82,7 @@ export const git_local_branch_exists = async (branch, options) => {
|
|
|
82
82
|
* Note: This implementation treats submodules the same as regular files.
|
|
83
83
|
* Submodule-specific status codes (lowercase m, ?) are interpreted as changes.
|
|
84
84
|
*
|
|
85
|
-
* @param stdout -
|
|
85
|
+
* @param stdout - the raw output from `git status --porcelain -z`
|
|
86
86
|
* @returns status object with flags for unstaged changes, staged changes, and untracked files
|
|
87
87
|
*/
|
|
88
88
|
export const git_parse_workspace_status = (stdout) => {
|
package/dist/hash.d.ts
CHANGED
|
@@ -11,28 +11,28 @@
|
|
|
11
11
|
* Computes a SHA-1 hash using Web Crypto API.
|
|
12
12
|
*
|
|
13
13
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
14
|
-
* @returns 40-character hexadecimal hash string
|
|
14
|
+
* @returns 40-character hexadecimal hash string
|
|
15
15
|
*/
|
|
16
16
|
export declare const hash_sha1: (data: BufferSource | string) => Promise<string>;
|
|
17
17
|
/**
|
|
18
18
|
* Computes a SHA-256 hash using Web Crypto API.
|
|
19
19
|
*
|
|
20
20
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
21
|
-
* @returns 64-character hexadecimal hash string
|
|
21
|
+
* @returns 64-character hexadecimal hash string
|
|
22
22
|
*/
|
|
23
23
|
export declare const hash_sha256: (data: BufferSource | string) => Promise<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Computes a SHA-384 hash using Web Crypto API.
|
|
26
26
|
*
|
|
27
27
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
28
|
-
* @returns 96-character hexadecimal hash string
|
|
28
|
+
* @returns 96-character hexadecimal hash string
|
|
29
29
|
*/
|
|
30
30
|
export declare const hash_sha384: (data: BufferSource | string) => Promise<string>;
|
|
31
31
|
/**
|
|
32
32
|
* Computes a SHA-512 hash using Web Crypto API.
|
|
33
33
|
*
|
|
34
34
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
35
|
-
* @returns 128-character hexadecimal hash string
|
|
35
|
+
* @returns 128-character hexadecimal hash string
|
|
36
36
|
*/
|
|
37
37
|
export declare const hash_sha512: (data: BufferSource | string) => Promise<string>;
|
|
38
38
|
/**
|
|
@@ -42,8 +42,8 @@ export declare const hash_sha512: (data: BufferSource | string) => Promise<strin
|
|
|
42
42
|
* Note: Strings use UTF-16 code units, buffers use raw bytes.
|
|
43
43
|
* For non-ASCII, `hash_insecure(str) !== hash_insecure(encoder.encode(str))`.
|
|
44
44
|
*
|
|
45
|
-
* @param data -
|
|
46
|
-
* @returns 8-character hex-encoded unsigned 32-bit hash
|
|
45
|
+
* @param data - string or binary data to hash
|
|
46
|
+
* @returns 8-character hex-encoded unsigned 32-bit hash
|
|
47
47
|
*/
|
|
48
48
|
export declare const hash_insecure: (data: BufferSource | string) => string;
|
|
49
49
|
//# sourceMappingURL=hash.d.ts.map
|
package/dist/hash.js
CHANGED
|
@@ -12,9 +12,9 @@ const encoder = new TextEncoder();
|
|
|
12
12
|
/**
|
|
13
13
|
* Computes a hash using Web Crypto API.
|
|
14
14
|
*
|
|
15
|
-
* @param algorithm - Web Crypto algorithm name (e.g. `'SHA-256'`)
|
|
15
|
+
* @param algorithm - Web Crypto algorithm name (e.g. `'SHA-256'`)
|
|
16
16
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
17
|
-
* @returns hexadecimal hash string
|
|
17
|
+
* @returns hexadecimal hash string
|
|
18
18
|
*/
|
|
19
19
|
const hash_webcrypto = async (algorithm, data) => {
|
|
20
20
|
const buffer = typeof data === 'string' ? encoder.encode(data) : data;
|
|
@@ -25,28 +25,28 @@ const hash_webcrypto = async (algorithm, data) => {
|
|
|
25
25
|
* Computes a SHA-1 hash using Web Crypto API.
|
|
26
26
|
*
|
|
27
27
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
28
|
-
* @returns 40-character hexadecimal hash string
|
|
28
|
+
* @returns 40-character hexadecimal hash string
|
|
29
29
|
*/
|
|
30
30
|
export const hash_sha1 = (data) => hash_webcrypto('SHA-1', data);
|
|
31
31
|
/**
|
|
32
32
|
* Computes a SHA-256 hash using Web Crypto API.
|
|
33
33
|
*
|
|
34
34
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
35
|
-
* @returns 64-character hexadecimal hash string
|
|
35
|
+
* @returns 64-character hexadecimal hash string
|
|
36
36
|
*/
|
|
37
37
|
export const hash_sha256 = (data) => hash_webcrypto('SHA-256', data);
|
|
38
38
|
/**
|
|
39
39
|
* Computes a SHA-384 hash using Web Crypto API.
|
|
40
40
|
*
|
|
41
41
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
42
|
-
* @returns 96-character hexadecimal hash string
|
|
42
|
+
* @returns 96-character hexadecimal hash string
|
|
43
43
|
*/
|
|
44
44
|
export const hash_sha384 = (data) => hash_webcrypto('SHA-384', data);
|
|
45
45
|
/**
|
|
46
46
|
* Computes a SHA-512 hash using Web Crypto API.
|
|
47
47
|
*
|
|
48
48
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
49
|
-
* @returns 128-character hexadecimal hash string
|
|
49
|
+
* @returns 128-character hexadecimal hash string
|
|
50
50
|
*/
|
|
51
51
|
export const hash_sha512 = (data) => hash_webcrypto('SHA-512', data);
|
|
52
52
|
/**
|
|
@@ -56,8 +56,8 @@ export const hash_sha512 = (data) => hash_webcrypto('SHA-512', data);
|
|
|
56
56
|
* Note: Strings use UTF-16 code units, buffers use raw bytes.
|
|
57
57
|
* For non-ASCII, `hash_insecure(str) !== hash_insecure(encoder.encode(str))`.
|
|
58
58
|
*
|
|
59
|
-
* @param data -
|
|
60
|
-
* @returns 8-character hex-encoded unsigned 32-bit hash
|
|
59
|
+
* @param data - string or binary data to hash
|
|
60
|
+
* @returns 8-character hex-encoded unsigned 32-bit hash
|
|
61
61
|
*/
|
|
62
62
|
export const hash_insecure = (data) => {
|
|
63
63
|
let hash = 5381; // DJB2 initial value, chosen empirically for good distribution
|
package/dist/hash_blake3.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const blake3_ready: Promise<void>;
|
|
|
18
18
|
* Computes a BLAKE3 hash synchronously.
|
|
19
19
|
*
|
|
20
20
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
21
|
-
* @returns 64-character hexadecimal hash string (32 bytes)
|
|
21
|
+
* @returns 64-character hexadecimal hash string (32 bytes)
|
|
22
22
|
*/
|
|
23
23
|
export declare const hash_blake3: (data: BufferSource | string) => string;
|
|
24
24
|
/** Zod schema for a BLAKE3 hex hash — 64 lowercase hex characters (256-bit output). */
|
package/dist/hash_blake3.js
CHANGED
|
@@ -21,7 +21,7 @@ export const blake3_ready = init();
|
|
|
21
21
|
* Computes a BLAKE3 hash synchronously.
|
|
22
22
|
*
|
|
23
23
|
* @param data - String or binary data to hash. Strings are UTF-8 encoded.
|
|
24
|
-
* @returns 64-character hexadecimal hash string (32 bytes)
|
|
24
|
+
* @returns 64-character hexadecimal hash string (32 bytes)
|
|
25
25
|
*/
|
|
26
26
|
export const hash_blake3 = (data) => to_hex(hash(to_bytes(data)));
|
|
27
27
|
/** Zod schema for a BLAKE3 hex hash — 64 lowercase hex characters (256-bit output). */
|
package/dist/hex.d.ts
CHANGED
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Converts a `Uint8Array` to a lowercase hex string.
|
|
8
8
|
*
|
|
9
|
-
* @param bytes -
|
|
10
|
-
* @returns
|
|
9
|
+
* @param bytes - binary data to encode
|
|
10
|
+
* @returns hex string with two characters per byte
|
|
11
11
|
*/
|
|
12
12
|
export declare const to_hex: (bytes: Uint8Array) => string;
|
|
13
13
|
/**
|
|
14
14
|
* Decodes a hex string to a `Uint8Array`.
|
|
15
15
|
* Whitespace is stripped before parsing. Returns `null` for invalid hex.
|
|
16
16
|
*
|
|
17
|
-
* @param hex -
|
|
18
|
-
* @returns
|
|
17
|
+
* @param hex - hex string to decode (case-insensitive, whitespace allowed)
|
|
18
|
+
* @returns decoded bytes, or `null` if the input is not valid hex
|
|
19
19
|
*/
|
|
20
20
|
export declare const from_hex: (hex: string) => Uint8Array | null;
|
|
21
21
|
//# sourceMappingURL=hex.d.ts.map
|
package/dist/hex.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Converts a `Uint8Array` to a lowercase hex string.
|
|
8
8
|
*
|
|
9
|
-
* @param bytes -
|
|
10
|
-
* @returns
|
|
9
|
+
* @param bytes - binary data to encode
|
|
10
|
+
* @returns hex string with two characters per byte
|
|
11
11
|
*/
|
|
12
12
|
export const to_hex = (bytes) => {
|
|
13
13
|
const lookup = get_byte_to_hex();
|
|
@@ -21,8 +21,8 @@ export const to_hex = (bytes) => {
|
|
|
21
21
|
* Decodes a hex string to a `Uint8Array`.
|
|
22
22
|
* Whitespace is stripped before parsing. Returns `null` for invalid hex.
|
|
23
23
|
*
|
|
24
|
-
* @param hex -
|
|
25
|
-
* @returns
|
|
24
|
+
* @param hex - hex string to decode (case-insensitive, whitespace allowed)
|
|
25
|
+
* @returns decoded bytes, or `null` if the input is not valid hex
|
|
26
26
|
*/
|
|
27
27
|
export const from_hex = (hex) => {
|
|
28
28
|
const clean = hex.replace(/\s/g, '');
|
package/dist/json.d.ts
CHANGED
|
@@ -23,8 +23,8 @@ export declare const json_embed: <T>(data: T, stringify?: (data: T) => string) =
|
|
|
23
23
|
* Recursively sorts object keys alphabetically for consistent hashing.
|
|
24
24
|
* Arrays and primitives are serialized as-is.
|
|
25
25
|
*
|
|
26
|
-
* @param value
|
|
27
|
-
* @returns
|
|
26
|
+
* @param value - any JSON-serializable value
|
|
27
|
+
* @returns deterministic JSON string representation
|
|
28
28
|
*/
|
|
29
29
|
export declare const json_stringify_deterministic: (value: unknown) => string;
|
|
30
30
|
//# sourceMappingURL=json.d.ts.map
|
package/dist/json.js
CHANGED
|
@@ -28,8 +28,8 @@ export const json_embed = (data, stringify = JSON.stringify) => `JSON.parse('${s
|
|
|
28
28
|
* Recursively sorts object keys alphabetically for consistent hashing.
|
|
29
29
|
* Arrays and primitives are serialized as-is.
|
|
30
30
|
*
|
|
31
|
-
* @param value
|
|
32
|
-
* @returns
|
|
31
|
+
* @param value - any JSON-serializable value
|
|
32
|
+
* @returns deterministic JSON string representation
|
|
33
33
|
*/
|
|
34
34
|
export const json_stringify_deterministic = (value) => JSON.stringify(value, (_key, val) => {
|
|
35
35
|
if (val !== null && typeof val === 'object' && !Array.isArray(val)) {
|
package/dist/log.d.ts
CHANGED
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
|
|
10
10
|
/**
|
|
11
|
-
* Console interface subset used by Logger for output.
|
|
11
|
+
* Console interface subset used by `Logger` for output.
|
|
12
12
|
* Allows custom console implementations for testing.
|
|
13
13
|
*/
|
|
14
14
|
export type LogConsole = Pick<typeof console, 'error' | 'warn' | 'log'>;
|
|
15
15
|
/**
|
|
16
16
|
* Converts a log level to its numeric value for comparison.
|
|
17
17
|
* Higher numbers indicate more verbose logging.
|
|
18
|
-
* @param level
|
|
19
|
-
* @returns
|
|
18
|
+
* @param level - the log level to convert
|
|
19
|
+
* @returns numeric value (0-4)
|
|
20
20
|
*/
|
|
21
21
|
export declare const log_level_to_number: (level: LogLevel) => number;
|
|
22
22
|
/**
|
|
23
23
|
* Parses and validates a log level string.
|
|
24
|
-
* @param value
|
|
25
|
-
* @returns
|
|
24
|
+
* @param value - the value to parse as a log level
|
|
25
|
+
* @returns the validated log level, or undefined if value is undefined
|
|
26
26
|
* @throws Error if value is provided but invalid
|
|
27
27
|
*/
|
|
28
28
|
export declare const log_level_parse: (value: string | undefined) => LogLevel | undefined;
|
|
@@ -56,10 +56,10 @@ export declare class Logger {
|
|
|
56
56
|
/**
|
|
57
57
|
* Creates a new Logger instance.
|
|
58
58
|
*
|
|
59
|
-
* @param label
|
|
59
|
+
* @param label - optional label for this logger. Can be `undefined` for no label, or an
|
|
60
60
|
* empty string `''` which is functionally equivalent (both produce no brackets in output).
|
|
61
61
|
* Note: Empty strings are only allowed for root loggers - child loggers cannot have empty labels.
|
|
62
|
-
* @param options
|
|
62
|
+
* @param options - optional configuration for level, colors, and console
|
|
63
63
|
*/
|
|
64
64
|
constructor(label?: string, options?: LoggerOptions);
|
|
65
65
|
/**
|
|
@@ -93,7 +93,7 @@ export declare class Logger {
|
|
|
93
93
|
/**
|
|
94
94
|
* Gets the root logger by walking up the parent chain.
|
|
95
95
|
* Useful for setting global configuration that affects all child loggers.
|
|
96
|
-
* @returns
|
|
96
|
+
* @returns the root logger (the one without a parent)
|
|
97
97
|
*/
|
|
98
98
|
get root(): Logger;
|
|
99
99
|
/**
|
|
@@ -118,11 +118,11 @@ export declare class Logger {
|
|
|
118
118
|
* Creates a child logger with automatic label concatenation.
|
|
119
119
|
* Children inherit parent configuration unless overridden.
|
|
120
120
|
*
|
|
121
|
-
* @param label
|
|
121
|
+
* @param label - child label (will be concatenated with parent label using `:`)
|
|
122
122
|
* Cannot be an empty string - empty labels would result in confusing output like `parent:`
|
|
123
123
|
* with a trailing colon. Use `undefined` or `''` only for root loggers.
|
|
124
|
-
* @param options
|
|
125
|
-
* @returns
|
|
124
|
+
* @param options - optional configuration overrides
|
|
125
|
+
* @returns new `Logger` instance with concatenated label
|
|
126
126
|
* @throws Error if label is an empty string
|
|
127
127
|
*
|
|
128
128
|
* @example
|
|
@@ -163,7 +163,7 @@ export declare class Logger {
|
|
|
163
163
|
* Note: This method ignores the configured log level - it always outputs regardless of
|
|
164
164
|
* whether the logger is set to 'off' or any other level.
|
|
165
165
|
*
|
|
166
|
-
* @param args
|
|
166
|
+
* @param args - values to log directly to console
|
|
167
167
|
*/
|
|
168
168
|
raw(...args: Array<unknown>): void;
|
|
169
169
|
}
|
package/dist/log.js
CHANGED
|
@@ -22,14 +22,14 @@ const LOG_LEVEL_VALUES = {
|
|
|
22
22
|
/**
|
|
23
23
|
* Converts a log level to its numeric value for comparison.
|
|
24
24
|
* Higher numbers indicate more verbose logging.
|
|
25
|
-
* @param level
|
|
26
|
-
* @returns
|
|
25
|
+
* @param level - the log level to convert
|
|
26
|
+
* @returns numeric value (0-4)
|
|
27
27
|
*/
|
|
28
28
|
export const log_level_to_number = (level) => LOG_LEVEL_VALUES[level];
|
|
29
29
|
/**
|
|
30
30
|
* Parses and validates a log level string.
|
|
31
|
-
* @param value
|
|
32
|
-
* @returns
|
|
31
|
+
* @param value - the value to parse as a log level
|
|
32
|
+
* @returns the validated log level, or undefined if value is undefined
|
|
33
33
|
* @throws Error if value is provided but invalid
|
|
34
34
|
*/
|
|
35
35
|
export const log_level_parse = (value) => {
|
|
@@ -85,10 +85,10 @@ export class Logger {
|
|
|
85
85
|
/**
|
|
86
86
|
* Creates a new Logger instance.
|
|
87
87
|
*
|
|
88
|
-
* @param label
|
|
88
|
+
* @param label - optional label for this logger. Can be `undefined` for no label, or an
|
|
89
89
|
* empty string `''` which is functionally equivalent (both produce no brackets in output).
|
|
90
90
|
* Note: Empty strings are only allowed for root loggers - child loggers cannot have empty labels.
|
|
91
|
-
* @param options
|
|
91
|
+
* @param options - optional configuration for level, colors, and console
|
|
92
92
|
*/
|
|
93
93
|
constructor(label, options = {}) {
|
|
94
94
|
this.label = label;
|
|
@@ -169,7 +169,7 @@ export class Logger {
|
|
|
169
169
|
/**
|
|
170
170
|
* Gets the root logger by walking up the parent chain.
|
|
171
171
|
* Useful for setting global configuration that affects all child loggers.
|
|
172
|
-
* @returns
|
|
172
|
+
* @returns the root logger (the one without a parent)
|
|
173
173
|
*/
|
|
174
174
|
get root() {
|
|
175
175
|
let current = this; // eslint-disable-line consistent-this, @typescript-eslint/no-this-alias
|
|
@@ -313,11 +313,11 @@ export class Logger {
|
|
|
313
313
|
* Creates a child logger with automatic label concatenation.
|
|
314
314
|
* Children inherit parent configuration unless overridden.
|
|
315
315
|
*
|
|
316
|
-
* @param label
|
|
316
|
+
* @param label - child label (will be concatenated with parent label using `:`)
|
|
317
317
|
* Cannot be an empty string - empty labels would result in confusing output like `parent:`
|
|
318
318
|
* with a trailing colon. Use `undefined` or `''` only for root loggers.
|
|
319
|
-
* @param options
|
|
320
|
-
* @returns
|
|
319
|
+
* @param options - optional configuration overrides
|
|
320
|
+
* @returns new `Logger` instance with concatenated label
|
|
321
321
|
* @throws Error if label is an empty string
|
|
322
322
|
*
|
|
323
323
|
* @example
|
|
@@ -391,7 +391,7 @@ export class Logger {
|
|
|
391
391
|
* Note: This method ignores the configured log level - it always outputs regardless of
|
|
392
392
|
* whether the logger is set to 'off' or any other level.
|
|
393
393
|
*
|
|
394
|
-
* @param args
|
|
394
|
+
* @param args - values to log directly to console
|
|
395
395
|
*/
|
|
396
396
|
raw(...args) {
|
|
397
397
|
this.console.log(...args);
|
package/dist/map.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sorts a map by `comparator`, a function that compares two entries,
|
|
3
|
-
* defaulting to using `
|
|
3
|
+
* defaulting to using `localeCompare` and `>`.
|
|
4
4
|
*/
|
|
5
5
|
export declare const sort_map: <T extends Map<any, any>>(map: T, comparator?: (a: [any, any], b: [any, any]) => number) => T;
|
|
6
6
|
/**
|
package/dist/map.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sorts a map by `comparator`, a function that compares two entries,
|
|
3
|
-
* defaulting to using `
|
|
3
|
+
* defaulting to using `localeCompare` and `>`.
|
|
4
4
|
*/
|
|
5
5
|
export const sort_map = (map, comparator = compare_simple_map_entries) => new Map([...map].sort(comparator));
|
|
6
6
|
/**
|
package/dist/object.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare const pick_by: <T extends Record<K, any>, K extends string | numb
|
|
|
23
23
|
* `omit_undefined` is a commonly used form of `pick_by`.
|
|
24
24
|
* See this issue for why it's used so much:
|
|
25
25
|
* https://github.com/Microsoft/TypeScript/issues/13195
|
|
26
|
-
* @param obj
|
|
26
|
+
* @param obj - the object to filter
|
|
27
27
|
* @returns `obj` with all `undefined` properties removed
|
|
28
28
|
*/
|
|
29
29
|
export declare const omit_undefined: <T extends Record<string | number, any>>(obj: T) => T;
|
package/dist/object.js
CHANGED
|
@@ -45,7 +45,7 @@ export const pick_by = (obj, should_pick) => {
|
|
|
45
45
|
* `omit_undefined` is a commonly used form of `pick_by`.
|
|
46
46
|
* See this issue for why it's used so much:
|
|
47
47
|
* https://github.com/Microsoft/TypeScript/issues/13195
|
|
48
|
-
* @param obj
|
|
48
|
+
* @param obj - the object to filter
|
|
49
49
|
* @returns `obj` with all `undefined` properties removed
|
|
50
50
|
*/
|
|
51
51
|
export const omit_undefined = (obj) => pick_by(obj, (v) => v !== undefined);
|
package/dist/package_json.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type PackageJsonExports = z.infer<typeof PackageJsonExports>;
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const PackageJson: z.ZodObject<{
|
|
33
33
|
name: z.ZodString;
|
|
34
|
-
version: z.ZodString
|
|
34
|
+
version: z.ZodOptional<z.ZodString>;
|
|
35
35
|
private: z.ZodOptional<z.ZodBoolean>;
|
|
36
36
|
description: z.ZodOptional<z.ZodString>;
|
|
37
37
|
tagline: z.ZodOptional<z.ZodString>;
|
package/dist/package_json.js
CHANGED
|
@@ -49,7 +49,7 @@ export const PackageJsonExports = z.union([
|
|
|
49
49
|
export const PackageJson = z.looseObject({
|
|
50
50
|
// according to the npm docs, `name` and `version` are the only required properties
|
|
51
51
|
name: z.string(),
|
|
52
|
-
version: z.string(),
|
|
52
|
+
version: z.string().optional(),
|
|
53
53
|
private: z
|
|
54
54
|
.boolean()
|
|
55
55
|
.meta({ description: 'disallow publishing to the configured registry' })
|
package/dist/path.d.ts
CHANGED
|
@@ -65,15 +65,15 @@ export declare const parse_path_pieces: (raw_path: string) => Array<PathPiece>;
|
|
|
65
65
|
* Returns `false` when `filename` is `undefined`, empty string, or `exclude` is empty.
|
|
66
66
|
* String patterns use substring matching. RegExp patterns use `.test()`.
|
|
67
67
|
*
|
|
68
|
-
* @param filename
|
|
69
|
-
* @param exclude
|
|
70
|
-
* @returns `true` if the file should be excluded from processing
|
|
68
|
+
* @param filename - the file path to check, or `undefined` for virtual files
|
|
69
|
+
* @param exclude - array of string or RegExp exclusion patterns
|
|
70
|
+
* @returns `true` if the file should be excluded from processing
|
|
71
71
|
*/
|
|
72
72
|
export declare const should_exclude_path: (filename: string | undefined, exclude: Array<string | RegExp>) => boolean;
|
|
73
73
|
/**
|
|
74
74
|
* Converts a string into a URL-compatible slug.
|
|
75
|
-
* @param str the string to convert
|
|
76
|
-
* @param map_special_characters if `true`, characters like `ñ` are converted to their ASCII equivalents, runs around 5x faster when disabled
|
|
75
|
+
* @param str - the string to convert
|
|
76
|
+
* @param map_special_characters - if `true`, characters like `ñ` are converted to their ASCII equivalents, runs around 5x faster when disabled
|
|
77
77
|
* @mutates special_char_mappers - calls `get_special_char_mappers()` which lazily initializes the module-level array if `map_special_characters` is true
|
|
78
78
|
*/
|
|
79
79
|
export declare const slugify: (str: string, map_special_characters?: boolean) => string;
|
package/dist/path.js
CHANGED
|
@@ -54,9 +54,9 @@ export const parse_path_pieces = (raw_path) => {
|
|
|
54
54
|
* Returns `false` when `filename` is `undefined`, empty string, or `exclude` is empty.
|
|
55
55
|
* String patterns use substring matching. RegExp patterns use `.test()`.
|
|
56
56
|
*
|
|
57
|
-
* @param filename
|
|
58
|
-
* @param exclude
|
|
59
|
-
* @returns `true` if the file should be excluded from processing
|
|
57
|
+
* @param filename - the file path to check, or `undefined` for virtual files
|
|
58
|
+
* @param exclude - array of string or RegExp exclusion patterns
|
|
59
|
+
* @returns `true` if the file should be excluded from processing
|
|
60
60
|
*/
|
|
61
61
|
export const should_exclude_path = (filename, exclude) => {
|
|
62
62
|
if (!filename || exclude.length === 0)
|
|
@@ -65,8 +65,8 @@ export const should_exclude_path = (filename, exclude) => {
|
|
|
65
65
|
};
|
|
66
66
|
/**
|
|
67
67
|
* Converts a string into a URL-compatible slug.
|
|
68
|
-
* @param str the string to convert
|
|
69
|
-
* @param map_special_characters if `true`, characters like `ñ` are converted to their ASCII equivalents, runs around 5x faster when disabled
|
|
68
|
+
* @param str - the string to convert
|
|
69
|
+
* @param map_special_characters - if `true`, characters like `ñ` are converted to their ASCII equivalents, runs around 5x faster when disabled
|
|
70
70
|
* @mutates special_char_mappers - calls `get_special_char_mappers()` which lazily initializes the module-level array if `map_special_characters` is true
|
|
71
71
|
*/
|
|
72
72
|
export const slugify = (str, map_special_characters = true) => {
|