@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/zod.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import type { z } from 'zod';
|
|
|
10
10
|
/**
|
|
11
11
|
* Unwrap nested schema types (optional, default, nullable, etc).
|
|
12
12
|
*
|
|
13
|
-
* @param def - Zod type definition to unwrap
|
|
14
|
-
* @returns
|
|
13
|
+
* @param def - Zod type definition to unwrap
|
|
14
|
+
* @returns inner schema if wrapped, undefined otherwise
|
|
15
15
|
*/
|
|
16
16
|
export declare const zod_to_subschema: (def: z.core.$ZodTypeDef) => z.ZodType | undefined;
|
|
17
17
|
/** Zod wrapper type names that `zod_unwrap_def` traverses through. */
|
|
@@ -78,36 +78,36 @@ export declare const zod_extract_fields: (schema: z.ZodObject) => Array<ZodField
|
|
|
78
78
|
/**
|
|
79
79
|
* Get the description from a schema's metadata, unwrapping if needed.
|
|
80
80
|
*
|
|
81
|
-
* @param schema - Zod schema to extract description from
|
|
82
|
-
* @returns
|
|
81
|
+
* @param schema - Zod schema to extract description from
|
|
82
|
+
* @returns description string or null if not found
|
|
83
83
|
*/
|
|
84
84
|
export declare const zod_to_schema_description: (schema: z.ZodType) => string | null;
|
|
85
85
|
/**
|
|
86
86
|
* Get the default value from a schema, unwrapping if needed.
|
|
87
87
|
*
|
|
88
|
-
* @param schema - Zod schema to extract default from
|
|
89
|
-
* @returns
|
|
88
|
+
* @param schema - Zod schema to extract default from
|
|
89
|
+
* @returns default value or undefined
|
|
90
90
|
*/
|
|
91
91
|
export declare const zod_to_schema_default: (schema: z.ZodType) => unknown;
|
|
92
92
|
/**
|
|
93
93
|
* Get aliases from a schema's metadata, unwrapping if needed.
|
|
94
94
|
*
|
|
95
|
-
* @param schema - Zod schema to extract aliases from
|
|
96
|
-
* @returns
|
|
95
|
+
* @param schema - Zod schema to extract aliases from
|
|
96
|
+
* @returns array of alias strings
|
|
97
97
|
*/
|
|
98
98
|
export declare const zod_to_schema_aliases: (schema: z.ZodType) => Array<string>;
|
|
99
99
|
/**
|
|
100
100
|
* Get the type string for a schema, suitable for display.
|
|
101
101
|
*
|
|
102
|
-
* @param schema - Zod schema to get type string for
|
|
103
|
-
* @returns
|
|
102
|
+
* @param schema - Zod schema to get type string for
|
|
103
|
+
* @returns human-readable type string
|
|
104
104
|
*/
|
|
105
105
|
export declare const zod_to_schema_type_string: (schema: z.ZodType) => string;
|
|
106
106
|
/**
|
|
107
107
|
* Format a value for display in help text.
|
|
108
108
|
*
|
|
109
|
-
* @param value -
|
|
110
|
-
* @returns
|
|
109
|
+
* @param value - value to format
|
|
110
|
+
* @returns formatted string representation
|
|
111
111
|
*/
|
|
112
112
|
export declare const zod_format_value: (value: unknown) => string;
|
|
113
113
|
/**
|
|
@@ -123,15 +123,15 @@ export interface ZodSchemaProperty {
|
|
|
123
123
|
/**
|
|
124
124
|
* Extract properties from a Zod object schema.
|
|
125
125
|
*
|
|
126
|
-
* @param schema - Zod object schema to extract from
|
|
127
|
-
* @returns
|
|
126
|
+
* @param schema - Zod object schema to extract from
|
|
127
|
+
* @returns array of property definitions
|
|
128
128
|
*/
|
|
129
129
|
export declare const zod_to_schema_properties: (schema: z.ZodType) => Array<ZodSchemaProperty>;
|
|
130
130
|
/**
|
|
131
131
|
* Get all property names and their aliases from an object schema.
|
|
132
132
|
*
|
|
133
|
-
* @param schema - Zod object schema
|
|
134
|
-
* @returns
|
|
133
|
+
* @param schema - Zod object schema
|
|
134
|
+
* @returns set of all names and aliases
|
|
135
135
|
*/
|
|
136
136
|
export declare const zod_to_schema_names_with_aliases: (schema: z.ZodType) => Set<string>;
|
|
137
137
|
//# sourceMappingURL=zod.d.ts.map
|
package/dist/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/zod.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,CAAC,EA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AwB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,KAAK,CAAC,iBAAiB,CAuBnF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,GAAG,CAAC,MAAM,CAW9E,CAAC"}
|
package/dist/zod.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
/**
|
|
13
13
|
* Unwrap nested schema types (optional, default, nullable, etc).
|
|
14
14
|
*
|
|
15
|
-
* @param def - Zod type definition to unwrap
|
|
16
|
-
* @returns
|
|
15
|
+
* @param def - Zod type definition to unwrap
|
|
16
|
+
* @returns inner schema if wrapped, undefined otherwise
|
|
17
17
|
*/
|
|
18
18
|
export const zod_to_subschema = (def) => {
|
|
19
19
|
if ('innerType' in def) {
|
|
@@ -44,7 +44,7 @@ export const ZOD_WRAPPER_TYPES = new Set([
|
|
|
44
44
|
* @returns the innermost non-wrapper type definition
|
|
45
45
|
*/
|
|
46
46
|
export const zod_unwrap_def = (schema) => {
|
|
47
|
-
const def = schema
|
|
47
|
+
const { def } = schema;
|
|
48
48
|
if (ZOD_WRAPPER_TYPES.has(def.type)) {
|
|
49
49
|
const sub = zod_to_subschema(def);
|
|
50
50
|
if (sub)
|
|
@@ -64,14 +64,14 @@ export const zod_get_base_type = (schema) => zod_unwrap_def(schema).type;
|
|
|
64
64
|
*
|
|
65
65
|
* @param schema - Zod schema to check
|
|
66
66
|
*/
|
|
67
|
-
export const zod_is_optional = (schema) => schema.
|
|
67
|
+
export const zod_is_optional = (schema) => schema.def.type === 'optional';
|
|
68
68
|
/**
|
|
69
69
|
* Check if a schema accepts null at any wrapping level.
|
|
70
70
|
*
|
|
71
71
|
* @param schema - Zod schema to check
|
|
72
72
|
*/
|
|
73
73
|
export const zod_is_nullable = (schema) => {
|
|
74
|
-
const def = schema
|
|
74
|
+
const { def } = schema;
|
|
75
75
|
if (def.type === 'nullable')
|
|
76
76
|
return true;
|
|
77
77
|
if (ZOD_WRAPPER_TYPES.has(def.type)) {
|
|
@@ -90,7 +90,7 @@ export const zod_is_nullable = (schema) => {
|
|
|
90
90
|
* @param schema - Zod schema to check
|
|
91
91
|
*/
|
|
92
92
|
export const zod_has_default = (schema) => {
|
|
93
|
-
const def = schema
|
|
93
|
+
const { def } = schema;
|
|
94
94
|
if ('defaultValue' in def)
|
|
95
95
|
return true;
|
|
96
96
|
const sub = zod_to_subschema(def);
|
|
@@ -110,8 +110,8 @@ export const zod_unwrap_to_object = (schema) => {
|
|
|
110
110
|
if (def.type !== 'object')
|
|
111
111
|
return null;
|
|
112
112
|
let s = schema;
|
|
113
|
-
while (s.
|
|
114
|
-
const sub = zod_to_subschema(s.
|
|
113
|
+
while (s.def.type !== 'object') {
|
|
114
|
+
const sub = zod_to_subschema(s.def);
|
|
115
115
|
if (!sub)
|
|
116
116
|
return null;
|
|
117
117
|
s = sub;
|
|
@@ -142,8 +142,8 @@ export const zod_extract_fields = (schema) => {
|
|
|
142
142
|
/**
|
|
143
143
|
* Get the description from a schema's metadata, unwrapping if needed.
|
|
144
144
|
*
|
|
145
|
-
* @param schema - Zod schema to extract description from
|
|
146
|
-
* @returns
|
|
145
|
+
* @param schema - Zod schema to extract description from
|
|
146
|
+
* @returns description string or null if not found
|
|
147
147
|
*/
|
|
148
148
|
export const zod_to_schema_description = (schema) => {
|
|
149
149
|
const meta = schema.meta();
|
|
@@ -159,11 +159,11 @@ export const zod_to_schema_description = (schema) => {
|
|
|
159
159
|
/**
|
|
160
160
|
* Get the default value from a schema, unwrapping if needed.
|
|
161
161
|
*
|
|
162
|
-
* @param schema - Zod schema to extract default from
|
|
163
|
-
* @returns
|
|
162
|
+
* @param schema - Zod schema to extract default from
|
|
163
|
+
* @returns default value or undefined
|
|
164
164
|
*/
|
|
165
165
|
export const zod_to_schema_default = (schema) => {
|
|
166
|
-
const { def } = schema
|
|
166
|
+
const { def } = schema;
|
|
167
167
|
if ('defaultValue' in def) {
|
|
168
168
|
return def.defaultValue;
|
|
169
169
|
}
|
|
@@ -176,8 +176,8 @@ export const zod_to_schema_default = (schema) => {
|
|
|
176
176
|
/**
|
|
177
177
|
* Get aliases from a schema's metadata, unwrapping if needed.
|
|
178
178
|
*
|
|
179
|
-
* @param schema - Zod schema to extract aliases from
|
|
180
|
-
* @returns
|
|
179
|
+
* @param schema - Zod schema to extract aliases from
|
|
180
|
+
* @returns array of alias strings
|
|
181
181
|
*/
|
|
182
182
|
export const zod_to_schema_aliases = (schema) => {
|
|
183
183
|
const meta = schema.meta();
|
|
@@ -193,11 +193,11 @@ export const zod_to_schema_aliases = (schema) => {
|
|
|
193
193
|
/**
|
|
194
194
|
* Get the type string for a schema, suitable for display.
|
|
195
195
|
*
|
|
196
|
-
* @param schema - Zod schema to get type string for
|
|
197
|
-
* @returns
|
|
196
|
+
* @param schema - Zod schema to get type string for
|
|
197
|
+
* @returns human-readable type string
|
|
198
198
|
*/
|
|
199
199
|
export const zod_to_schema_type_string = (schema) => {
|
|
200
|
-
const { def } = schema
|
|
200
|
+
const { def } = schema;
|
|
201
201
|
switch (def.type) {
|
|
202
202
|
case 'string':
|
|
203
203
|
return 'string';
|
|
@@ -244,8 +244,8 @@ export const zod_to_schema_type_string = (schema) => {
|
|
|
244
244
|
/**
|
|
245
245
|
* Format a value for display in help text.
|
|
246
246
|
*
|
|
247
|
-
* @param value -
|
|
248
|
-
* @returns
|
|
247
|
+
* @param value - value to format
|
|
248
|
+
* @returns formatted string representation
|
|
249
249
|
*/
|
|
250
250
|
export const zod_format_value = (value) => {
|
|
251
251
|
if (value === undefined)
|
|
@@ -265,8 +265,8 @@ export const zod_format_value = (value) => {
|
|
|
265
265
|
/**
|
|
266
266
|
* Extract properties from a Zod object schema.
|
|
267
267
|
*
|
|
268
|
-
* @param schema - Zod object schema to extract from
|
|
269
|
-
* @returns
|
|
268
|
+
* @param schema - Zod object schema to extract from
|
|
269
|
+
* @returns array of property definitions
|
|
270
270
|
*/
|
|
271
271
|
export const zod_to_schema_properties = (schema) => {
|
|
272
272
|
const { def } = schema;
|
|
@@ -293,8 +293,8 @@ export const zod_to_schema_properties = (schema) => {
|
|
|
293
293
|
/**
|
|
294
294
|
* Get all property names and their aliases from an object schema.
|
|
295
295
|
*
|
|
296
|
-
* @param schema - Zod object schema
|
|
297
|
-
* @returns
|
|
296
|
+
* @param schema - Zod object schema
|
|
297
|
+
* @returns set of all names and aliases
|
|
298
298
|
*/
|
|
299
299
|
export const zod_to_schema_names_with_aliases = (schema) => {
|
|
300
300
|
const names = new Set();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuzdev/fuz_util",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "utility belt for JS",
|
|
5
5
|
"glyph": "🦕",
|
|
6
6
|
"logo": "logo.svg",
|
|
@@ -75,11 +75,11 @@
|
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@changesets/changelog-git": "^0.2.1",
|
|
78
|
-
"@fuzdev/blake3_wasm": "^0.1.
|
|
78
|
+
"@fuzdev/blake3_wasm": "^0.1.1",
|
|
79
79
|
"@fuzdev/fuz_code": "^0.45.1",
|
|
80
|
-
"@fuzdev/fuz_css": "^0.
|
|
81
|
-
"@fuzdev/fuz_ui": "^0.
|
|
82
|
-
"@fuzdev/gro": "^0.197.
|
|
80
|
+
"@fuzdev/fuz_css": "^0.58.0",
|
|
81
|
+
"@fuzdev/fuz_ui": "^0.191.3",
|
|
82
|
+
"@fuzdev/gro": "^0.197.3",
|
|
83
83
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
84
84
|
"@ryanatkn/eslint-config": "^0.10.1",
|
|
85
85
|
"@sveltejs/acorn-typescript": "^1.0.9",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"magic-string": "^0.30.21",
|
|
99
99
|
"prettier": "^3.7.4",
|
|
100
100
|
"prettier-plugin-svelte": "^3.4.1",
|
|
101
|
-
"svelte": "^5.
|
|
101
|
+
"svelte": "^5.55.0",
|
|
102
102
|
"svelte-check": "^4.3.6",
|
|
103
103
|
"svelte2tsx": "^0.7.47",
|
|
104
104
|
"tslib": "^2.8.1",
|
package/src/lib/args.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type ArgValue = string | number | boolean | undefined | Array<string | nu
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Schema description for help text generation.
|
|
28
|
-
* Not used by args_parse
|
|
28
|
+
* Not used by `args_parse`/`args_serialize` directly - provided for consumers
|
|
29
29
|
* building CLI help output.
|
|
30
30
|
*/
|
|
31
31
|
export interface ArgSchema {
|
|
@@ -184,8 +184,8 @@ const get_schema_cache = (schema: z.ZodType): SchemaCacheEntry => {
|
|
|
184
184
|
*
|
|
185
185
|
* Results are cached per schema (WeakMap). Safe to call multiple times.
|
|
186
186
|
*
|
|
187
|
-
* @param schema
|
|
188
|
-
* @returns
|
|
187
|
+
* @param schema - zod object schema with optional alias metadata
|
|
188
|
+
* @returns validation result with success flag and optional error
|
|
189
189
|
*/
|
|
190
190
|
export const args_validate_schema = (
|
|
191
191
|
schema: z.ZodType,
|
|
@@ -209,8 +209,8 @@ export const args_validate_schema = (
|
|
|
209
209
|
*
|
|
210
210
|
* Schema analysis is cached per schema (WeakMap) for performance.
|
|
211
211
|
*
|
|
212
|
-
* @param unparsed_args
|
|
213
|
-
* @param schema
|
|
212
|
+
* @param unparsed_args - args object from CLI parser (mri, minimist, etc.)
|
|
213
|
+
* @param schema - zod object schema with optional alias metadata
|
|
214
214
|
* @returns Zod SafeParseResult with expanded/synced data on success
|
|
215
215
|
*/
|
|
216
216
|
export const args_parse = <TOutput extends Record<string, ArgValue> = Args>(
|
|
@@ -276,9 +276,9 @@ export const args_parse = <TOutput extends Record<string, ArgValue> = Args>(
|
|
|
276
276
|
*
|
|
277
277
|
* Schema analysis is cached per schema (WeakMap) for performance.
|
|
278
278
|
*
|
|
279
|
-
* @param args
|
|
280
|
-
* @param schema
|
|
281
|
-
* @returns
|
|
279
|
+
* @param args - args object to serialize
|
|
280
|
+
* @param schema - optional zod schema to extract aliases for short form preference
|
|
281
|
+
* @returns array of CLI argument strings
|
|
282
282
|
*/
|
|
283
283
|
export const args_serialize = (args: Args, schema?: z.ZodType): Array<string> => {
|
|
284
284
|
const result: Array<string> = [];
|
|
@@ -349,8 +349,8 @@ export const args_serialize = (args: Args, schema?: z.ZodType): Array<string> =>
|
|
|
349
349
|
*
|
|
350
350
|
* Note: Returns copies of the cached data to prevent mutation of internal cache.
|
|
351
351
|
*
|
|
352
|
-
* @param schema
|
|
353
|
-
* @returns
|
|
352
|
+
* @param schema - zod object schema with optional `.meta({aliases})` on fields
|
|
353
|
+
* @returns object with aliases map and canonical_keys set
|
|
354
354
|
*/
|
|
355
355
|
export const args_extract_aliases = (schema: z.ZodType): ArgsAliasesResult => {
|
|
356
356
|
const cache = get_schema_cache(schema);
|
|
@@ -419,8 +419,8 @@ const set_arg = (args: Args, key: string, value: string | number | boolean): voi
|
|
|
419
419
|
* The returned object uses `Object.create(null)` to prevent prototype pollution
|
|
420
420
|
* and allow any key name including `__proto__` and `constructor`.
|
|
421
421
|
*
|
|
422
|
-
* @param argv
|
|
423
|
-
* @returns
|
|
422
|
+
* @param argv - raw argument array (typically process.argv.slice(2))
|
|
423
|
+
* @returns parsed `Args` object with guaranteed `_` array (null prototype)
|
|
424
424
|
*/
|
|
425
425
|
export const argv_parse = (argv: Array<string>): ParsedArgs => {
|
|
426
426
|
// Use Object.create(null) to allow __proto__ as a normal key
|
package/src/lib/async.ts
CHANGED
|
@@ -38,10 +38,10 @@ export const create_deferred = <T>(): Deferred<T> => {
|
|
|
38
38
|
* Runs a function on each item with controlled concurrency.
|
|
39
39
|
* Like `map_concurrent` but doesn't collect results (more efficient for side effects).
|
|
40
40
|
*
|
|
41
|
-
* @param items items to process
|
|
42
|
-
* @param concurrency maximum number of concurrent operations
|
|
43
|
-
* @param fn function to apply to each item
|
|
44
|
-
* @param signal optional `AbortSignal` to cancel processing
|
|
41
|
+
* @param items - items to process
|
|
42
|
+
* @param concurrency - maximum number of concurrent operations
|
|
43
|
+
* @param fn - function to apply to each item
|
|
44
|
+
* @param signal - optional `AbortSignal` to cancel processing
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
47
|
* ```ts
|
|
@@ -123,10 +123,10 @@ export const each_concurrent = async <T>(
|
|
|
123
123
|
/**
|
|
124
124
|
* Maps over items with controlled concurrency, preserving input order.
|
|
125
125
|
*
|
|
126
|
-
* @param items items to process
|
|
127
|
-
* @param concurrency maximum number of concurrent operations
|
|
128
|
-
* @param fn function to apply to each item
|
|
129
|
-
* @param signal optional `AbortSignal` to cancel processing
|
|
126
|
+
* @param items - items to process
|
|
127
|
+
* @param concurrency - maximum number of concurrent operations
|
|
128
|
+
* @param fn - function to apply to each item
|
|
129
|
+
* @param signal - optional `AbortSignal` to cancel processing
|
|
130
130
|
* @returns promise resolving to array of results in same order as input
|
|
131
131
|
*
|
|
132
132
|
* @example
|
|
@@ -215,10 +215,10 @@ export const map_concurrent = async <T, R>(
|
|
|
215
215
|
* On abort, resolves with partial results: completed items keep their real settlements,
|
|
216
216
|
* in-flight and un-started items are settled as rejected with the abort reason.
|
|
217
217
|
*
|
|
218
|
-
* @param items items to process
|
|
219
|
-
* @param concurrency maximum number of concurrent operations
|
|
220
|
-
* @param fn function to apply to each item
|
|
221
|
-
* @param signal optional `AbortSignal` to cancel processing
|
|
218
|
+
* @param items - items to process
|
|
219
|
+
* @param concurrency - maximum number of concurrent operations
|
|
220
|
+
* @param fn - function to apply to each item
|
|
221
|
+
* @param signal - optional `AbortSignal` to cancel processing
|
|
222
222
|
* @returns promise resolving to array of `PromiseSettledResult` objects in input order
|
|
223
223
|
*
|
|
224
224
|
* @example
|
package/src/lib/benchmark.ts
CHANGED
|
@@ -44,8 +44,8 @@ import type {
|
|
|
44
44
|
const DEFAULT_DURATION_MS = 1000;
|
|
45
45
|
const DEFAULT_WARMUP_ITERATIONS = 10;
|
|
46
46
|
const DEFAULT_COOLDOWN_MS = 100;
|
|
47
|
-
const
|
|
48
|
-
const
|
|
47
|
+
const DEFAULT_ITERATIONS_MIN = 10;
|
|
48
|
+
const DEFAULT_ITERATIONS_MAX = 100_000;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Validate and normalize benchmark configuration.
|
|
@@ -90,10 +90,10 @@ interface BenchmarkTaskInternal extends BenchmarkTask {
|
|
|
90
90
|
* Warmup function by running it multiple times.
|
|
91
91
|
* Detects whether the function is async based on return value.
|
|
92
92
|
*
|
|
93
|
-
* @param fn -
|
|
94
|
-
* @param iterations -
|
|
95
|
-
* @param async_hint -
|
|
96
|
-
* @returns
|
|
93
|
+
* @param fn - function to warmup (sync or async)
|
|
94
|
+
* @param iterations - number of warmup iterations
|
|
95
|
+
* @param async_hint - if provided, use this instead of detecting
|
|
96
|
+
* @returns whether the function is async
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
99
|
* ```ts
|
|
@@ -146,8 +146,8 @@ export class Benchmark {
|
|
|
146
146
|
duration_ms: config.duration_ms ?? DEFAULT_DURATION_MS,
|
|
147
147
|
warmup_iterations: config.warmup_iterations ?? DEFAULT_WARMUP_ITERATIONS,
|
|
148
148
|
cooldown_ms: config.cooldown_ms ?? DEFAULT_COOLDOWN_MS,
|
|
149
|
-
min_iterations: config.min_iterations ??
|
|
150
|
-
max_iterations: config.max_iterations ??
|
|
149
|
+
min_iterations: config.min_iterations ?? DEFAULT_ITERATIONS_MIN,
|
|
150
|
+
max_iterations: config.max_iterations ?? DEFAULT_ITERATIONS_MAX,
|
|
151
151
|
timer: config.timer ?? timer_default,
|
|
152
152
|
on_iteration: config.on_iteration,
|
|
153
153
|
on_task_complete: config.on_task_complete,
|
|
@@ -156,9 +156,9 @@ export class Benchmark {
|
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* Add a benchmark task.
|
|
159
|
-
* @param name -
|
|
159
|
+
* @param name - task name or full task object
|
|
160
160
|
* @param fn - Function to benchmark (if name is string). Return values are ignored.
|
|
161
|
-
* @returns
|
|
161
|
+
* @returns this `Benchmark` instance for chaining
|
|
162
162
|
*
|
|
163
163
|
* @example
|
|
164
164
|
* ```ts
|
|
@@ -194,8 +194,8 @@ export class Benchmark {
|
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
196
|
* Remove a benchmark task by name.
|
|
197
|
-
* @param name -
|
|
198
|
-
* @returns
|
|
197
|
+
* @param name - name of the task to remove
|
|
198
|
+
* @returns this `Benchmark` instance for chaining
|
|
199
199
|
* @throws Error if task with given name doesn't exist
|
|
200
200
|
*
|
|
201
201
|
* @example
|
|
@@ -217,8 +217,8 @@ export class Benchmark {
|
|
|
217
217
|
|
|
218
218
|
/**
|
|
219
219
|
* Mark a task to be skipped during benchmark runs.
|
|
220
|
-
* @param name -
|
|
221
|
-
* @returns
|
|
220
|
+
* @param name - name of the task to skip
|
|
221
|
+
* @returns this `Benchmark` instance for chaining
|
|
222
222
|
* @throws Error if task with given name doesn't exist
|
|
223
223
|
*
|
|
224
224
|
* @example
|
|
@@ -240,8 +240,8 @@ export class Benchmark {
|
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
242
|
* Mark a task to run exclusively (along with other `only` tasks).
|
|
243
|
-
* @param name -
|
|
244
|
-
* @returns
|
|
243
|
+
* @param name - name of the task to run exclusively
|
|
244
|
+
* @returns this `Benchmark` instance for chaining
|
|
245
245
|
* @throws Error if task with given name doesn't exist
|
|
246
246
|
*
|
|
247
247
|
* @example
|
|
@@ -264,7 +264,7 @@ export class Benchmark {
|
|
|
264
264
|
|
|
265
265
|
/**
|
|
266
266
|
* Run all benchmark tasks.
|
|
267
|
-
* @returns
|
|
267
|
+
* @returns array of benchmark results
|
|
268
268
|
*/
|
|
269
269
|
async run(): Promise<Array<BenchmarkResult>> {
|
|
270
270
|
this.#results = [];
|
|
@@ -385,8 +385,8 @@ export class Benchmark {
|
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
387
|
* Format results as an ASCII table with percentiles, min/max, and relative performance.
|
|
388
|
-
* @param options -
|
|
389
|
-
* @returns
|
|
388
|
+
* @param options - formatting options
|
|
389
|
+
* @returns formatted table string
|
|
390
390
|
*
|
|
391
391
|
* @example
|
|
392
392
|
* ```ts
|
|
@@ -410,8 +410,8 @@ export class Benchmark {
|
|
|
410
410
|
|
|
411
411
|
/**
|
|
412
412
|
* Format results as a Markdown table.
|
|
413
|
-
* @param options -
|
|
414
|
-
* @returns
|
|
413
|
+
* @param options - formatting options (groups for organized output with optional baselines)
|
|
414
|
+
* @returns formatted markdown string
|
|
415
415
|
*
|
|
416
416
|
* @example
|
|
417
417
|
* ```ts
|
|
@@ -435,7 +435,7 @@ export class Benchmark {
|
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
437
|
* Format results as JSON.
|
|
438
|
-
* @param options -
|
|
438
|
+
* @param options - formatting options (pretty, include_timings)
|
|
439
439
|
* @returns JSON string
|
|
440
440
|
*/
|
|
441
441
|
json(options?: BenchmarkFormatJsonOptions): string {
|
|
@@ -445,7 +445,7 @@ export class Benchmark {
|
|
|
445
445
|
/**
|
|
446
446
|
* Get the benchmark results.
|
|
447
447
|
* Returns a shallow copy to prevent external mutation.
|
|
448
|
-
* @returns
|
|
448
|
+
* @returns array of benchmark results
|
|
449
449
|
*/
|
|
450
450
|
results(): Array<BenchmarkResult> {
|
|
451
451
|
return [...this.#results];
|
|
@@ -453,7 +453,7 @@ export class Benchmark {
|
|
|
453
453
|
|
|
454
454
|
/**
|
|
455
455
|
* Check if the benchmark has been run and has results.
|
|
456
|
-
* @returns
|
|
456
|
+
* @returns true if results are available
|
|
457
457
|
*
|
|
458
458
|
* @example
|
|
459
459
|
* ```ts
|
|
@@ -469,7 +469,7 @@ export class Benchmark {
|
|
|
469
469
|
/**
|
|
470
470
|
* Get results as a map for convenient lookup by task name.
|
|
471
471
|
* Returns a new Map each call to prevent external mutation.
|
|
472
|
-
* @returns
|
|
472
|
+
* @returns map of task name to benchmark result
|
|
473
473
|
*
|
|
474
474
|
* @example
|
|
475
475
|
* ```ts
|
|
@@ -487,7 +487,7 @@ export class Benchmark {
|
|
|
487
487
|
/**
|
|
488
488
|
* Reset the benchmark results.
|
|
489
489
|
* Keeps tasks intact so benchmarks can be rerun.
|
|
490
|
-
* @returns
|
|
490
|
+
* @returns this `Benchmark` instance for chaining
|
|
491
491
|
*/
|
|
492
492
|
reset(): this {
|
|
493
493
|
this.#results = [];
|
|
@@ -497,7 +497,7 @@ export class Benchmark {
|
|
|
497
497
|
/**
|
|
498
498
|
* Clear everything (results and tasks).
|
|
499
499
|
* Use this to start fresh with a new set of benchmarks.
|
|
500
|
-
* @returns
|
|
500
|
+
* @returns this `Benchmark` instance for chaining
|
|
501
501
|
*/
|
|
502
502
|
clear(): this {
|
|
503
503
|
this.#results = [];
|
|
@@ -507,7 +507,7 @@ export class Benchmark {
|
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
509
|
* Get a quick text summary of the fastest task.
|
|
510
|
-
* @returns
|
|
510
|
+
* @returns human-readable summary string
|
|
511
511
|
*
|
|
512
512
|
* @example
|
|
513
513
|
* ```ts
|