@fuzdev/fuz_util 0.55.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 +11 -11
- package/dist/benchmark_baseline.js +11 -11
- package/dist/benchmark_format.d.ts +15 -15
- package/dist/benchmark_format.js +15 -15
- package/dist/benchmark_stats.d.ts +5 -5
- package/dist/benchmark_stats.js +5 -5
- 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 +11 -11
- package/src/lib/benchmark_format.ts +15 -15
- package/src/lib/benchmark_stats.ts +5 -5
- 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/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) => {
|
package/dist/process.d.ts
CHANGED
|
@@ -138,20 +138,20 @@ export declare class ProcessRegistry {
|
|
|
138
138
|
* Spawns a process and tracks it in this registry.
|
|
139
139
|
* The process is automatically unregistered when it exits.
|
|
140
140
|
*
|
|
141
|
-
* @param command -
|
|
142
|
-
* @param args -
|
|
143
|
-
* @param options -
|
|
144
|
-
* @returns
|
|
141
|
+
* @param command - the command to run
|
|
142
|
+
* @param args - arguments to pass to the command
|
|
143
|
+
* @param options - spawn options including `signal` and `timeout_ms`
|
|
144
|
+
* @returns handle with `child` process and `closed` promise
|
|
145
145
|
*/
|
|
146
146
|
spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnProcessOptions): SpawnedProcess;
|
|
147
147
|
/**
|
|
148
148
|
* Spawns a process and captures stdout/stderr as strings.
|
|
149
149
|
* Sets `stdio: 'pipe'` automatically.
|
|
150
150
|
*
|
|
151
|
-
* @param command -
|
|
152
|
-
* @param args -
|
|
153
|
-
* @param options -
|
|
154
|
-
* @returns
|
|
151
|
+
* @param command - the command to run
|
|
152
|
+
* @param args - arguments to pass to the command
|
|
153
|
+
* @param options - spawn options
|
|
154
|
+
* @returns result with captured `stdout` and `stderr`
|
|
155
155
|
* - `null` means spawn failed (ENOENT, etc.) or stream was unavailable
|
|
156
156
|
* - `''` (empty string) means process ran but produced no output
|
|
157
157
|
* - non-empty string contains the captured output
|
|
@@ -160,16 +160,16 @@ export declare class ProcessRegistry {
|
|
|
160
160
|
/**
|
|
161
161
|
* Kills a child process and waits for it to exit.
|
|
162
162
|
*
|
|
163
|
-
* @param child -
|
|
164
|
-
* @param options -
|
|
165
|
-
* @returns
|
|
163
|
+
* @param child - the child process to kill
|
|
164
|
+
* @param options - kill options including signal and timeout
|
|
165
|
+
* @returns the spawn result after the process exits
|
|
166
166
|
*/
|
|
167
167
|
despawn(child: ChildProcess, options?: DespawnOptions): Promise<SpawnResult>;
|
|
168
168
|
/**
|
|
169
169
|
* Kills all processes in this registry.
|
|
170
170
|
*
|
|
171
|
-
* @param options -
|
|
172
|
-
* @returns
|
|
171
|
+
* @param options - kill options applied to all processes
|
|
172
|
+
* @returns array of spawn results
|
|
173
173
|
*/
|
|
174
174
|
despawn_all(options?: DespawnOptions): Promise<Array<SpawnResult>>;
|
|
175
175
|
/**
|
|
@@ -184,14 +184,14 @@ export declare class ProcessRegistry {
|
|
|
184
184
|
* graceful shutdown uses a blocking busy-wait. This may not be sufficient
|
|
185
185
|
* for processes that need significant cleanup time.
|
|
186
186
|
*
|
|
187
|
-
* @param options -
|
|
187
|
+
* @param options - configuration options
|
|
188
188
|
* @param options.to_error_label - Customize error label, return `null` for default
|
|
189
189
|
* @param options.map_error_text - Customize error text, return `''` to silence
|
|
190
190
|
* @param options.handle_error - Called after cleanup, defaults to `process.exit(1)`
|
|
191
191
|
* @param options.graceful_timeout_ms - If set, sends SIGTERM first and waits this
|
|
192
192
|
* many ms before SIGKILL. Recommended: 100-500ms. If null/undefined, uses
|
|
193
193
|
* immediate SIGKILL (default).
|
|
194
|
-
* @returns
|
|
194
|
+
* @returns cleanup function to remove the handler
|
|
195
195
|
*/
|
|
196
196
|
attach_error_handler(options?: {
|
|
197
197
|
to_error_label?: (err: Error, origin: NodeJS.UncaughtExceptionOrigin) => string | null;
|
|
@@ -256,19 +256,19 @@ export declare const despawn_all: (options?: DespawnOptions) => Promise<Array<Sp
|
|
|
256
256
|
/**
|
|
257
257
|
* Attaches an `uncaughtException` handler to the default registry.
|
|
258
258
|
*
|
|
259
|
-
* @see ProcessRegistry.attach_error_handler
|
|
259
|
+
* @see `ProcessRegistry.attach_error_handler`
|
|
260
260
|
*/
|
|
261
261
|
export declare const attach_process_error_handler: (options?: Parameters<ProcessRegistry["attach_error_handler"]>[0]) => (() => void);
|
|
262
262
|
/**
|
|
263
263
|
* Spawns a detached process that continues after parent exits.
|
|
264
264
|
*
|
|
265
|
-
* Unlike other spawn functions, this is NOT tracked in any ProcessRegistry
|
|
265
|
+
* Unlike other spawn functions, this is NOT tracked in any `ProcessRegistry`.
|
|
266
266
|
* The spawned process is meant to outlive the parent (e.g., daemon processes).
|
|
267
267
|
*
|
|
268
|
-
* @param command -
|
|
269
|
-
* @param args -
|
|
270
|
-
* @param options -
|
|
271
|
-
* @returns
|
|
268
|
+
* @param command - the command to run
|
|
269
|
+
* @param args - arguments to pass to the command
|
|
270
|
+
* @param options - spawn options (use `stdio` to redirect output to file descriptors)
|
|
271
|
+
* @returns result with pid on success, or error message on failure
|
|
272
272
|
*
|
|
273
273
|
* @example
|
|
274
274
|
* ```ts
|
|
@@ -381,7 +381,7 @@ export declare const spawn_restartable_process: (command: string, args?: Readonl
|
|
|
381
381
|
* Checks if a process with the given PID is running.
|
|
382
382
|
* Uses signal 0 which checks existence without sending a signal.
|
|
383
383
|
*
|
|
384
|
-
* @param pid -
|
|
384
|
+
* @param pid - the process ID to check (must be a positive integer)
|
|
385
385
|
* @returns `true` if the process exists (even without permission to signal it),
|
|
386
386
|
* `false` if the process doesn't exist or if pid is invalid (non-positive, non-integer, NaN, Infinity)
|
|
387
387
|
*/
|
package/dist/process.js
CHANGED
|
@@ -111,10 +111,10 @@ export class ProcessRegistry {
|
|
|
111
111
|
* Spawns a process and tracks it in this registry.
|
|
112
112
|
* The process is automatically unregistered when it exits.
|
|
113
113
|
*
|
|
114
|
-
* @param command -
|
|
115
|
-
* @param args -
|
|
116
|
-
* @param options -
|
|
117
|
-
* @returns
|
|
114
|
+
* @param command - the command to run
|
|
115
|
+
* @param args - arguments to pass to the command
|
|
116
|
+
* @param options - spawn options including `signal` and `timeout_ms`
|
|
117
|
+
* @returns handle with `child` process and `closed` promise
|
|
118
118
|
*/
|
|
119
119
|
spawn(command, args = [], options) {
|
|
120
120
|
const { signal, timeout_ms, spawn_child_process = node_spawn_child_process, ...spawn_options } = options ?? {};
|
|
@@ -141,10 +141,10 @@ export class ProcessRegistry {
|
|
|
141
141
|
* Spawns a process and captures stdout/stderr as strings.
|
|
142
142
|
* Sets `stdio: 'pipe'` automatically.
|
|
143
143
|
*
|
|
144
|
-
* @param command -
|
|
145
|
-
* @param args -
|
|
146
|
-
* @param options -
|
|
147
|
-
* @returns
|
|
144
|
+
* @param command - the command to run
|
|
145
|
+
* @param args - arguments to pass to the command
|
|
146
|
+
* @param options - spawn options
|
|
147
|
+
* @returns result with captured `stdout` and `stderr`
|
|
148
148
|
* - `null` means spawn failed (ENOENT, etc.) or stream was unavailable
|
|
149
149
|
* - `''` (empty string) means process ran but produced no output
|
|
150
150
|
* - non-empty string contains the captured output
|
|
@@ -178,9 +178,9 @@ export class ProcessRegistry {
|
|
|
178
178
|
/**
|
|
179
179
|
* Kills a child process and waits for it to exit.
|
|
180
180
|
*
|
|
181
|
-
* @param child -
|
|
182
|
-
* @param options -
|
|
183
|
-
* @returns
|
|
181
|
+
* @param child - the child process to kill
|
|
182
|
+
* @param options - kill options including signal and timeout
|
|
183
|
+
* @returns the spawn result after the process exits
|
|
184
184
|
*/
|
|
185
185
|
async despawn(child, options) {
|
|
186
186
|
const { signal = 'SIGTERM', timeout_ms } = options ?? {};
|
|
@@ -218,8 +218,8 @@ export class ProcessRegistry {
|
|
|
218
218
|
/**
|
|
219
219
|
* Kills all processes in this registry.
|
|
220
220
|
*
|
|
221
|
-
* @param options -
|
|
222
|
-
* @returns
|
|
221
|
+
* @param options - kill options applied to all processes
|
|
222
|
+
* @returns array of spawn results
|
|
223
223
|
*/
|
|
224
224
|
async despawn_all(options) {
|
|
225
225
|
return Promise.all([...this.processes].map((child) => this.despawn(child, options)));
|
|
@@ -236,14 +236,14 @@ export class ProcessRegistry {
|
|
|
236
236
|
* graceful shutdown uses a blocking busy-wait. This may not be sufficient
|
|
237
237
|
* for processes that need significant cleanup time.
|
|
238
238
|
*
|
|
239
|
-
* @param options -
|
|
239
|
+
* @param options - configuration options
|
|
240
240
|
* @param options.to_error_label - Customize error label, return `null` for default
|
|
241
241
|
* @param options.map_error_text - Customize error text, return `''` to silence
|
|
242
242
|
* @param options.handle_error - Called after cleanup, defaults to `process.exit(1)`
|
|
243
243
|
* @param options.graceful_timeout_ms - If set, sends SIGTERM first and waits this
|
|
244
244
|
* many ms before SIGKILL. Recommended: 100-500ms. If null/undefined, uses
|
|
245
245
|
* immediate SIGKILL (default).
|
|
246
|
-
* @returns
|
|
246
|
+
* @returns cleanup function to remove the handler
|
|
247
247
|
*/
|
|
248
248
|
attach_error_handler(options) {
|
|
249
249
|
if (this.#error_handler) {
|
|
@@ -348,19 +348,19 @@ export const despawn_all = (options) => process_registry_default.despawn_all(opt
|
|
|
348
348
|
/**
|
|
349
349
|
* Attaches an `uncaughtException` handler to the default registry.
|
|
350
350
|
*
|
|
351
|
-
* @see ProcessRegistry.attach_error_handler
|
|
351
|
+
* @see `ProcessRegistry.attach_error_handler`
|
|
352
352
|
*/
|
|
353
353
|
export const attach_process_error_handler = (options) => process_registry_default.attach_error_handler(options);
|
|
354
354
|
/**
|
|
355
355
|
* Spawns a detached process that continues after parent exits.
|
|
356
356
|
*
|
|
357
|
-
* Unlike other spawn functions, this is NOT tracked in any ProcessRegistry
|
|
357
|
+
* Unlike other spawn functions, this is NOT tracked in any `ProcessRegistry`.
|
|
358
358
|
* The spawned process is meant to outlive the parent (e.g., daemon processes).
|
|
359
359
|
*
|
|
360
|
-
* @param command -
|
|
361
|
-
* @param args -
|
|
362
|
-
* @param options -
|
|
363
|
-
* @returns
|
|
360
|
+
* @param command - the command to run
|
|
361
|
+
* @param args - arguments to pass to the command
|
|
362
|
+
* @param options - spawn options (use `stdio` to redirect output to file descriptors)
|
|
363
|
+
* @returns result with pid on success, or error message on failure
|
|
364
364
|
*
|
|
365
365
|
* @example
|
|
366
366
|
* ```ts
|
|
@@ -556,7 +556,7 @@ export const spawn_restartable_process = (command, args = [], options) => {
|
|
|
556
556
|
* Checks if a process with the given PID is running.
|
|
557
557
|
* Uses signal 0 which checks existence without sending a signal.
|
|
558
558
|
*
|
|
559
|
-
* @param pid -
|
|
559
|
+
* @param pid - the process ID to check (must be a positive integer)
|
|
560
560
|
* @returns `true` if the process exists (even without permission to signal it),
|
|
561
561
|
* `false` if the process doesn't exist or if pid is invalid (non-positive, non-integer, NaN, Infinity)
|
|
562
562
|
*/
|
package/dist/random.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Random helpers that accept an optional `random` parameter,
|
|
3
3
|
* defaulting to `Math.random`. Pass a seeded PRNG for reproducible results:
|
|
4
4
|
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
5
|
+
* - `create_random_xoshiro` — fast, high-quality numeric seeding (recommended)
|
|
6
|
+
* - `create_random_alea` — supports string and variadic seeds
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
package/dist/random.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Random helpers that accept an optional `random` parameter,
|
|
3
3
|
* defaulting to `Math.random`. Pass a seeded PRNG for reproducible results:
|
|
4
4
|
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
5
|
+
* - `create_random_xoshiro` — fast, high-quality numeric seeding (recommended)
|
|
6
|
+
* - `create_random_alea` — supports string and variadic seeds
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
package/dist/result.d.ts
CHANGED
|
@@ -24,9 +24,9 @@ export declare const NOT_OK: Readonly<{
|
|
|
24
24
|
* A helper that says,
|
|
25
25
|
* "hey I know this is wrapped in a `Result`, but I expect it to be `ok`,
|
|
26
26
|
* so if it's not, I understand it will throw an error that wraps the result".
|
|
27
|
-
* @param result
|
|
28
|
-
* @param message
|
|
29
|
-
* @returns
|
|
27
|
+
* @param result - some `Result` object
|
|
28
|
+
* @param message - optional custom error message
|
|
29
|
+
* @returns the wrapped value
|
|
30
30
|
*/
|
|
31
31
|
export declare const unwrap: <TValue extends {
|
|
32
32
|
value?: unknown;
|
|
@@ -54,9 +54,9 @@ export declare class ResultError extends Error {
|
|
|
54
54
|
/**
|
|
55
55
|
* A helper that does the opposite of `unwrap`, throwing if the `Result` is ok.
|
|
56
56
|
* Note that while `unwrap` returns the wrapped `value`, `unwrap_error` returns the entire result.
|
|
57
|
-
* @param result
|
|
58
|
-
* @param message
|
|
59
|
-
* @returns
|
|
57
|
+
* @param result - some `Result` object
|
|
58
|
+
* @param message - optional custom error message
|
|
59
|
+
* @returns the type-narrowed result
|
|
60
60
|
*/
|
|
61
61
|
export declare const unwrap_error: <TError extends object>(result: Result<object, TError>, message?: string) => {
|
|
62
62
|
ok: false;
|
package/dist/result.js
CHANGED
|
@@ -10,9 +10,9 @@ export const NOT_OK = Object.freeze({ ok: false });
|
|
|
10
10
|
* A helper that says,
|
|
11
11
|
* "hey I know this is wrapped in a `Result`, but I expect it to be `ok`,
|
|
12
12
|
* so if it's not, I understand it will throw an error that wraps the result".
|
|
13
|
-
* @param result
|
|
14
|
-
* @param message
|
|
15
|
-
* @returns
|
|
13
|
+
* @param result - some `Result` object
|
|
14
|
+
* @param message - optional custom error message
|
|
15
|
+
* @returns the wrapped value
|
|
16
16
|
*/
|
|
17
17
|
export const unwrap = (result, message) => {
|
|
18
18
|
if (!result.ok)
|
|
@@ -37,9 +37,9 @@ export class ResultError extends Error {
|
|
|
37
37
|
/**
|
|
38
38
|
* A helper that does the opposite of `unwrap`, throwing if the `Result` is ok.
|
|
39
39
|
* Note that while `unwrap` returns the wrapped `value`, `unwrap_error` returns the entire result.
|
|
40
|
-
* @param result
|
|
41
|
-
* @param message
|
|
42
|
-
* @returns
|
|
40
|
+
* @param result - some `Result` object
|
|
41
|
+
* @param message - optional custom error message
|
|
42
|
+
* @returns the type-narrowed result
|
|
43
43
|
*/
|
|
44
44
|
export const unwrap_error = (result, message = 'Failed to unwrap result error') => {
|
|
45
45
|
if (result.ok)
|
package/dist/sort.d.ts
CHANGED
|
@@ -30,9 +30,9 @@ export type TopologicalSortResult<T extends Sortable> = {
|
|
|
30
30
|
* Returns items ordered so that dependencies come before dependents.
|
|
31
31
|
* If a cycle is detected, returns an error with the cycle path.
|
|
32
32
|
*
|
|
33
|
-
* @param items -
|
|
34
|
-
* @param label -
|
|
35
|
-
* @returns
|
|
33
|
+
* @param items - array of items to sort
|
|
34
|
+
* @param label - label for error messages (e.g. "resource", "step")
|
|
35
|
+
* @returns sorted items or error if cycle detected
|
|
36
36
|
*/
|
|
37
37
|
export declare const topological_sort: <T extends Sortable>(items: Array<T>, label?: string) => TopologicalSortResult<T>;
|
|
38
38
|
//# sourceMappingURL=sort.d.ts.map
|
package/dist/sort.js
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* Returns items ordered so that dependencies come before dependents.
|
|
13
13
|
* If a cycle is detected, returns an error with the cycle path.
|
|
14
14
|
*
|
|
15
|
-
* @param items -
|
|
16
|
-
* @param label -
|
|
17
|
-
* @returns
|
|
15
|
+
* @param items - array of items to sort
|
|
16
|
+
* @param label - label for error messages (e.g. "resource", "step")
|
|
17
|
+
* @returns sorted items or error if cycle detected
|
|
18
18
|
*/
|
|
19
19
|
export const topological_sort = (items, label = 'item') => {
|
|
20
20
|
// Build id -> item map
|