@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.
Files changed (104) hide show
  1. package/dist/args.d.ts +12 -12
  2. package/dist/args.js +11 -11
  3. package/dist/async.d.ts +12 -12
  4. package/dist/async.js +12 -12
  5. package/dist/benchmark.d.ts +24 -24
  6. package/dist/benchmark.js +26 -26
  7. package/dist/benchmark_baseline.d.ts +11 -11
  8. package/dist/benchmark_baseline.js +11 -11
  9. package/dist/benchmark_format.d.ts +15 -15
  10. package/dist/benchmark_format.js +15 -15
  11. package/dist/benchmark_stats.d.ts +5 -5
  12. package/dist/benchmark_stats.js +5 -5
  13. package/dist/benchmark_types.d.ts +7 -7
  14. package/dist/bytes.d.ts +4 -4
  15. package/dist/bytes.js +4 -4
  16. package/dist/dag.d.ts +2 -2
  17. package/dist/dag.js +2 -2
  18. package/dist/deep_equal.d.ts +2 -2
  19. package/dist/deep_equal.js +2 -2
  20. package/dist/diff.d.ts +17 -17
  21. package/dist/diff.js +17 -17
  22. package/dist/dom.d.ts +4 -4
  23. package/dist/dom.js +4 -4
  24. package/dist/fetch.d.ts +1 -1
  25. package/dist/fetch.js +1 -1
  26. package/dist/git.d.ts +1 -1
  27. package/dist/git.js +1 -1
  28. package/dist/hash.d.ts +6 -6
  29. package/dist/hash.js +8 -8
  30. package/dist/hash_blake3.d.ts +1 -1
  31. package/dist/hash_blake3.js +1 -1
  32. package/dist/hex.d.ts +4 -4
  33. package/dist/hex.js +4 -4
  34. package/dist/json.d.ts +2 -2
  35. package/dist/json.js +2 -2
  36. package/dist/log.d.ts +12 -12
  37. package/dist/log.js +11 -11
  38. package/dist/map.d.ts +1 -1
  39. package/dist/map.js +1 -1
  40. package/dist/object.d.ts +1 -1
  41. package/dist/object.js +1 -1
  42. package/dist/package_json.d.ts +1 -1
  43. package/dist/package_json.js +1 -1
  44. package/dist/path.d.ts +5 -5
  45. package/dist/path.js +5 -5
  46. package/dist/process.d.ts +22 -22
  47. package/dist/process.js +22 -22
  48. package/dist/random.d.ts +2 -2
  49. package/dist/random.js +2 -2
  50. package/dist/result.d.ts +6 -6
  51. package/dist/result.js +6 -6
  52. package/dist/sort.d.ts +3 -3
  53. package/dist/sort.js +3 -3
  54. package/dist/source_json.d.ts +3 -3
  55. package/dist/source_json.js +3 -3
  56. package/dist/stats.d.ts +17 -17
  57. package/dist/stats.js +17 -17
  58. package/dist/string.d.ts +6 -6
  59. package/dist/string.js +6 -6
  60. package/dist/svelte_preprocess_helpers.d.ts +42 -42
  61. package/dist/svelte_preprocess_helpers.js +42 -42
  62. package/dist/testing.d.ts +44 -0
  63. package/dist/testing.d.ts.map +1 -0
  64. package/dist/testing.js +59 -0
  65. package/dist/time.d.ts +19 -19
  66. package/dist/time.js +19 -19
  67. package/dist/zod.d.ts +16 -16
  68. package/dist/zod.d.ts.map +1 -1
  69. package/dist/zod.js +24 -24
  70. package/package.json +6 -6
  71. package/src/lib/args.ts +12 -12
  72. package/src/lib/async.ts +12 -12
  73. package/src/lib/benchmark.ts +28 -28
  74. package/src/lib/benchmark_baseline.ts +11 -11
  75. package/src/lib/benchmark_format.ts +15 -15
  76. package/src/lib/benchmark_stats.ts +5 -5
  77. package/src/lib/benchmark_types.ts +7 -7
  78. package/src/lib/bytes.ts +4 -4
  79. package/src/lib/dag.ts +2 -2
  80. package/src/lib/deep_equal.ts +2 -2
  81. package/src/lib/diff.ts +17 -17
  82. package/src/lib/dom.ts +4 -4
  83. package/src/lib/fetch.ts +1 -1
  84. package/src/lib/git.ts +1 -1
  85. package/src/lib/hash.ts +8 -8
  86. package/src/lib/hash_blake3.ts +1 -1
  87. package/src/lib/hex.ts +4 -4
  88. package/src/lib/json.ts +2 -2
  89. package/src/lib/log.ts +12 -12
  90. package/src/lib/map.ts +1 -1
  91. package/src/lib/object.ts +1 -1
  92. package/src/lib/package_json.ts +1 -1
  93. package/src/lib/path.ts +5 -5
  94. package/src/lib/process.ts +22 -22
  95. package/src/lib/random.ts +2 -2
  96. package/src/lib/result.ts +6 -6
  97. package/src/lib/sort.ts +3 -3
  98. package/src/lib/source_json.ts +3 -3
  99. package/src/lib/stats.ts +17 -17
  100. package/src/lib/string.ts +6 -6
  101. package/src/lib/svelte_preprocess_helpers.ts +42 -42
  102. package/src/lib/testing.ts +80 -0
  103. package/src/lib/time.ts +19 -19
  104. package/src/lib/zod.ts +24 -24
@@ -5,7 +5,7 @@
5
5
  * extracted at build time via TypeScript compiler analysis.
6
6
  * Used for generating API documentation and enabling code search.
7
7
  *
8
- * Hierarchy: SourceJson → ModuleJson → DeclarationJson
8
+ * Hierarchy: `SourceJson``ModuleJson``DeclarationJson`
9
9
  *
10
10
  * @module
11
11
  */
@@ -39,7 +39,7 @@ export type GenericParamInfo = z.infer<typeof GenericParamInfo>;
39
39
  /**
40
40
  * Parameter information for functions and methods.
41
41
  *
42
- * Kept distinct from ComponentPropInfo despite structural similarity.
42
+ * Kept distinct from `ComponentPropInfo` despite structural similarity.
43
43
  * Function parameters form a tuple with positional semantics:
44
44
  * calling order matters (`fn(a, b)` vs `fn(b, a)`),
45
45
  * may include rest parameters and destructuring patterns.
@@ -55,7 +55,7 @@ export type ParameterInfo = z.infer<typeof ParameterInfo>;
55
55
  /**
56
56
  * Component prop information for Svelte components.
57
57
  *
58
- * Kept distinct from ParameterInfo despite structural similarity.
58
+ * Kept distinct from `ParameterInfo` despite structural similarity.
59
59
  * Component props are named attributes with different semantics:
60
60
  * no positional order when passing (`<Foo {a} {b} />` = `<Foo {b} {a} />`),
61
61
  * support two-way binding via `$bindable` rune.
@@ -5,7 +5,7 @@
5
5
  * extracted at build time via TypeScript compiler analysis.
6
6
  * Used for generating API documentation and enabling code search.
7
7
  *
8
- * Hierarchy: SourceJson → ModuleJson → DeclarationJson
8
+ * Hierarchy: `SourceJson``ModuleJson``DeclarationJson`
9
9
  *
10
10
  * @module
11
11
  */
@@ -37,7 +37,7 @@ export const GenericParamInfo = z.looseObject({
37
37
  /**
38
38
  * Parameter information for functions and methods.
39
39
  *
40
- * Kept distinct from ComponentPropInfo despite structural similarity.
40
+ * Kept distinct from `ComponentPropInfo` despite structural similarity.
41
41
  * Function parameters form a tuple with positional semantics:
42
42
  * calling order matters (`fn(a, b)` vs `fn(b, a)`),
43
43
  * may include rest parameters and destructuring patterns.
@@ -52,7 +52,7 @@ export const ParameterInfo = z.looseObject({
52
52
  /**
53
53
  * Component prop information for Svelte components.
54
54
  *
55
- * Kept distinct from ParameterInfo despite structural similarity.
55
+ * Kept distinct from `ParameterInfo` despite structural similarity.
56
56
  * Component props are named attributes with different semantics:
57
57
  * no positional order when passing (`<Foo {a} {b} />` = `<Foo {b} {a} />`),
58
58
  * support two-way binding via `$bindable` rune.
package/dist/stats.d.ts CHANGED
@@ -26,8 +26,8 @@ export declare const stats_variance: (values: Array<number>, mean?: number) => n
26
26
  * Calculate a percentile of an array of numbers using linear interpolation.
27
27
  * Uses the "R-7" method (default in R, NumPy, Excel) which interpolates between
28
28
  * data points for more accurate percentile estimates, especially with smaller samples.
29
- * @param values - Array of numbers
30
- * @param p - Percentile (0-1, e.g., 0.95 for 95th percentile)
29
+ * @param values - array of numbers
30
+ * @param p - percentile (0-1, e.g., 0.95 for 95th percentile)
31
31
  */
32
32
  export declare const stats_percentile: (values: Array<number>, p: number) => number;
33
33
  /**
@@ -120,18 +120,18 @@ export interface StatsConfidenceIntervalOptions {
120
120
  }
121
121
  /**
122
122
  * Calculate confidence interval for the mean.
123
- * @param values - Array of numbers
124
- * @param options - Configuration options
123
+ * @param values - array of numbers
124
+ * @param options - configuration options
125
125
  * @returns [lower_bound, upper_bound]
126
126
  */
127
127
  export declare const stats_confidence_interval: (values: Array<number>, options?: StatsConfidenceIntervalOptions) => [number, number];
128
128
  /**
129
129
  * Calculate confidence interval from summary statistics (mean, std_dev, sample_size).
130
130
  * Useful when raw data is not available.
131
- * @param mean - Mean of the data
132
- * @param std_dev - Standard deviation of the data
133
- * @param sample_size - Number of samples
134
- * @param options - Configuration options
131
+ * @param mean - mean of the data
132
+ * @param std_dev - standard deviation of the data
133
+ * @param sample_size - number of samples
134
+ * @param options - configuration options
135
135
  * @returns [lower_bound, upper_bound]
136
136
  */
137
137
  export declare const stats_confidence_interval_from_summary: (mean: number, std_dev: number, sample_size: number, options?: StatsConfidenceIntervalOptions) => [number, number];
@@ -148,12 +148,12 @@ export interface StatsWelchTTestResult {
148
148
  * Calculate Welch's t-test statistic and degrees of freedom.
149
149
  * Welch's t-test is more robust than Student's t-test when variances are unequal.
150
150
  *
151
- * @param mean1 - Mean of first sample
152
- * @param std1 - Standard deviation of first sample
153
- * @param n1 - Size of first sample
154
- * @param mean2 - Mean of second sample
155
- * @param std2 - Standard deviation of second sample
156
- * @param n2 - Size of second sample
151
+ * @param mean1 - mean of first sample
152
+ * @param std1 - standard deviation of first sample
153
+ * @param n1 - size of first sample
154
+ * @param mean2 - mean of second sample
155
+ * @param std2 - standard deviation of second sample
156
+ * @param n2 - size of second sample
157
157
  */
158
158
  export declare const stats_welch_t_test: (mean1: number, std1: number, n1: number, mean2: number, std2: number, n2: number) => StatsWelchTTestResult;
159
159
  /**
@@ -174,9 +174,9 @@ export declare const stats_incomplete_beta: (x: number, a: number, b: number) =>
174
174
  * For large df (>100), uses normal approximation.
175
175
  * For smaller df, uses incomplete beta function.
176
176
  *
177
- * @param t - Absolute value of t-statistic
178
- * @param df - Degrees of freedom
179
- * @returns Two-tailed p-value
177
+ * @param t - absolute value of t-statistic
178
+ * @param df - degrees of freedom
179
+ * @returns two-tailed p-value
180
180
  */
181
181
  export declare const stats_t_distribution_p_value: (t: number, df: number) => number;
182
182
  //# sourceMappingURL=stats.d.ts.map
package/dist/stats.js CHANGED
@@ -57,8 +57,8 @@ export const stats_variance = (values, mean) => {
57
57
  * Calculate a percentile of an array of numbers using linear interpolation.
58
58
  * Uses the "R-7" method (default in R, NumPy, Excel) which interpolates between
59
59
  * data points for more accurate percentile estimates, especially with smaller samples.
60
- * @param values - Array of numbers
61
- * @param p - Percentile (0-1, e.g., 0.95 for 95th percentile)
60
+ * @param values - array of numbers
61
+ * @param p - percentile (0-1, e.g., 0.95 for 95th percentile)
62
62
  */
63
63
  export const stats_percentile = (values, p) => {
64
64
  if (values.length === 0)
@@ -245,8 +245,8 @@ export const stats_confidence_level_to_z_score = (level) => {
245
245
  };
246
246
  /**
247
247
  * Calculate confidence interval for the mean.
248
- * @param values - Array of numbers
249
- * @param options - Configuration options
248
+ * @param values - array of numbers
249
+ * @param options - configuration options
250
250
  * @returns [lower_bound, upper_bound]
251
251
  */
252
252
  export const stats_confidence_interval = (values, options) => {
@@ -259,10 +259,10 @@ export const stats_confidence_interval = (values, options) => {
259
259
  /**
260
260
  * Calculate confidence interval from summary statistics (mean, std_dev, sample_size).
261
261
  * Useful when raw data is not available.
262
- * @param mean - Mean of the data
263
- * @param std_dev - Standard deviation of the data
264
- * @param sample_size - Number of samples
265
- * @param options - Configuration options
262
+ * @param mean - mean of the data
263
+ * @param std_dev - standard deviation of the data
264
+ * @param sample_size - number of samples
265
+ * @param options - configuration options
266
266
  * @returns [lower_bound, upper_bound]
267
267
  */
268
268
  export const stats_confidence_interval_from_summary = (mean, std_dev, sample_size, options) => {
@@ -282,12 +282,12 @@ export const stats_confidence_interval_from_summary = (mean, std_dev, sample_siz
282
282
  * Calculate Welch's t-test statistic and degrees of freedom.
283
283
  * Welch's t-test is more robust than Student's t-test when variances are unequal.
284
284
  *
285
- * @param mean1 - Mean of first sample
286
- * @param std1 - Standard deviation of first sample
287
- * @param n1 - Size of first sample
288
- * @param mean2 - Mean of second sample
289
- * @param std2 - Standard deviation of second sample
290
- * @param n2 - Size of second sample
285
+ * @param mean1 - mean of first sample
286
+ * @param std1 - standard deviation of first sample
287
+ * @param n1 - size of first sample
288
+ * @param mean2 - mean of second sample
289
+ * @param std2 - standard deviation of second sample
290
+ * @param n2 - size of second sample
291
291
  */
292
292
  export const stats_welch_t_test = (mean1, std1, n1, mean2, std2, n2) => {
293
293
  const var1 = std1 ** 2;
@@ -386,9 +386,9 @@ export const stats_incomplete_beta = (x, a, b) => {
386
386
  * For large df (>100), uses normal approximation.
387
387
  * For smaller df, uses incomplete beta function.
388
388
  *
389
- * @param t - Absolute value of t-statistic
390
- * @param df - Degrees of freedom
391
- * @returns Two-tailed p-value
389
+ * @param t - absolute value of t-statistic
390
+ * @param df - degrees of freedom
391
+ * @returns two-tailed p-value
392
392
  */
393
393
  export const stats_t_distribution_p_value = (t, df) => {
394
394
  // Use normal approximation for large df
package/dist/string.d.ts CHANGED
@@ -39,7 +39,7 @@ export declare const plural: (count: number | undefined | null, suffix?: string)
39
39
  */
40
40
  export declare const count_graphemes: (str: string) => number;
41
41
  /**
42
- * Strips ANSI escape sequences from a string
42
+ * Strips ANSI escape sequences from a string.
43
43
  */
44
44
  export declare const strip_ansi: (str: string) => string;
45
45
  /**
@@ -65,9 +65,9 @@ export declare const pad_width: (str: string, target_width: number, align?: "lef
65
65
  * Calculates the Levenshtein distance between two strings.
66
66
  * Useful for typo detection and fuzzy matching.
67
67
  *
68
- * @param a - First string
69
- * @param b - Second string
70
- * @returns The edit distance between the strings
68
+ * @param a - first string
69
+ * @param b - second string
70
+ * @returns the edit distance between the strings
71
71
  */
72
72
  export declare const levenshtein_distance: (a: string, b: string) => number;
73
73
  /**
@@ -82,8 +82,8 @@ export declare const escape_js_string: (value: string) => string;
82
82
  *
83
83
  * Checks for null bytes in the first 8KB of content.
84
84
  *
85
- * @param content - Content to check.
86
- * @returns True if content appears to be binary.
85
+ * @param content - content to check
86
+ * @returns true if content appears to be binary
87
87
  */
88
88
  export declare const string_is_binary: (content: string) => boolean;
89
89
  //# sourceMappingURL=string.d.ts.map
package/dist/string.js CHANGED
@@ -81,7 +81,7 @@ export const plural = (count, suffix = 's') => count === 1 ? '' : suffix;
81
81
  */
82
82
  export const count_graphemes = (str) => count_iterator(new Intl.Segmenter().segment(str));
83
83
  /**
84
- * Strips ANSI escape sequences from a string
84
+ * Strips ANSI escape sequences from a string.
85
85
  */
86
86
  export const strip_ansi = (str) => str.replaceAll(/\x1B\[[0-9;]*[a-zA-Z]/g, ''); // eslint-disable-line no-control-regex
87
87
  /**
@@ -152,9 +152,9 @@ export const pad_width = (str, target_width, align = 'left') => {
152
152
  * Calculates the Levenshtein distance between two strings.
153
153
  * Useful for typo detection and fuzzy matching.
154
154
  *
155
- * @param a - First string
156
- * @param b - Second string
157
- * @returns The edit distance between the strings
155
+ * @param a - first string
156
+ * @param b - second string
157
+ * @returns the edit distance between the strings
158
158
  */
159
159
  export const levenshtein_distance = (a, b) => {
160
160
  if (a.length === 0)
@@ -220,7 +220,7 @@ export const escape_js_string = (value) => value.replace(/[\\'\n\r\u2028\u2029]/
220
220
  *
221
221
  * Checks for null bytes in the first 8KB of content.
222
222
  *
223
- * @param content - Content to check.
224
- * @returns True if content appears to be binary.
223
+ * @param content - content to check
224
+ * @returns true if content appears to be binary
225
225
  */
226
226
  export const string_is_binary = (content) => content.slice(0, 8192).includes('\0');
@@ -33,9 +33,9 @@ export interface ResolvedComponentImport {
33
33
  * Iterates the node's `attributes` array and returns the first `Attribute`
34
34
  * node whose `name` matches. Skips `SpreadAttribute`, directive, and other node types.
35
35
  *
36
- * @param node The component AST node to search.
37
- * @param name The attribute name to find.
38
- * @returns The matching `Attribute` node, or `undefined` if not found.
36
+ * @param node - the component AST node to search
37
+ * @param name - the attribute name to find
38
+ * @returns the matching `Attribute` node, or `undefined` if not found
39
39
  */
40
40
  export declare const find_attribute: (node: AST.Component, name: string) => AST.Attribute | undefined;
41
41
  /**
@@ -46,9 +46,9 @@ export declare const find_attribute: (node: AST.Component, name: string) => AST.
46
46
  * via an optional bindings map built by `build_static_bindings`.
47
47
  * Returns `null` for dynamic expressions, non-string literals, or unsupported node types.
48
48
  *
49
- * @param expr An ESTree expression AST node.
50
- * @param bindings Optional map of variable names to their resolved static string values.
51
- * @returns The resolved static string, or `null` if the expression is dynamic.
49
+ * @param expr - an ESTree expression AST node
50
+ * @param bindings - optional map of variable names to their resolved static string values
51
+ * @returns the resolved static string, or `null` if the expression is dynamic
52
52
  */
53
53
  export declare const evaluate_static_expr: (expr: Expression, bindings?: ReadonlyMap<string, string>) => string | null;
54
54
  /**
@@ -62,9 +62,9 @@ export declare const evaluate_static_expr: (expr: Expression, bindings?: Readonl
62
62
  *
63
63
  * Returns `null` for null literals, mixed arrays, dynamic expressions, and non-string values.
64
64
  *
65
- * @param value The attribute value from `AST.Attribute['value']`.
66
- * @param bindings Optional map of variable names to their resolved static string values.
67
- * @returns The resolved static string, or `null` if the value is dynamic.
65
+ * @param value - the attribute value from `AST.Attribute['value']`
66
+ * @param bindings - optional map of variable names to their resolved static string values
67
+ * @returns the resolved static string, or `null` if the value is dynamic
68
68
  */
69
69
  export declare const extract_static_string: (value: AST.Attribute["value"], bindings?: ReadonlyMap<string, string>) => string | null;
70
70
  /** A single branch in a conditional chain extracted from nested ternary expressions. */
@@ -88,10 +88,10 @@ export interface ConditionalChainBranch {
88
88
  *
89
89
  * A 2-branch result covers the simple ternary case (`a ? 'x' : 'y'`).
90
90
  *
91
- * @param value The attribute value from `AST.Attribute['value']`.
92
- * @param source The full source string (needed to slice test expression source text).
93
- * @param bindings Map of variable names to their resolved static string values.
94
- * @returns Array of conditional chain branches, or `null` if not extractable.
91
+ * @param value - the attribute value from `AST.Attribute['value']`
92
+ * @param source - the full source string (needed to slice test expression source text)
93
+ * @param bindings - map of variable names to their resolved static string values
94
+ * @returns array of conditional chain branches, or `null` if not extractable
95
95
  */
96
96
  export declare const try_extract_conditional_chain: (value: AST.Attribute["value"], source: string, bindings: ReadonlyMap<string, string>) => Array<ConditionalChainBranch> | null;
97
97
  /**
@@ -105,8 +105,8 @@ export declare const try_extract_conditional_chain: (value: AST.Attribute["value
105
105
  * Skips destructuring patterns, `let`/`var` declarations, and declarations
106
106
  * whose initializers reference dynamic values.
107
107
  *
108
- * @param ast The parsed Svelte AST root node.
109
- * @returns Map of variable names to their resolved static string values.
108
+ * @param ast - the parsed Svelte AST root node
109
+ * @returns map of variable names to their resolved static string values
110
110
  */
111
111
  export declare const build_static_bindings: (ast: AST.Root) => Map<string, string>;
112
112
  /**
@@ -117,9 +117,9 @@ export declare const build_static_bindings: (ast: AST.Root) => Map<string, strin
117
117
  * and `import type` declarations (both whole-declaration and per-specifier).
118
118
  * Returns import node references alongside names to support import removal.
119
119
  *
120
- * @param ast The parsed Svelte AST root node.
121
- * @param component_imports Array of import source paths to match against.
122
- * @returns Map of local names to their resolved import info.
120
+ * @param ast - the parsed Svelte AST root node
121
+ * @param component_imports - array of import source paths to match against
122
+ * @returns map of local names to their resolved import info
123
123
  */
124
124
  export declare const resolve_component_names: (ast: AST.Root, component_imports: Array<string>) => Map<string, ResolvedComponentImport>;
125
125
  /**
@@ -128,8 +128,8 @@ export declare const resolve_component_names: (ast: AST.Root, component_imports:
128
128
  * Returns the end position of the last `ImportDeclaration`, or the start
129
129
  * of the script body content if no imports exist.
130
130
  *
131
- * @param script The parsed `AST.Script` node.
132
- * @returns The character position where new imports should be inserted.
131
+ * @param script - the parsed `AST.Script` node
132
+ * @returns the character position where new imports should be inserted
133
133
  */
134
134
  export declare const find_import_insert_position: (script: AST.Script) => number;
135
135
  /**
@@ -138,9 +138,9 @@ export declare const find_import_insert_position: (script: AST.Script) => number
138
138
  * Default imports produce `import Name from 'path';` lines.
139
139
  * Named imports are grouped by path into `import {a, b} from 'path';` lines.
140
140
  *
141
- * @param imports Map of local names to their import info.
142
- * @param indent Indentation prefix for each line. @default '\t'
143
- * @returns A string of newline-separated import statements.
141
+ * @param imports - map of local names to their import info
142
+ * @param indent - indentation prefix for each line @default '\t'
143
+ * @returns a string of newline-separated import statements
144
144
  */
145
145
  export declare const generate_import_lines: (imports: Map<string, PreprocessImportInfo>, indent?: string) => string;
146
146
  /**
@@ -158,10 +158,10 @@ export declare const generate_import_lines: (imports: Map<string, PreprocessImpo
158
158
  * Safe for Svelte template ASTs: `Component.name` is a plain string property
159
159
  * (not an `Identifier` node), so `<Mdz>` tags do not produce false matches.
160
160
  *
161
- * @param node The AST subtree to search.
162
- * @param name The identifier name to look for.
163
- * @param skip Set of AST nodes to skip during traversal.
164
- * @returns `true` if a matching `Identifier` node is found.
161
+ * @param node - the AST subtree to search
162
+ * @param name - the identifier name to look for
163
+ * @param skip - set of AST nodes to skip during traversal
164
+ * @returns `true` if a matching `Identifier` node is found
165
165
  */
166
166
  export declare const has_identifier_in_tree: (node: unknown, name: string, skip?: Set<unknown>) => boolean;
167
167
  /**
@@ -188,9 +188,9 @@ export declare const escape_svelte_text: (text: string) => string;
188
188
  * blank lines. Only safe for single-declarator statements (`const x = 'val';`);
189
189
  * callers must verify `node.declarations.length === 1` before calling.
190
190
  *
191
- * @param s The MagicString instance to modify.
192
- * @param declaration_node The `VariableDeclaration` AST node with Svelte position data.
193
- * @param source The original source string.
191
+ * @param s - the MagicString instance to modify
192
+ * @param declaration_node - the `VariableDeclaration` AST node with Svelte position data
193
+ * @param source - the original source string
194
194
  */
195
195
  export declare const remove_variable_declaration: (s: {
196
196
  remove: (start: number, end: number) => unknown;
@@ -204,9 +204,9 @@ export declare const remove_variable_declaration: (s: {
204
204
  * Consumes leading whitespace (tabs/spaces) and trailing newline to avoid leaving
205
205
  * blank lines.
206
206
  *
207
- * @param s The MagicString instance to modify.
208
- * @param import_node The `ImportDeclaration` AST node with Svelte position data.
209
- * @param source The original source string.
207
+ * @param s - the MagicString instance to modify
208
+ * @param import_node - the `ImportDeclaration` AST node with Svelte position data
209
+ * @param source - the original source string
210
210
  */
211
211
  export declare const remove_import_declaration: (s: {
212
212
  remove: (start: number, end: number) => unknown;
@@ -225,11 +225,11 @@ export declare const remove_import_declaration: (s: {
225
225
  * - `import {default as Mdz, other} from '...'` → `import {other} from '...'`
226
226
  * - `import {Mdz, other} from '...'` → `import {other} from '...'`
227
227
  *
228
- * @param s The MagicString instance to modify.
229
- * @param node The positioned `ImportDeclaration` AST node.
230
- * @param specifier_to_remove The specifier to remove from the import.
231
- * @param source The original source string.
232
- * @param additional_lines Extra content appended after the reconstructed import
228
+ * @param s - the MagicString instance to modify
229
+ * @param node - the positioned `ImportDeclaration` AST node
230
+ * @param specifier_to_remove - the specifier to remove from the import
231
+ * @param source - the original source string
232
+ * @param additional_lines - extra content appended after the reconstructed import
233
233
  * (used to bundle new imports into the overwrite to avoid MagicString boundary conflicts).
234
234
  */
235
235
  export declare const remove_import_specifier: (s: {
@@ -241,10 +241,10 @@ export declare const remove_import_specifier: (s: {
241
241
  /**
242
242
  * Handles errors during Svelte preprocessing with configurable behavior.
243
243
  *
244
- * @param error The caught error.
245
- * @param prefix Log prefix (e.g. `'[fuz-mdz]'`, `'[fuz-code]'`).
246
- * @param filename The file being processed.
247
- * @param on_error `'throw'` to re-throw as a new Error, `'log'` to console.error.
244
+ * @param error - the caught error
245
+ * @param prefix - log prefix (e.g. `'[fuz-mdz]'`, `'[fuz-code]'`)
246
+ * @param filename - the file being processed
247
+ * @param on_error - `'throw'` to re-throw as a new Error, `'log'` to console.error
248
248
  */
249
249
  export declare const handle_preprocess_error: (error: unknown, prefix: string, filename: string | undefined, on_error: "throw" | "log") => void;
250
250
  //# sourceMappingURL=svelte_preprocess_helpers.d.ts.map
@@ -17,9 +17,9 @@
17
17
  * Iterates the node's `attributes` array and returns the first `Attribute`
18
18
  * node whose `name` matches. Skips `SpreadAttribute`, directive, and other node types.
19
19
  *
20
- * @param node The component AST node to search.
21
- * @param name The attribute name to find.
22
- * @returns The matching `Attribute` node, or `undefined` if not found.
20
+ * @param node - the component AST node to search
21
+ * @param name - the attribute name to find
22
+ * @returns the matching `Attribute` node, or `undefined` if not found
23
23
  */
24
24
  export const find_attribute = (node, name) => {
25
25
  for (const attr of node.attributes) {
@@ -37,9 +37,9 @@ export const find_attribute = (node, name) => {
37
37
  * via an optional bindings map built by `build_static_bindings`.
38
38
  * Returns `null` for dynamic expressions, non-string literals, or unsupported node types.
39
39
  *
40
- * @param expr An ESTree expression AST node.
41
- * @param bindings Optional map of variable names to their resolved static string values.
42
- * @returns The resolved static string, or `null` if the expression is dynamic.
40
+ * @param expr - an ESTree expression AST node
41
+ * @param bindings - optional map of variable names to their resolved static string values
42
+ * @returns the resolved static string, or `null` if the expression is dynamic
43
43
  */
44
44
  export const evaluate_static_expr = (expr, bindings) => {
45
45
  if (expr.type === 'Literal' && typeof expr.value === 'string')
@@ -89,9 +89,9 @@ export const evaluate_static_expr = (expr, bindings) => {
89
89
  *
90
90
  * Returns `null` for null literals, mixed arrays, dynamic expressions, and non-string values.
91
91
  *
92
- * @param value The attribute value from `AST.Attribute['value']`.
93
- * @param bindings Optional map of variable names to their resolved static string values.
94
- * @returns The resolved static string, or `null` if the value is dynamic.
92
+ * @param value - the attribute value from `AST.Attribute['value']`
93
+ * @param bindings - optional map of variable names to their resolved static string values
94
+ * @returns the resolved static string, or `null` if the value is dynamic
95
95
  */
96
96
  export const extract_static_string = (value, bindings) => {
97
97
  // Boolean attribute (e.g., <Mdz inline />)
@@ -126,10 +126,10 @@ export const extract_static_string = (value, bindings) => {
126
126
  *
127
127
  * A 2-branch result covers the simple ternary case (`a ? 'x' : 'y'`).
128
128
  *
129
- * @param value The attribute value from `AST.Attribute['value']`.
130
- * @param source The full source string (needed to slice test expression source text).
131
- * @param bindings Map of variable names to their resolved static string values.
132
- * @returns Array of conditional chain branches, or `null` if not extractable.
129
+ * @param value - the attribute value from `AST.Attribute['value']`
130
+ * @param source - the full source string (needed to slice test expression source text)
131
+ * @param bindings - map of variable names to their resolved static string values
132
+ * @returns array of conditional chain branches, or `null` if not extractable
133
133
  */
134
134
  export const try_extract_conditional_chain = (value, source, bindings) => {
135
135
  if (value === true || Array.isArray(value))
@@ -178,8 +178,8 @@ export const try_extract_conditional_chain = (value, source, bindings) => {
178
178
  * Skips destructuring patterns, `let`/`var` declarations, and declarations
179
179
  * whose initializers reference dynamic values.
180
180
  *
181
- * @param ast The parsed Svelte AST root node.
182
- * @returns Map of variable names to their resolved static string values.
181
+ * @param ast - the parsed Svelte AST root node
182
+ * @returns map of variable names to their resolved static string values
183
183
  */
184
184
  export const build_static_bindings = (ast) => {
185
185
  const bindings = new Map();
@@ -211,9 +211,9 @@ export const build_static_bindings = (ast) => {
211
211
  * and `import type` declarations (both whole-declaration and per-specifier).
212
212
  * Returns import node references alongside names to support import removal.
213
213
  *
214
- * @param ast The parsed Svelte AST root node.
215
- * @param component_imports Array of import source paths to match against.
216
- * @returns Map of local names to their resolved import info.
214
+ * @param ast - the parsed Svelte AST root node
215
+ * @param component_imports - array of import source paths to match against
216
+ * @returns map of local names to their resolved import info
217
217
  */
218
218
  export const resolve_component_names = (ast, component_imports) => {
219
219
  const names = new Map();
@@ -247,8 +247,8 @@ export const resolve_component_names = (ast, component_imports) => {
247
247
  * Returns the end position of the last `ImportDeclaration`, or the start
248
248
  * of the script body content if no imports exist.
249
249
  *
250
- * @param script The parsed `AST.Script` node.
251
- * @returns The character position where new imports should be inserted.
250
+ * @param script - the parsed `AST.Script` node
251
+ * @returns the character position where new imports should be inserted
252
252
  */
253
253
  export const find_import_insert_position = (script) => {
254
254
  let last_import_end = -1;
@@ -269,9 +269,9 @@ export const find_import_insert_position = (script) => {
269
269
  * Default imports produce `import Name from 'path';` lines.
270
270
  * Named imports are grouped by path into `import {a, b} from 'path';` lines.
271
271
  *
272
- * @param imports Map of local names to their import info.
273
- * @param indent Indentation prefix for each line. @default '\t'
274
- * @returns A string of newline-separated import statements.
272
+ * @param imports - map of local names to their import info
273
+ * @param indent - indentation prefix for each line @default '\t'
274
+ * @returns a string of newline-separated import statements
275
275
  */
276
276
  export const generate_import_lines = (imports, indent = '\t') => {
277
277
  const default_imports = [];
@@ -333,10 +333,10 @@ const NON_REFERENCE_FIELDS = new Map([
333
333
  * Safe for Svelte template ASTs: `Component.name` is a plain string property
334
334
  * (not an `Identifier` node), so `<Mdz>` tags do not produce false matches.
335
335
  *
336
- * @param node The AST subtree to search.
337
- * @param name The identifier name to look for.
338
- * @param skip Set of AST nodes to skip during traversal.
339
- * @returns `true` if a matching `Identifier` node is found.
336
+ * @param node - the AST subtree to search
337
+ * @param name - the identifier name to look for
338
+ * @param skip - set of AST nodes to skip during traversal
339
+ * @returns `true` if a matching `Identifier` node is found
340
340
  */
341
341
  export const has_identifier_in_tree = (node, name, skip) => {
342
342
  if (node === null || node === undefined || typeof node !== 'object')
@@ -396,9 +396,9 @@ export const escape_svelte_text = (text) => text.replace(/[{}<&]/g, (ch) => {
396
396
  * blank lines. Only safe for single-declarator statements (`const x = 'val';`);
397
397
  * callers must verify `node.declarations.length === 1` before calling.
398
398
  *
399
- * @param s The MagicString instance to modify.
400
- * @param declaration_node The `VariableDeclaration` AST node with Svelte position data.
401
- * @param source The original source string.
399
+ * @param s - the MagicString instance to modify
400
+ * @param declaration_node - the `VariableDeclaration` AST node with Svelte position data
401
+ * @param source - the original source string
402
402
  */
403
403
  export const remove_variable_declaration = (s, declaration_node, source) => {
404
404
  remove_positioned_node(s, declaration_node, source);
@@ -409,9 +409,9 @@ export const remove_variable_declaration = (s, declaration_node, source) => {
409
409
  * Consumes leading whitespace (tabs/spaces) and trailing newline to avoid leaving
410
410
  * blank lines.
411
411
  *
412
- * @param s The MagicString instance to modify.
413
- * @param import_node The `ImportDeclaration` AST node with Svelte position data.
414
- * @param source The original source string.
412
+ * @param s - the MagicString instance to modify
413
+ * @param import_node - the `ImportDeclaration` AST node with Svelte position data
414
+ * @param source - the original source string
415
415
  */
416
416
  export const remove_import_declaration = (s, import_node, source) => {
417
417
  remove_positioned_node(s, import_node, source);
@@ -450,11 +450,11 @@ const remove_positioned_node = (s, node, source) => {
450
450
  * - `import {default as Mdz, other} from '...'` → `import {other} from '...'`
451
451
  * - `import {Mdz, other} from '...'` → `import {other} from '...'`
452
452
  *
453
- * @param s The MagicString instance to modify.
454
- * @param node The positioned `ImportDeclaration` AST node.
455
- * @param specifier_to_remove The specifier to remove from the import.
456
- * @param source The original source string.
457
- * @param additional_lines Extra content appended after the reconstructed import
453
+ * @param s - the MagicString instance to modify
454
+ * @param node - the positioned `ImportDeclaration` AST node
455
+ * @param specifier_to_remove - the specifier to remove from the import
456
+ * @param source - the original source string
457
+ * @param additional_lines - extra content appended after the reconstructed import
458
458
  * (used to bundle new imports into the overwrite to avoid MagicString boundary conflicts).
459
459
  */
460
460
  export const remove_import_specifier = (s, node, specifier_to_remove, source, additional_lines = '') => {
@@ -501,10 +501,10 @@ const format_named_specifiers = (specs) => specs
501
501
  /**
502
502
  * Handles errors during Svelte preprocessing with configurable behavior.
503
503
  *
504
- * @param error The caught error.
505
- * @param prefix Log prefix (e.g. `'[fuz-mdz]'`, `'[fuz-code]'`).
506
- * @param filename The file being processed.
507
- * @param on_error `'throw'` to re-throw as a new Error, `'log'` to console.error.
504
+ * @param error - the caught error
505
+ * @param prefix - log prefix (e.g. `'[fuz-mdz]'`, `'[fuz-code]'`)
506
+ * @param filename - the file being processed
507
+ * @param on_error - `'throw'` to re-throw as a new Error, `'log'` to console.error
508
508
  */
509
509
  export const handle_preprocess_error = (error, prefix, filename, on_error) => {
510
510
  const message = `${prefix} Preprocessing failed${filename ? ` in ${filename}` : ''}: ${error instanceof Error ? error.message : String(error)}`;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Shared test assertions for the `@fuzdev` ecosystem.
3
+ *
4
+ * Extends the fuz-stack testing conventions (`assert` from vitest, tests in `src/test/`,
5
+ * plain object mocks) with reusable helpers for patterns that appear across multiple repos.
6
+ * Only depends on vitest — safe for fuz_util's zero-runtime-deps constraint.
7
+ *
8
+ * @module
9
+ */
10
+ import type { Logger } from './log.js';
11
+ /**
12
+ * Asserts that `fn` rejects with an `Error`.
13
+ * Optionally matches the error message against `pattern`.
14
+ * Returns the caught `Error` for further assertions by the caller.
15
+ *
16
+ * `assert.fail` is placed after the catch block so that assertion failures
17
+ * from the test itself are not swallowed by the catch.
18
+ *
19
+ * @param fn - async function expected to reject
20
+ * @param pattern - optional regex to match against the error message
21
+ * @returns the caught `Error`
22
+ */
23
+ export declare const assert_rejects: (fn: () => Promise<unknown>, pattern?: RegExp) => Promise<Error>;
24
+ /**
25
+ * A mock `Logger` with `vi.fn()` methods and call tracking arrays.
26
+ * Assignable to `Logger` for use in code under test.
27
+ * Each tracking array captures the first argument of each call.
28
+ * For full call details, use `vi.fn()` introspection on the methods directly.
29
+ */
30
+ export type MockLogger = Logger & {
31
+ error_calls: Array<unknown>;
32
+ warn_calls: Array<unknown>;
33
+ info_calls: Array<unknown>;
34
+ debug_calls: Array<unknown>;
35
+ };
36
+ /**
37
+ * Creates a mock `Logger` with `vi.fn()` on each logging method
38
+ * and tracking arrays for inspecting logged messages.
39
+ * Follows the fuz-stack convention of plain object mocks over mocking libraries.
40
+ *
41
+ * @returns a `MockLogger` assignable to `Logger`
42
+ */
43
+ export declare const create_mock_logger: () => MockLogger;
44
+ //# sourceMappingURL=testing.d.ts.map