cmpstr 3.2.1 → 3.2.2

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 (150) hide show
  1. package/README.md +24 -18
  2. package/dist/CmpStr.esm.js +485 -220
  3. package/dist/CmpStr.esm.min.js +2 -3
  4. package/dist/CmpStr.umd.js +484 -220
  5. package/dist/CmpStr.umd.min.js +2 -3
  6. package/dist/cjs/CmpStr.cjs +57 -36
  7. package/dist/cjs/CmpStrAsync.cjs +30 -24
  8. package/dist/cjs/index.cjs +1 -2
  9. package/dist/cjs/metric/Cosine.cjs +1 -2
  10. package/dist/cjs/metric/DamerauLevenshtein.cjs +1 -2
  11. package/dist/cjs/metric/DiceSorensen.cjs +1 -2
  12. package/dist/cjs/metric/Hamming.cjs +5 -4
  13. package/dist/cjs/metric/Jaccard.cjs +1 -2
  14. package/dist/cjs/metric/JaroWinkler.cjs +1 -2
  15. package/dist/cjs/metric/LCS.cjs +1 -2
  16. package/dist/cjs/metric/Levenshtein.cjs +1 -2
  17. package/dist/cjs/metric/Metric.cjs +57 -38
  18. package/dist/cjs/metric/NeedlemanWunsch.cjs +1 -2
  19. package/dist/cjs/metric/QGram.cjs +1 -2
  20. package/dist/cjs/metric/SmithWaterman.cjs +1 -2
  21. package/dist/cjs/phonetic/Caverphone.cjs +1 -2
  22. package/dist/cjs/phonetic/Cologne.cjs +1 -2
  23. package/dist/cjs/phonetic/Metaphone.cjs +1 -2
  24. package/dist/cjs/phonetic/Phonetic.cjs +55 -35
  25. package/dist/cjs/phonetic/Soundex.cjs +1 -2
  26. package/dist/cjs/root.cjs +3 -2
  27. package/dist/cjs/utils/DeepMerge.cjs +10 -5
  28. package/dist/cjs/utils/DiffChecker.cjs +1 -2
  29. package/dist/cjs/utils/Errors.cjs +103 -0
  30. package/dist/cjs/utils/Filter.cjs +52 -27
  31. package/dist/cjs/utils/HashTable.cjs +1 -2
  32. package/dist/cjs/utils/Normalizer.cjs +54 -34
  33. package/dist/cjs/utils/Pool.cjs +42 -18
  34. package/dist/cjs/utils/Profiler.cjs +1 -2
  35. package/dist/cjs/utils/Registry.cjs +46 -22
  36. package/dist/cjs/utils/StructuredData.cjs +13 -5
  37. package/dist/cjs/utils/TextAnalyzer.cjs +1 -2
  38. package/dist/esm/CmpStr.mjs +55 -32
  39. package/dist/esm/CmpStrAsync.mjs +26 -20
  40. package/dist/esm/index.mjs +1 -2
  41. package/dist/esm/metric/Cosine.mjs +1 -2
  42. package/dist/esm/metric/DamerauLevenshtein.mjs +1 -2
  43. package/dist/esm/metric/DiceSorensen.mjs +1 -2
  44. package/dist/esm/metric/Hamming.mjs +5 -4
  45. package/dist/esm/metric/Jaccard.mjs +1 -2
  46. package/dist/esm/metric/JaroWinkler.mjs +1 -2
  47. package/dist/esm/metric/LCS.mjs +1 -2
  48. package/dist/esm/metric/Levenshtein.mjs +1 -2
  49. package/dist/esm/metric/Metric.mjs +59 -38
  50. package/dist/esm/metric/NeedlemanWunsch.mjs +1 -2
  51. package/dist/esm/metric/QGram.mjs +1 -2
  52. package/dist/esm/metric/SmithWaterman.mjs +1 -2
  53. package/dist/esm/phonetic/Caverphone.mjs +1 -2
  54. package/dist/esm/phonetic/Cologne.mjs +1 -2
  55. package/dist/esm/phonetic/Metaphone.mjs +1 -2
  56. package/dist/esm/phonetic/Phonetic.mjs +55 -35
  57. package/dist/esm/phonetic/Soundex.mjs +1 -2
  58. package/dist/esm/root.mjs +3 -2
  59. package/dist/esm/utils/DeepMerge.mjs +10 -5
  60. package/dist/esm/utils/DiffChecker.mjs +1 -2
  61. package/dist/esm/utils/Errors.mjs +103 -0
  62. package/dist/esm/utils/Filter.mjs +52 -27
  63. package/dist/esm/utils/HashTable.mjs +1 -2
  64. package/dist/esm/utils/Normalizer.mjs +54 -34
  65. package/dist/esm/utils/Pool.mjs +38 -18
  66. package/dist/esm/utils/Profiler.mjs +1 -2
  67. package/dist/esm/utils/Registry.mjs +46 -22
  68. package/dist/esm/utils/StructuredData.mjs +13 -5
  69. package/dist/esm/utils/TextAnalyzer.mjs +1 -2
  70. package/dist/types/CmpStr.d.ts +5 -1
  71. package/dist/types/CmpStrAsync.d.ts +1 -0
  72. package/dist/types/index.d.ts +3 -2
  73. package/dist/types/metric/Metric.d.ts +6 -5
  74. package/dist/types/phonetic/Phonetic.d.ts +3 -1
  75. package/dist/types/root.d.ts +2 -1
  76. package/dist/types/utils/DeepMerge.d.ts +1 -1
  77. package/dist/types/utils/Errors.d.ts +137 -0
  78. package/dist/types/utils/Filter.d.ts +4 -0
  79. package/dist/types/utils/Normalizer.d.ts +3 -0
  80. package/dist/types/utils/Pool.d.ts +2 -0
  81. package/dist/types/utils/Registry.d.ts +3 -3
  82. package/dist/types/utils/StructuredData.d.ts +3 -1
  83. package/dist/types/utils/Types.d.ts +26 -0
  84. package/package.json +7 -7
  85. package/dist/CmpStr.esm.js.map +0 -1
  86. package/dist/CmpStr.esm.min.js.map +0 -1
  87. package/dist/CmpStr.umd.js.map +0 -1
  88. package/dist/CmpStr.umd.min.js.map +0 -1
  89. package/dist/cjs/CmpStr.cjs.map +0 -1
  90. package/dist/cjs/CmpStrAsync.cjs.map +0 -1
  91. package/dist/cjs/index.cjs.map +0 -1
  92. package/dist/cjs/metric/Cosine.cjs.map +0 -1
  93. package/dist/cjs/metric/DamerauLevenshtein.cjs.map +0 -1
  94. package/dist/cjs/metric/DiceSorensen.cjs.map +0 -1
  95. package/dist/cjs/metric/Hamming.cjs.map +0 -1
  96. package/dist/cjs/metric/Jaccard.cjs.map +0 -1
  97. package/dist/cjs/metric/JaroWinkler.cjs.map +0 -1
  98. package/dist/cjs/metric/LCS.cjs.map +0 -1
  99. package/dist/cjs/metric/Levenshtein.cjs.map +0 -1
  100. package/dist/cjs/metric/Metric.cjs.map +0 -1
  101. package/dist/cjs/metric/NeedlemanWunsch.cjs.map +0 -1
  102. package/dist/cjs/metric/QGram.cjs.map +0 -1
  103. package/dist/cjs/metric/SmithWaterman.cjs.map +0 -1
  104. package/dist/cjs/phonetic/Caverphone.cjs.map +0 -1
  105. package/dist/cjs/phonetic/Cologne.cjs.map +0 -1
  106. package/dist/cjs/phonetic/Metaphone.cjs.map +0 -1
  107. package/dist/cjs/phonetic/Phonetic.cjs.map +0 -1
  108. package/dist/cjs/phonetic/Soundex.cjs.map +0 -1
  109. package/dist/cjs/root.cjs.map +0 -1
  110. package/dist/cjs/utils/DeepMerge.cjs.map +0 -1
  111. package/dist/cjs/utils/DiffChecker.cjs.map +0 -1
  112. package/dist/cjs/utils/Filter.cjs.map +0 -1
  113. package/dist/cjs/utils/HashTable.cjs.map +0 -1
  114. package/dist/cjs/utils/Normalizer.cjs.map +0 -1
  115. package/dist/cjs/utils/Pool.cjs.map +0 -1
  116. package/dist/cjs/utils/Profiler.cjs.map +0 -1
  117. package/dist/cjs/utils/Registry.cjs.map +0 -1
  118. package/dist/cjs/utils/StructuredData.cjs.map +0 -1
  119. package/dist/cjs/utils/TextAnalyzer.cjs.map +0 -1
  120. package/dist/esm/CmpStr.mjs.map +0 -1
  121. package/dist/esm/CmpStrAsync.mjs.map +0 -1
  122. package/dist/esm/index.mjs.map +0 -1
  123. package/dist/esm/metric/Cosine.mjs.map +0 -1
  124. package/dist/esm/metric/DamerauLevenshtein.mjs.map +0 -1
  125. package/dist/esm/metric/DiceSorensen.mjs.map +0 -1
  126. package/dist/esm/metric/Hamming.mjs.map +0 -1
  127. package/dist/esm/metric/Jaccard.mjs.map +0 -1
  128. package/dist/esm/metric/JaroWinkler.mjs.map +0 -1
  129. package/dist/esm/metric/LCS.mjs.map +0 -1
  130. package/dist/esm/metric/Levenshtein.mjs.map +0 -1
  131. package/dist/esm/metric/Metric.mjs.map +0 -1
  132. package/dist/esm/metric/NeedlemanWunsch.mjs.map +0 -1
  133. package/dist/esm/metric/QGram.mjs.map +0 -1
  134. package/dist/esm/metric/SmithWaterman.mjs.map +0 -1
  135. package/dist/esm/phonetic/Caverphone.mjs.map +0 -1
  136. package/dist/esm/phonetic/Cologne.mjs.map +0 -1
  137. package/dist/esm/phonetic/Metaphone.mjs.map +0 -1
  138. package/dist/esm/phonetic/Phonetic.mjs.map +0 -1
  139. package/dist/esm/phonetic/Soundex.mjs.map +0 -1
  140. package/dist/esm/root.mjs.map +0 -1
  141. package/dist/esm/utils/DeepMerge.mjs.map +0 -1
  142. package/dist/esm/utils/DiffChecker.mjs.map +0 -1
  143. package/dist/esm/utils/Filter.mjs.map +0 -1
  144. package/dist/esm/utils/HashTable.mjs.map +0 -1
  145. package/dist/esm/utils/Normalizer.mjs.map +0 -1
  146. package/dist/esm/utils/Pool.mjs.map +0 -1
  147. package/dist/esm/utils/Profiler.mjs.map +0 -1
  148. package/dist/esm/utils/Registry.mjs.map +0 -1
  149. package/dist/esm/utils/StructuredData.mjs.map +0 -1
  150. package/dist/esm/utils/TextAnalyzer.mjs.map +0 -1
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Error Utilities
3
+ * src/utils/Errors.ts
4
+ *
5
+ * This module provides a small hierarchy of error classes and helper methods
6
+ * that standardize error creation and formatting across the CmpStr project.
7
+ * It improves on vanilla JavaScript errors by adding codes, structured metadata,
8
+ * and consistent `toString()` / `toJSON()` output while keeping the original
9
+ * message text intact.
10
+ *
11
+ * The error classes are designed to be lightweight and fast, while still
12
+ * providing useful context for debugging (including optional `cause` chaining).
13
+ *
14
+ * @module Utils
15
+ * @name Errors
16
+ * @author Paul Köhler (komed3)
17
+ * @license MIT
18
+ */
19
+ import type { CmpStrErrorJSON, CmpStrErrorMeta } from './Types';
20
+ /**
21
+ * Base error class for CmpStr.
22
+ *
23
+ * It provides a standard `code` field and a consistent `toString()` / `toJSON()`
24
+ * output without changing the original error message expectations.
25
+ */
26
+ export declare class CmpStrError extends Error {
27
+ /** A short, machine-readable error code */
28
+ readonly code: string;
29
+ /** Optional structured metadata for the error */
30
+ readonly meta?: CmpStrErrorMeta;
31
+ /** Optional cause (native JS Error chaining) */
32
+ readonly cause?: unknown;
33
+ /** Timestamp when the error was created (ISO 8601) */
34
+ readonly when: string;
35
+ /**
36
+ * Constructor for CmpStrError.
37
+ *
38
+ * Will construct an error with a code, message, optional metadata, and optional cause.
39
+ *
40
+ * @param {string} code - A short, machine-readable error code
41
+ * @param {string} message - The error message (human-readable)
42
+ * @param {CmpStrErrorMeta} [meta] - Optional structured metadata for the error
43
+ * @param {unknown} [cause] - Optional cause (native JS Error chaining)
44
+ */
45
+ constructor(code: string, message: string, meta?: CmpStrErrorMeta, cause?: unknown);
46
+ /**
47
+ * Serialize the error into a plain object for JSON output.
48
+ */
49
+ toJSON(): CmpStrErrorJSON;
50
+ /**
51
+ * Pretty string representation of the error.
52
+ *
53
+ * @param {boolean} [stack=false] - Whether to include the stack trace in the output
54
+ */
55
+ toString(stack?: boolean): string;
56
+ }
57
+ /**
58
+ * Error thrown when user input (options, arguments) is invalid.
59
+ */
60
+ export declare class CmpStrValidationError extends CmpStrError {
61
+ constructor(message: string, meta?: CmpStrErrorMeta, cause?: unknown);
62
+ }
63
+ /**
64
+ * Error thrown when a requested resource is missing or not found.
65
+ */
66
+ export declare class CmpStrNotFoundError extends CmpStrError {
67
+ constructor(message: string, meta?: CmpStrErrorMeta, cause?: unknown);
68
+ }
69
+ /**
70
+ * Error thrown for incorrect usage or invalid state (assertions).
71
+ */
72
+ export declare class CmpStrUsageError extends CmpStrError {
73
+ constructor(message: string, meta?: CmpStrErrorMeta, cause?: unknown);
74
+ }
75
+ /**
76
+ * Error thrown for internal failures that should not happen under normal usage.
77
+ */
78
+ export declare class CmpStrInternalError extends CmpStrError {
79
+ constructor(message: string, meta?: CmpStrErrorMeta, cause?: unknown);
80
+ }
81
+ /**
82
+ * Helper utilities for throwing and formatting errors.
83
+ *
84
+ * Provides methods for asserting conditions, wrapping unknown errors, and formatting
85
+ * errors into readable strings. This centralizes error handling logic and ensures
86
+ * consistent error messages across the codebase.
87
+ */
88
+ export declare class ErrorUtil {
89
+ /**
90
+ * Throw a `CmpStrUsageError` if a condition is not met.
91
+ *
92
+ * @param {boolean} condition - The condition to assert
93
+ * @param {string} message - The error message to throw if the condition is false
94
+ * @param {CmpStrErrorMeta} [meta] - Optional structured metadata for the error
95
+ * @throws {CmpStrUsageError} - If the condition is false
96
+ */
97
+ static assert(condition: boolean, message: string, meta?: CmpStrErrorMeta): asserts condition;
98
+ /**
99
+ * Wrap an unknown error into a `CmpStrInternalError`.
100
+ *
101
+ * @param {unknown} err - The error to wrap
102
+ * @param {string} message - The error message to use for the wrapped error
103
+ * @param {CmpStrErrorMeta} [meta] - Optional structured metadata for the error
104
+ * @throws {CmpStrInternalError} - Always throws a new `CmpStrInternalError` wrapping the original error
105
+ */
106
+ static create(err: unknown, message: string, meta?: CmpStrErrorMeta): never;
107
+ /**
108
+ * Format any error into a readable string.
109
+ *
110
+ * @param {unknown} err - The error to format
111
+ * @returns {string} - A formatted string representation of the error
112
+ */
113
+ static format(err: unknown): string;
114
+ /**
115
+ * Execute a synchronous operation and wrap any exception as a `CmpStrInternalError`.
116
+ *
117
+ * This is used to avoid repeating try/catch blocks and to add consistent context
118
+ * to unexpected failures while preserving the original error as `cause`.
119
+ *
120
+ * @param {() => T} fn - The function to execute
121
+ * @param {string} message - The error message to use if an exception is thrown
122
+ * @param {CmpStrErrorMeta} [meta] - Optional structured metadata for the error
123
+ * @return {T} The result of the function if it executes successfully
124
+ * @throws {CmpStrInternalError} - If the function throws an error, it will be wrapped and re-thrown as a `CmpStrInternalError`
125
+ */
126
+ static wrap<T>(fn: () => T, message: string, meta?: CmpStrErrorMeta): T;
127
+ /**
128
+ * Execute an asynchronous operation and wrap any exception as a `CmpStrInternalError`.
129
+ *
130
+ * @param {() => Promise< T >} fn - The asynchronous function to execute
131
+ * @param {string} message - The error message to use if an exception is thrown
132
+ * @param {CmpStrErrorMeta} [meta] - Optional structured metadata for the error
133
+ * @return {Promise<T>} A promise that resolves to the result of the function if it executes successfully
134
+ * @throws {CmpStrInternalError} - If the function throws an error, it will be wrapped and re-thrown as a `CmpStrInternalError`
135
+ */
136
+ static wrapAsync<T>(fn: () => Promise<T>, message: string, meta?: CmpStrErrorMeta): Promise<T>;
137
+ }
@@ -33,6 +33,7 @@ export declare class Filter {
33
33
  *
34
34
  * @param {FilterHooks} hook - The name of the hook
35
35
  * @returns {FilterFn} - The compiled filter function for the hook
36
+ * @throws {CmpStrInternalError} - Throws an error if the pipeline compilation fails
36
37
  */
37
38
  private static getPipeline;
38
39
  /**
@@ -52,6 +53,7 @@ export declare class Filter {
52
53
  * @param {FilterOptions} [opt] - Additional options for the filter
53
54
  * @returns {boolean} - Returns true if the filter was added,
54
55
  * false if it was not added due to override restrictions
56
+ * @throws {CmpStrInternalError} - Throws an error if there is an issue adding the filter
55
57
  */
56
58
  static add(hook: FilterHooks, id: string, fn: FilterFn, opt?: FilterOptions): boolean;
57
59
  /**
@@ -92,6 +94,7 @@ export declare class Filter {
92
94
  * @param {FilterHooks} hook - The name of the hook
93
95
  * @param {string | string[]} input - The input string(s) to be filtered
94
96
  * @returns {string | string[]} - The filtered string(s)
97
+ * @throws {CmpStrInternalError} - Throws an error if there is an issue applying the filters
95
98
  */
96
99
  static apply(hook: FilterHooks, input: string | string[]): string | string[];
97
100
  /**
@@ -101,6 +104,7 @@ export declare class Filter {
101
104
  * @param {FilterHooks} hook - The name of the hook
102
105
  * @param {string | string[]} input - The input string(s) to be filtered
103
106
  * @returns {Promise< string | string[] >} - The filtered string(s)
107
+ * @throws {CmpStrInternalError} - Throws an error if there is an issue applying the filters
104
108
  */
105
109
  static applyAsync(hook: FilterHooks, input: string | string[]): Promise<string | string[]>;
106
110
  /**
@@ -57,6 +57,7 @@ export declare class Normalizer {
57
57
  *
58
58
  * @param {NormalizeFlags} flags - A string of characters representing the normalization steps
59
59
  * @returns {NormalizerFn} - A function that normalizes a string based on the provided flags
60
+ * @throws {CmpStrInternalError} - Throws an error if the pipeline creation fails
60
61
  */
61
62
  private static getPipeline;
62
63
  /**
@@ -66,6 +67,7 @@ export declare class Normalizer {
66
67
  * @param {string | string[]} input - The string or array of strings to normalize
67
68
  * @param {NormalizeFlags} flags - A string of characters representing the normalization steps
68
69
  * @returns {string | string[]} - The normalized string(s)
70
+ * @throws {CmpStrInternalError} - Throws an error if the normalization process fails
69
71
  */
70
72
  static normalize(input: string | string[], flags: NormalizeFlags): string | string[];
71
73
  /**
@@ -76,6 +78,7 @@ export declare class Normalizer {
76
78
  * @param {string | string[]} input - The string or array of strings to normalize
77
79
  * @param {NormalizeFlags} flags - A string of characters representing the normalization steps
78
80
  * @returns {Promise< string | string[] >} - A promise that resolves to the normalized string(s)
81
+ * @throws {CmpStrInternalError} - Throws an error if the normalization process fails
79
82
  */
80
83
  static normalizeAsync(input: string | string[], flags: NormalizeFlags): Promise<string | string[]>;
81
84
  /**
@@ -44,6 +44,7 @@ export declare class Pool {
44
44
  * @param {PoolType} type - The type of buffer to acquire (e.g., 'int32', 'number[]', 'map')
45
45
  * @param {number} size - The size of the buffer to acquire
46
46
  * @return {T} - The acquired buffer of the specified type
47
+ * @throws {CmpStrUsageError} - Throws an error if the pool type is unsupported
47
48
  */
48
49
  static acquire<T = any>(type: PoolType, size: number): T;
49
50
  /**
@@ -61,6 +62,7 @@ export declare class Pool {
61
62
  * @param {PoolType} type - The type of buffer to release
62
63
  * @param {T} buffer - The buffer to release
63
64
  * @param {number} size - The size of the buffer
65
+ * @throws {CmpStrUsageError} - Throws an error if the pool type is unsupported
64
66
  */
65
67
  static release<T = any>(type: PoolType, buffer: T, size: number): void;
66
68
  }
@@ -35,7 +35,7 @@ export declare const factory: Record<string, (cls: string, ...args: any[]) => In
35
35
  * @param {string} reg - The name of the registry
36
36
  * @param {RegistryConstructor< T >} ctor - The base constructor that all registered classes must extend
37
37
  * @returns {RegistryService< T >} - An object with methods to register, remove, check, get, and list classes
38
- * @throws {Error} If the registry already exists (overwriting is forbidden)
38
+ * @throws {Error} - If the registry already exists (overwriting is forbidden)
39
39
  */
40
40
  export declare function Registry<T>(reg: string, ctor: RegistryConstructor<T>): RegistryService<T>;
41
41
  /**
@@ -45,7 +45,7 @@ export declare function Registry<T>(reg: string, ctor: RegistryConstructor<T>):
45
45
  * @param {string} reg - The name of the registry
46
46
  * @param {T | string} cls - The class itself or name of the class to resolve
47
47
  * @returns {T | undefined} - The class constructor if found, otherwise undefined
48
- * @throws {ReferenceError} If the registry does not exist
48
+ * @throws {CmpStrNotFoundError} - If the registry or class does not exist
49
49
  */
50
50
  export declare function resolveCls<T extends RegistryConstructor<any>>(reg: string, cls: T | string): T;
51
51
  /**
@@ -56,6 +56,6 @@ export declare function resolveCls<T extends RegistryConstructor<any>>(reg: stri
56
56
  * @param {T | string} cls - The class itself or name of the class to instantiate
57
57
  * @param {...any} args - Arguments to pass to the class constructor
58
58
  * @returns {T} - An instance of the class
59
- * @throws {Error} If the class cannot be instantiated
59
+ * @throws {CmpStrInternalError} - If instantiation fails due to an internal error
60
60
  */
61
61
  export declare function createFromRegistry<T extends RegistryConstructor<any>>(reg: string, cls: T | string, ...args: any[]): InstanceType<T>;
@@ -80,7 +80,7 @@ export declare class StructuredData<T = any, R = MetricRaw> {
80
80
  *
81
81
  * @param {any} results - The raw metric results
82
82
  * @returns {IndexedResult< R >[]} - Normalized results with indices
83
- * @throws {TypeError} - If results format is unsupported
83
+ * @throws {CmpStrValidationError} - If the results format is unsupported
84
84
  */
85
85
  private normalizeResults;
86
86
  /**
@@ -121,6 +121,7 @@ export declare class StructuredData<T = any, R = MetricRaw> {
121
121
  * @param {string[]} extractedStrings - The extracted strings for index mapping
122
122
  * @param {StructuredDataOptions} [opt] - Additional options
123
123
  * @returns {StructuredDataBatchResult< T, R > | T[]} - The lookup results
124
+ * @throws {CmpStrUsageError} - If the lookup process fails
124
125
  */
125
126
  private performLookup;
126
127
  /**
@@ -130,6 +131,7 @@ export declare class StructuredData<T = any, R = MetricRaw> {
130
131
  * @param {string[]} extractedStrings - The extracted strings for index mapping
131
132
  * @param {StructuredDataOptions} [opt] - Additional options
132
133
  * @returns {Promise< StructuredDataBatchResult< T, R > | T[] >} - The async lookup results
134
+ * @throws {CmpStrUsageError} - If the async lookup process fails
133
135
  */
134
136
  private performLookupAsync;
135
137
  /**
@@ -14,6 +14,32 @@
14
14
  * @author Paul Köhler (komed3)
15
15
  * @license MIT
16
16
  */
17
+ /**
18
+ * ================================================================================
19
+ * ERROR HANDLING
20
+ * ================================================================================
21
+ *
22
+ * Types for standardized error classes and structured error metadata.
23
+ */
24
+ /**
25
+ * Metadata attached to a CmpStr error.
26
+ */
27
+ export type CmpStrErrorMeta = Record<string, any> | undefined;
28
+ /**
29
+ * Structured format for CmpStr errors when serialized to JSON.
30
+ */
31
+ export interface CmpStrErrorJSON {
32
+ name: string;
33
+ code: string;
34
+ message: string;
35
+ meta?: CmpStrErrorMeta;
36
+ when: string;
37
+ cause?: {
38
+ name: string;
39
+ message: string;
40
+ stack?: string;
41
+ } | unknown;
42
+ }
17
43
  /**
18
44
  * ================================================================================
19
45
  * PROFILER & POOL UTILITIES
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "cmpstr",
3
3
  "description": "CmpStr is a lightweight, fast and well performing package for calculating string similarity",
4
4
  "license": "MIT",
5
- "version": "3.2.1",
5
+ "version": "3.2.2",
6
6
  "author": {
7
7
  "name": "komed3 (Paul Köhler)",
8
8
  "email": "webmaster@komed3.de",
@@ -97,19 +97,19 @@
97
97
  "docs": "typedoc --logLevel Verbose --options typedoc.json"
98
98
  },
99
99
  "devDependencies": {
100
- "@rollup/plugin-commonjs": "^29.0.0",
100
+ "@rollup/plugin-commonjs": "^29.0.2",
101
101
  "@rollup/plugin-node-resolve": "^16.0.3",
102
- "@rollup/plugin-terser": "^0.4.4",
102
+ "@rollup/plugin-terser": "^1.0.0",
103
103
  "@rollup/plugin-typescript": "^12.3.0",
104
- "@types/node": "^25.0.10",
104
+ "@types/node": "^25.4.0",
105
105
  "package-verify": "^1.0.3",
106
106
  "prettier": "^3.8.1",
107
- "rollup": "^4.57.0",
107
+ "rollup": "^4.59.0",
108
108
  "rollup-plugin-cleanup": "^3.2.1",
109
109
  "rollup-plugin-prettier": "^4.1.2",
110
110
  "tslib": "^2.8.1",
111
- "typedoc": "^0.28.16",
112
- "typedoc-github-theme": "^0.3.1",
111
+ "typedoc": "^0.28.17",
112
+ "typedoc-github-theme": "^0.4.0",
113
113
  "typescript": "^5.9.3",
114
114
  "vitest": "^4.0.18"
115
115
  }