cmpstr 3.1.1 → 3.2.1

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 (168) hide show
  1. package/README.md +45 -40
  2. package/dist/CmpStr.esm.js +904 -886
  3. package/dist/CmpStr.esm.js.map +1 -1
  4. package/dist/CmpStr.esm.min.js +2 -2
  5. package/dist/CmpStr.esm.min.js.map +1 -1
  6. package/dist/CmpStr.umd.js +917 -889
  7. package/dist/CmpStr.umd.js.map +1 -1
  8. package/dist/CmpStr.umd.min.js +2 -2
  9. package/dist/CmpStr.umd.min.js.map +1 -1
  10. package/dist/cjs/CmpStr.cjs +27 -44
  11. package/dist/cjs/CmpStr.cjs.map +1 -1
  12. package/dist/cjs/CmpStrAsync.cjs +10 -5
  13. package/dist/cjs/CmpStrAsync.cjs.map +1 -1
  14. package/dist/cjs/index.cjs +1 -1
  15. package/dist/cjs/metric/Cosine.cjs +21 -21
  16. package/dist/cjs/metric/Cosine.cjs.map +1 -1
  17. package/dist/cjs/metric/DamerauLevenshtein.cjs +31 -29
  18. package/dist/cjs/metric/DamerauLevenshtein.cjs.map +1 -1
  19. package/dist/cjs/metric/DiceSorensen.cjs +16 -13
  20. package/dist/cjs/metric/DiceSorensen.cjs.map +1 -1
  21. package/dist/cjs/metric/Hamming.cjs +2 -2
  22. package/dist/cjs/metric/Hamming.cjs.map +1 -1
  23. package/dist/cjs/metric/Jaccard.cjs +16 -13
  24. package/dist/cjs/metric/Jaccard.cjs.map +1 -1
  25. package/dist/cjs/metric/JaroWinkler.cjs +45 -43
  26. package/dist/cjs/metric/JaroWinkler.cjs.map +1 -1
  27. package/dist/cjs/metric/LCS.cjs +21 -18
  28. package/dist/cjs/metric/LCS.cjs.map +1 -1
  29. package/dist/cjs/metric/Levenshtein.cjs +21 -18
  30. package/dist/cjs/metric/Levenshtein.cjs.map +1 -1
  31. package/dist/cjs/metric/Metric.cjs +18 -31
  32. package/dist/cjs/metric/Metric.cjs.map +1 -1
  33. package/dist/cjs/metric/NeedlemanWunsch.cjs +27 -24
  34. package/dist/cjs/metric/NeedlemanWunsch.cjs.map +1 -1
  35. package/dist/cjs/metric/{qGram.cjs → QGram.cjs} +18 -15
  36. package/dist/cjs/metric/QGram.cjs.map +1 -0
  37. package/dist/cjs/metric/SmithWaterman.cjs +27 -24
  38. package/dist/cjs/metric/SmithWaterman.cjs.map +1 -1
  39. package/dist/cjs/phonetic/Caverphone.cjs +5 -8
  40. package/dist/cjs/phonetic/Caverphone.cjs.map +1 -1
  41. package/dist/cjs/phonetic/Cologne.cjs +1 -1
  42. package/dist/cjs/phonetic/Cologne.cjs.map +1 -1
  43. package/dist/cjs/phonetic/Metaphone.cjs +6 -3
  44. package/dist/cjs/phonetic/Metaphone.cjs.map +1 -1
  45. package/dist/cjs/phonetic/Phonetic.cjs +23 -16
  46. package/dist/cjs/phonetic/Phonetic.cjs.map +1 -1
  47. package/dist/cjs/phonetic/Soundex.cjs +1 -1
  48. package/dist/cjs/phonetic/Soundex.cjs.map +1 -1
  49. package/dist/cjs/root.cjs +3 -2
  50. package/dist/cjs/root.cjs.map +1 -1
  51. package/dist/cjs/utils/DeepMerge.cjs +73 -42
  52. package/dist/cjs/utils/DeepMerge.cjs.map +1 -1
  53. package/dist/cjs/utils/DiffChecker.cjs +33 -45
  54. package/dist/cjs/utils/DiffChecker.cjs.map +1 -1
  55. package/dist/cjs/utils/Filter.cjs +44 -46
  56. package/dist/cjs/utils/Filter.cjs.map +1 -1
  57. package/dist/cjs/utils/HashTable.cjs +28 -37
  58. package/dist/cjs/utils/HashTable.cjs.map +1 -1
  59. package/dist/cjs/utils/Normalizer.cjs +32 -21
  60. package/dist/cjs/utils/Normalizer.cjs.map +1 -1
  61. package/dist/cjs/utils/Pool.cjs +17 -22
  62. package/dist/cjs/utils/Pool.cjs.map +1 -1
  63. package/dist/cjs/utils/Profiler.cjs +40 -53
  64. package/dist/cjs/utils/Profiler.cjs.map +1 -1
  65. package/dist/cjs/utils/Registry.cjs +6 -4
  66. package/dist/cjs/utils/Registry.cjs.map +1 -1
  67. package/dist/cjs/utils/StructuredData.cjs +23 -25
  68. package/dist/cjs/utils/StructuredData.cjs.map +1 -1
  69. package/dist/cjs/utils/TextAnalyzer.cjs +76 -56
  70. package/dist/cjs/utils/TextAnalyzer.cjs.map +1 -1
  71. package/dist/esm/CmpStr.mjs +22 -44
  72. package/dist/esm/CmpStr.mjs.map +1 -1
  73. package/dist/esm/CmpStrAsync.mjs +5 -5
  74. package/dist/esm/CmpStrAsync.mjs.map +1 -1
  75. package/dist/esm/index.mjs +1 -1
  76. package/dist/esm/metric/Cosine.mjs +21 -21
  77. package/dist/esm/metric/Cosine.mjs.map +1 -1
  78. package/dist/esm/metric/DamerauLevenshtein.mjs +31 -29
  79. package/dist/esm/metric/DamerauLevenshtein.mjs.map +1 -1
  80. package/dist/esm/metric/DiceSorensen.mjs +16 -13
  81. package/dist/esm/metric/DiceSorensen.mjs.map +1 -1
  82. package/dist/esm/metric/Hamming.mjs +2 -2
  83. package/dist/esm/metric/Hamming.mjs.map +1 -1
  84. package/dist/esm/metric/Jaccard.mjs +16 -13
  85. package/dist/esm/metric/Jaccard.mjs.map +1 -1
  86. package/dist/esm/metric/JaroWinkler.mjs +45 -43
  87. package/dist/esm/metric/JaroWinkler.mjs.map +1 -1
  88. package/dist/esm/metric/LCS.mjs +21 -18
  89. package/dist/esm/metric/LCS.mjs.map +1 -1
  90. package/dist/esm/metric/Levenshtein.mjs +21 -18
  91. package/dist/esm/metric/Levenshtein.mjs.map +1 -1
  92. package/dist/esm/metric/Metric.mjs +19 -32
  93. package/dist/esm/metric/Metric.mjs.map +1 -1
  94. package/dist/esm/metric/NeedlemanWunsch.mjs +27 -24
  95. package/dist/esm/metric/NeedlemanWunsch.mjs.map +1 -1
  96. package/dist/esm/metric/QGram.mjs +38 -0
  97. package/dist/esm/metric/QGram.mjs.map +1 -0
  98. package/dist/esm/metric/SmithWaterman.mjs +27 -24
  99. package/dist/esm/metric/SmithWaterman.mjs.map +1 -1
  100. package/dist/esm/phonetic/Caverphone.mjs +5 -8
  101. package/dist/esm/phonetic/Caverphone.mjs.map +1 -1
  102. package/dist/esm/phonetic/Cologne.mjs +1 -1
  103. package/dist/esm/phonetic/Cologne.mjs.map +1 -1
  104. package/dist/esm/phonetic/Metaphone.mjs +6 -3
  105. package/dist/esm/phonetic/Metaphone.mjs.map +1 -1
  106. package/dist/esm/phonetic/Phonetic.mjs +24 -17
  107. package/dist/esm/phonetic/Phonetic.mjs.map +1 -1
  108. package/dist/esm/phonetic/Soundex.mjs +1 -1
  109. package/dist/esm/phonetic/Soundex.mjs.map +1 -1
  110. package/dist/esm/root.mjs +3 -3
  111. package/dist/esm/utils/DeepMerge.mjs +73 -42
  112. package/dist/esm/utils/DeepMerge.mjs.map +1 -1
  113. package/dist/esm/utils/DiffChecker.mjs +33 -45
  114. package/dist/esm/utils/DiffChecker.mjs.map +1 -1
  115. package/dist/esm/utils/Filter.mjs +44 -46
  116. package/dist/esm/utils/Filter.mjs.map +1 -1
  117. package/dist/esm/utils/HashTable.mjs +28 -38
  118. package/dist/esm/utils/HashTable.mjs.map +1 -1
  119. package/dist/esm/utils/Normalizer.mjs +32 -21
  120. package/dist/esm/utils/Normalizer.mjs.map +1 -1
  121. package/dist/esm/utils/Pool.mjs +17 -22
  122. package/dist/esm/utils/Pool.mjs.map +1 -1
  123. package/dist/esm/utils/Profiler.mjs +40 -53
  124. package/dist/esm/utils/Profiler.mjs.map +1 -1
  125. package/dist/esm/utils/Registry.mjs +6 -4
  126. package/dist/esm/utils/Registry.mjs.map +1 -1
  127. package/dist/esm/utils/StructuredData.mjs +23 -25
  128. package/dist/esm/utils/StructuredData.mjs.map +1 -1
  129. package/dist/esm/utils/TextAnalyzer.mjs +76 -56
  130. package/dist/esm/utils/TextAnalyzer.mjs.map +1 -1
  131. package/dist/types/CmpStr.d.ts +62 -59
  132. package/dist/types/CmpStrAsync.d.ts +49 -48
  133. package/dist/types/index.d.ts +2 -2
  134. package/dist/types/metric/Cosine.d.ts +9 -6
  135. package/dist/types/metric/DamerauLevenshtein.d.ts +6 -3
  136. package/dist/types/metric/DiceSorensen.d.ts +7 -4
  137. package/dist/types/metric/Hamming.d.ts +6 -3
  138. package/dist/types/metric/Jaccard.d.ts +5 -2
  139. package/dist/types/metric/JaroWinkler.d.ts +6 -3
  140. package/dist/types/metric/LCS.d.ts +5 -2
  141. package/dist/types/metric/Levenshtein.d.ts +6 -3
  142. package/dist/types/metric/Metric.d.ts +24 -21
  143. package/dist/types/metric/NeedlemanWunsch.d.ts +6 -3
  144. package/dist/types/metric/{qGram.d.ts → QGram.d.ts} +7 -4
  145. package/dist/types/metric/SmithWaterman.d.ts +6 -3
  146. package/dist/types/metric/index.d.ts +3 -2
  147. package/dist/types/phonetic/Caverphone.d.ts +7 -3
  148. package/dist/types/phonetic/Cologne.d.ts +3 -1
  149. package/dist/types/phonetic/Metaphone.d.ts +5 -1
  150. package/dist/types/phonetic/Phonetic.d.ts +15 -10
  151. package/dist/types/phonetic/Soundex.d.ts +3 -1
  152. package/dist/types/phonetic/index.d.ts +2 -1
  153. package/dist/types/root.d.ts +7 -7
  154. package/dist/types/utils/DeepMerge.d.ts +6 -4
  155. package/dist/types/utils/DiffChecker.d.ts +11 -8
  156. package/dist/types/utils/Filter.d.ts +49 -28
  157. package/dist/types/utils/HashTable.d.ts +46 -11
  158. package/dist/types/utils/Normalizer.d.ts +15 -5
  159. package/dist/types/utils/Pool.d.ts +7 -4
  160. package/dist/types/utils/Profiler.d.ts +33 -17
  161. package/dist/types/utils/Registry.d.ts +13 -9
  162. package/dist/types/utils/StructuredData.d.ts +40 -29
  163. package/dist/types/utils/TextAnalyzer.d.ts +40 -15
  164. package/dist/types/utils/Types.d.ts +105 -17
  165. package/package.json +13 -6
  166. package/dist/cjs/metric/qGram.cjs.map +0 -1
  167. package/dist/esm/metric/qGram.mjs +0 -35
  168. package/dist/esm/metric/qGram.mjs.map +0 -1
@@ -21,10 +21,11 @@
21
21
  * implement the `compute` method to define the specific metric computation logic.
22
22
  *
23
23
  * @module Metric
24
+ * @name Metric
24
25
  * @author Paul Köhler (komed3)
25
26
  * @license MIT
26
27
  */
27
- import type { MetricMode, MetricInput, MetricOptions, MetricCompute, MetricRaw, MetricResult, RegistryService } from '../utils/Types';
28
+ import type { MetricCompute, MetricInput, MetricMode, MetricOptions, MetricRaw, MetricResult, RegistryService } from '../utils/Types';
28
29
  /**
29
30
  * Abstract class representing a generic string metric.
30
31
  *
@@ -32,13 +33,20 @@ import type { MetricMode, MetricInput, MetricOptions, MetricCompute, MetricRaw,
32
33
  * @template R - The type of the raw result, defaulting to `MetricRaw`.
33
34
  */
34
35
  export declare abstract class Metric<R = MetricRaw> {
36
+ /** Cache for metric computations to avoid redundant calculations */
35
37
  private static cache;
38
+ /** Metric name for identification */
36
39
  private readonly metric;
40
+ /** Inputs for the metric computation, transformed into arrays */
37
41
  private readonly a;
38
42
  private readonly b;
43
+ /** Store original inputs for result mapping */
39
44
  private origA;
40
45
  private origB;
46
+ /** Options for the metric computation, such as performance tracking */
41
47
  protected readonly options: MetricOptions;
48
+ protected readonly optKey: string;
49
+ /** Indicates whether the metric is symmetric (same result for inputs in any order) */
42
50
  protected readonly symmetric: boolean;
43
51
  /**
44
52
  * Result of the metric computation, which can be a single result or an array of results.
@@ -48,7 +56,7 @@ export declare abstract class Metric<R = MetricRaw> {
48
56
  /**
49
57
  * Static method to clear the cache of metric computations.
50
58
  */
51
- static clear(): void;
59
+ static clear: () => void;
52
60
  /**
53
61
  * Swaps two strings and their lengths if the first is longer than the second.
54
62
  *
@@ -56,21 +64,16 @@ export declare abstract class Metric<R = MetricRaw> {
56
64
  * @param {string} b - Second string
57
65
  * @param {number} m - Length of the first string
58
66
  * @param {number} n - Length of the second string
59
- * @returns {[string, string, number, number]} - Swapped strings and lengths
67
+ * @returns {[ string, string, number, number ]} - Swapped strings and lengths
60
68
  */
61
- protected static swap(a: string, b: string, m: number, n: number): [
62
- string,
63
- string,
64
- number,
65
- number
66
- ];
69
+ protected static swap: (a: string, b: string, m: number, n: number) => [string, string, number, number];
67
70
  /**
68
71
  * Clamps the similarity result between 0 and 1.
69
72
  *
70
73
  * @param {number} res - The input similarity to clamp
71
74
  * @returns {number} - The clamped similarity (0 to 1)
72
75
  */
73
- protected static clamp(res: number): number;
76
+ protected static clamp: (res: number) => number;
74
77
  /**
75
78
  * Constructor for the Metric class.
76
79
  * Initializes the metric with two inputs (strings or arrays of strings) and options.
@@ -91,7 +94,7 @@ export declare abstract class Metric<R = MetricRaw> {
91
94
  * @param {string} b - Second string
92
95
  * @param {number} m - Length of the first string
93
96
  * @param {number} n - Length of the second string
94
- * @returns {MetricCompute<R>|undefined} - Pre-computed result or undefined if not applicable
97
+ * @returns {MetricCompute< R > | undefined} - Pre-computed result or undefined if not applicable
95
98
  */
96
99
  protected preCompute(a: string, b: string, m: number, n: number): MetricCompute<R> | undefined;
97
100
  /**
@@ -103,7 +106,7 @@ export declare abstract class Metric<R = MetricRaw> {
103
106
  * @param {number} m - Length of the first string
104
107
  * @param {number} n - Length of the second string
105
108
  * @param {number} maxLen - Maximum length of the strings
106
- * @returns {MetricCompute<R>} - The result of the metric computation
109
+ * @returns {MetricCompute< R >} - The result of the metric computation
107
110
  * @throws {Error} - If not overridden in a subclass
108
111
  */
109
112
  protected compute(a: string, b: string, m: number, n: number, maxLen: number): MetricCompute<R>;
@@ -115,7 +118,7 @@ export declare abstract class Metric<R = MetricRaw> {
115
118
  *
116
119
  * @param {number} i - Pointer to the first string
117
120
  * @param {number} j - Pointer to the second string
118
- * @returns {MetricResultSingle<R>} - The result of the metric computation
121
+ * @returns {MetricResultSingle< R >} - The result of the metric computation
119
122
  */
120
123
  private runSingle;
121
124
  /**
@@ -123,7 +126,7 @@ export declare abstract class Metric<R = MetricRaw> {
123
126
  *
124
127
  * @param {number} i - Pointer to the first string
125
128
  * @param {number} j - Pointer to the second string
126
- * @returns {Promise<MetricResultSingle<R>>} - Promise resolving the result of the metric computation
129
+ * @returns {Promise< MetricResultSingle< R > >} - Promise resolving the result of the metric computation
127
130
  */
128
131
  private runSingleAsync;
129
132
  /**
@@ -163,7 +166,7 @@ export declare abstract class Metric<R = MetricRaw> {
163
166
  *
164
167
  * @returns {boolean} - True if either input is an array with more than one element
165
168
  */
166
- isBatch(): boolean;
169
+ isBatch: () => boolean;
167
170
  /**
168
171
  * Check if the inputs are in single mode.
169
172
  *
@@ -172,7 +175,7 @@ export declare abstract class Metric<R = MetricRaw> {
172
175
  *
173
176
  * @returns {boolean} - True if both inputs are single strings
174
177
  */
175
- isSingle(): boolean;
178
+ isSingle: () => boolean;
176
179
  /**
177
180
  * Check if the inputs are in pairwise mode.
178
181
  *
@@ -192,7 +195,7 @@ export declare abstract class Metric<R = MetricRaw> {
192
195
  *
193
196
  * @returns {boolean} - True if the metric is symmetric
194
197
  */
195
- isSymmetrical(): boolean;
198
+ isSymmetrical: () => boolean;
196
199
  /**
197
200
  * Determine which mode to run the metric in.
198
201
  *
@@ -202,7 +205,7 @@ export declare abstract class Metric<R = MetricRaw> {
202
205
  * @param {MetricMode} [mode] - The mode to run the metric in (optional)
203
206
  * @returns {MetricMode} - The determined mode
204
207
  */
205
- whichMode(mode?: MetricMode): MetricMode;
208
+ whichMode: (mode?: MetricMode) => MetricMode;
206
209
  /**
207
210
  * Clear the cached results of the metric.
208
211
  *
@@ -210,7 +213,7 @@ export declare abstract class Metric<R = MetricRaw> {
210
213
  * any previously computed results. It can be useful for re-running the metric
211
214
  * with new inputs or options.
212
215
  */
213
- clear(): void;
216
+ clear: () => void;
214
217
  /**
215
218
  * Run the metric computation based on the specified mode.
216
219
  *
@@ -233,11 +236,11 @@ export declare abstract class Metric<R = MetricRaw> {
233
236
  *
234
237
  * @returns {string} - The name of the metric
235
238
  */
236
- getMetricName(): string;
239
+ getMetricName: () => string;
237
240
  /**
238
241
  * Get the result of the metric computation.
239
242
  *
240
- * @returns {MetricResult<R>} - The result of the metric computation
243
+ * @returns {MetricResult< R >} - The result of the metric computation
241
244
  * @throws {Error} - If `run()` has not been called before this method
242
245
  */
243
246
  getResults(): MetricResult<R>;
@@ -8,11 +8,12 @@
8
8
  * entirely, including gaps. It is commonly used in bioinformatics for sequence
9
9
  * alignment.
10
10
  *
11
- * @module Metric/NeedlemanWunsch
11
+ * @module Metric
12
+ * @name NeedlemanWunsch
12
13
  * @author Paul Köhler (komed3)
13
14
  * @license MIT
14
15
  */
15
- import type { MetricInput, MetricOptions, MetricCompute } from '../utils/Types';
16
+ import type { MetricCompute, MetricInput, MetricOptions } from '../utils/Types';
16
17
  import { Metric } from './Metric';
17
18
  export interface NeedlemanRaw {
18
19
  score: number;
@@ -28,6 +29,8 @@ export declare class NeedlemanWunschDistance extends Metric<NeedlemanRaw> {
28
29
  * Initializes the Needleman-Wunsch metric with two input strings or
29
30
  * arrays of strings and optional options.
30
31
  *
32
+ * Metric is symmetrical.
33
+ *
31
34
  * @param {MetricInput} a - First input string or array of strings
32
35
  * @param {MetricInput} b - Second input string or array of strings
33
36
  * @param {MetricOptions} [opt] - Options for the metric computation
@@ -41,7 +44,7 @@ export declare class NeedlemanWunschDistance extends Metric<NeedlemanRaw> {
41
44
  * @param {number} m - Length of the first string
42
45
  * @param {number} n - Length of the second string
43
46
  * @param {number} maxLen - Maximum length of the strings
44
- * @return {MetricCompute<NeedlemanRaw>} - Object containing the similarity result and raw score
47
+ * @return {MetricCompute< NeedlemanRaw >} - Object containing the similarity result and raw score
45
48
  */
46
49
  protected compute(a: string, b: string, m: number, n: number, maxLen: number): MetricCompute<NeedlemanRaw>;
47
50
  }
@@ -12,11 +12,12 @@
12
12
  * This metric is widely used in approximate string matching, information retrieval,
13
13
  * and computational linguistics.
14
14
  *
15
- * @module Metric/QGramSimilarity
15
+ * @module Metric
16
+ * @name QGramSimilarity
16
17
  * @author Paul Köhler (komed3)
17
18
  * @license MIT
18
19
  */
19
- import type { MetricInput, MetricOptions, MetricCompute } from '../utils/Types';
20
+ import type { MetricCompute, MetricInput, MetricOptions } from '../utils/Types';
20
21
  import { Metric } from './Metric';
21
22
  export interface QGramRaw {
22
23
  intersection: number;
@@ -32,6 +33,8 @@ export declare class QGramSimilarity extends Metric<QGramRaw> {
32
33
  * Initializes the q-Gram similarity metric with two input strings or
33
34
  * arrays of strings and optional options.
34
35
  *
36
+ * Metric is symmetrical.
37
+ *
35
38
  * @param {MetricInput} a - First input string or array of strings
36
39
  * @param {MetricInput} b - Second input string or array of strings
37
40
  * @param {MetricOptions} [opt] - Options for the metric computation
@@ -42,7 +45,7 @@ export declare class QGramSimilarity extends Metric<QGramRaw> {
42
45
  *
43
46
  * @param {string} str - The input string
44
47
  * @param {number} q - The length of each q-gram
45
- * @return {Set<string>} - Set of q-grams
48
+ * @return {Set< string >} - Set of q-grams
46
49
  */
47
50
  private _qGrams;
48
51
  /**
@@ -50,7 +53,7 @@ export declare class QGramSimilarity extends Metric<QGramRaw> {
50
53
  *
51
54
  * @param {string} a - First string
52
55
  * @param {string} b - Second string
53
- * @return {MetricCompute<QGramRaw>} - Object containing the similarity result and raw values
56
+ * @return {MetricCompute< QGramRaw >} - Object containing the similarity result and raw values
54
57
  */
55
58
  protected compute(a: string, b: string): MetricCompute<QGramRaw>;
56
59
  }
@@ -10,11 +10,12 @@
10
10
  * algorithm compares segments of all possible lengths and optimizes the similarity
11
11
  * measure.
12
12
  *
13
- * @module Metric/SmithWatermanDistance
13
+ * @module Metric
14
+ * @name SmithWatermanDistance
14
15
  * @author Paul Köhler (komed3)
15
16
  * @license MIT
16
17
  */
17
- import type { MetricInput, MetricOptions, MetricCompute } from '../utils/Types';
18
+ import type { MetricCompute, MetricInput, MetricOptions } from '../utils/Types';
18
19
  import { Metric } from './Metric';
19
20
  export interface SmithWatermanRaw {
20
21
  score: number;
@@ -30,6 +31,8 @@ export declare class SmithWatermanDistance extends Metric<SmithWatermanRaw> {
30
31
  * Initializes the Smith-Waterman metric with two input strings or
31
32
  * arrays of strings and optional options.
32
33
  *
34
+ * Metric is symmetrical.
35
+ *
33
36
  * @param {MetricInput} a - First input string or array of strings
34
37
  * @param {MetricInput} b - Second input string or array of strings
35
38
  * @param {MetricOptions} [opt] - Options for the metric computation
@@ -42,7 +45,7 @@ export declare class SmithWatermanDistance extends Metric<SmithWatermanRaw> {
42
45
  * @param {string} b - Second string
43
46
  * @param {number} m - Length of the first string
44
47
  * @param {number} n - Length of the second string
45
- * @return {MetricCompute<SmithWatermanRaw>} - Object containing the similarity result and raw score
48
+ * @return {MetricCompute< SmithWatermanRaw >} - Object containing the similarity result and raw score
46
49
  */
47
50
  protected compute(a: string, b: string, m: number, n: number): MetricCompute<SmithWatermanRaw>;
48
51
  }
@@ -24,6 +24,7 @@
24
24
  * pooling system to manage resources effectively, ensuring minimal overhead
25
25
  * and maximum performance.
26
26
  *
27
+ * @module Metric
27
28
  * @author Paul Köhler (komed3)
28
29
  * @license MIT
29
30
  */
@@ -36,6 +37,6 @@ import './JaroWinkler';
36
37
  import './LCS';
37
38
  import './Levenshtein';
38
39
  import './NeedlemanWunsch';
39
- import './qGram';
40
+ import './QGram';
40
41
  import './SmithWaterman';
41
- export { MetricRegistry, Metric, MetricCls } from './Metric';
42
+ export { Metric, MetricCls, MetricRegistry } from './Metric';
@@ -12,7 +12,8 @@
12
12
  * It converts words into a standardized phonetic code, allowing for variations
13
13
  * in spelling and pronunciation to be matched.
14
14
  *
15
- * @module Phonetic/Caverphone
15
+ * @module Phonetic
16
+ * @name Caverphone
16
17
  * @author Paul Köhler (komed3)
17
18
  * @license MIT
18
19
  */
@@ -22,6 +23,9 @@ import { Phonetic } from './Phonetic';
22
23
  * Caverphone class extends the Phonetic class to implement the Caverphone phonetic algorithm.
23
24
  */
24
25
  export declare class Caverphone extends Phonetic {
26
+ /** Regular expressions used in the Caverphone algorithm */
27
+ private static readonly REGEX;
28
+ /** Default options for the Caverphone phonetic algorithm */
25
29
  protected static default: PhoneticOptions;
26
30
  /**
27
31
  * Constructor for the Caverphone class.
@@ -44,12 +48,12 @@ export declare class Caverphone extends Phonetic {
44
48
  * @param {string} char - The character to be mapped
45
49
  * @returns {string} - The mapped character
46
50
  */
47
- protected mapChar(char: string): string;
51
+ protected mapChar: (char: string) => string;
48
52
  /**
49
53
  * Adjusts the phonetic code to uppercase.
50
54
  *
51
55
  * @param {string} code - The phonetic code to adjust
52
56
  * @returns {string} - The adjusted phonetic code
53
57
  */
54
- protected adjustCode(code: string): string;
58
+ protected adjustCode: (code: string) => string;
55
59
  }
@@ -17,7 +17,8 @@
17
17
  * The Cologne phonetic algorithm works by mapping letters to digits, ignoring
18
18
  * certain letters, and applying specific rules to handle character combinations.
19
19
  *
20
- * @module Phonetic/Cologne
20
+ * @module Phonetic
21
+ * @name Cologne
21
22
  * @author Paul Köhler (komed3)
22
23
  * @license MIT
23
24
  */
@@ -27,6 +28,7 @@ import { Phonetic } from './Phonetic';
27
28
  * Cologne class extends the Phonetic class to implement the Cologne phonetic algorithm.
28
29
  */
29
30
  export declare class Cologne extends Phonetic {
31
+ /** Default options for the Cologne phonetic algorithm */
30
32
  protected static default: PhoneticOptions;
31
33
  /**
32
34
  * Constructor for the Cologne class.
@@ -14,7 +14,8 @@
14
14
  * transform input words into their Metaphone code. The algorithm drops or transforms
15
15
  * letters according to context-sensitive rules, and only retains vowels at the start.
16
16
  *
17
- * @module Phonetic/Metaphone
17
+ * @module Phonetic
18
+ * @name Metaphone
18
19
  * @author Paul Köhler (komed3)
19
20
  * @license MIT
20
21
  */
@@ -24,6 +25,9 @@ import { Phonetic } from './Phonetic';
24
25
  * Metaphone class extends the Phonetic class to implement the Metaphone phonetic algorithm.
25
26
  */
26
27
  export declare class Metaphone extends Phonetic {
28
+ /** Regular expressions used in the Metaphone algorithm */
29
+ private static readonly REGEX;
30
+ /** Default options for the Metaphone phonetic algorithm */
27
31
  protected static default: PhoneticOptions;
28
32
  /**
29
33
  * Constructor for the Metaphone class.
@@ -19,10 +19,11 @@
19
19
  * phonetic algorithms by extending the abstract class.
20
20
  *
21
21
  * @module Phonetic
22
+ * @name Phonetic
22
23
  * @author Paul Köhler (komed3)
23
24
  * @license MIT
24
25
  */
25
- import type { PhoneticMap, PhoneticOptions, RegistryService, PhoneticMappingService } from '../utils/Types';
26
+ import type { PhoneticMap, PhoneticMappingService, PhoneticOptions, RegistryService } from '../utils/Types';
26
27
  /**
27
28
  * Abstract class representing a phonetic algorithm.
28
29
  *
@@ -33,6 +34,7 @@ import type { PhoneticMap, PhoneticOptions, RegistryService, PhoneticMappingServ
33
34
  * @abstract
34
35
  */
35
36
  export declare abstract class Phonetic {
37
+ /** Cache for indexed words to avoid redundant calculations */
36
38
  private static cache;
37
39
  /**
38
40
  * Default phonetic options.
@@ -41,13 +43,16 @@ export declare abstract class Phonetic {
41
43
  * implemented in the subclass.
42
44
  */
43
45
  protected static default: PhoneticOptions;
46
+ /** Phonetic algorithm name for identification */
44
47
  private readonly algo;
48
+ /** Phonetic map and options for the algorithm */
45
49
  protected readonly options: PhoneticOptions;
50
+ protected readonly optKey: string;
46
51
  protected readonly map: PhoneticMap;
47
52
  /**
48
53
  * Static method to clear the cache of indexed words.
49
54
  */
50
- static clear(): void;
55
+ static clear: () => void;
51
56
  /**
52
57
  * Constructor for the Phonetic class.
53
58
  *
@@ -81,7 +86,7 @@ export declare abstract class Phonetic {
81
86
  * @param {number} i - The current position within the word
82
87
  * @param {string[]} chars - The word as an array of characters
83
88
  * @param {number} charLen - The total length of the word
84
- * @returns {string|undefined} - The rule code or undefined if no rule applies
89
+ * @returns {string | undefined} - The rule code or undefined if no rule applies
85
90
  */
86
91
  protected applyRules(char: string, i: number, chars: string[], charLen: number): string | undefined;
87
92
  /**
@@ -101,9 +106,9 @@ export declare abstract class Phonetic {
101
106
  * @param {number} i - The current position within the word
102
107
  * @param {string[]} chars - The word as an array of characters
103
108
  * @param {number} charLen - The total length of the word
104
- * @param {string|null} lastCode - The last code generated (to avoid duplicates)
105
- * @param {Record<string, string>} map - The phonetic mapping
106
- * @returns {string|undefined} - The phonetic code or undefined if no code applies
109
+ * @param {string | null} lastCode - The last code generated (to avoid duplicates)
110
+ * @param {Record< string, string >} map - The phonetic mapping
111
+ * @returns {string | undefined} - The phonetic code or undefined if no code applies
107
112
  */
108
113
  protected mapChar(char: string, i: number, chars: string[], charLen: number, lastCode: string | null, map: Record<string, string>): string | undefined;
109
114
  /**
@@ -119,7 +124,7 @@ export declare abstract class Phonetic {
119
124
  * @param {string} word - The input word to be converted
120
125
  * @returns {string[]} - An array of characters from the input word
121
126
  */
122
- protected word2Chars(word: string): string[];
127
+ protected word2Chars: (word: string) => string[];
123
128
  /**
124
129
  * Determines whether to exit early based on the current phonetic code length.
125
130
  *
@@ -153,7 +158,7 @@ export declare abstract class Phonetic {
153
158
  * and ensures that the resulting codes are of equal length.
154
159
  *
155
160
  * @param {string[]} words - An array of words to be processed
156
- * @returns {Promise<string[]>} - A promise that resolves to an array of phonetic indices for the input words
161
+ * @returns {Promise< string[] >} - A promise that resolves to an array of phonetic indices for the input words
157
162
  */
158
163
  protected loopAsync(words: string[]): Promise<string[]>;
159
164
  /**
@@ -161,7 +166,7 @@ export declare abstract class Phonetic {
161
166
  *
162
167
  * @returns {string} - The name of the algorithm
163
168
  */
164
- getAlgoName(): string;
169
+ getAlgoName: () => string;
165
170
  /**
166
171
  * Generates a phonetic index for the given input string.
167
172
  *
@@ -173,7 +178,7 @@ export declare abstract class Phonetic {
173
178
  * Asynchronously generates a phonetic index for the given input string.
174
179
  *
175
180
  * @param {string} input - The input string to be indexed
176
- * @returns {Promise<string[]>} - A promise that resolves to an array of phonetic indices for the input words
181
+ * @returns {Promise< string[] >} - A promise that resolves to an array of phonetic indices for the input words
177
182
  */
178
183
  getIndexAsync(input: string): Promise<string[]>;
179
184
  }
@@ -18,7 +18,8 @@
18
18
  * consonants. It outputs an array of strings that represents the phonetic code
19
19
  * of the input, typically limited to the length of four characters.
20
20
  *
21
- * @module Phonetic/Soundex
21
+ * @module Phonetic
22
+ * @name Soundex
22
23
  * @author Paul Köhler (komed3)
23
24
  * @license MIT
24
25
  */
@@ -28,6 +29,7 @@ import { Phonetic } from './Phonetic';
28
29
  * Soundex class extends the Phonetic class to implement the Soundex phonetic algorithm.
29
30
  */
30
31
  export declare class Soundex extends Phonetic {
32
+ /** Default options for the Soundex phonetic algorithm */
31
33
  protected static default: PhoneticOptions;
32
34
  /**
33
35
  * Constructor for the Soundex class.
@@ -21,6 +21,7 @@
21
21
  * - Consistent interface for accessing, listing, and managing phonetic algorithms
22
22
  * - Ensures that all phonetic algorithms are available for use in the CmpStr API
23
23
  *
24
+ * @module Phonetic
24
25
  * @author Paul Köhler (komed3)
25
26
  * @license MIT
26
27
  */
@@ -28,4 +29,4 @@ import './Caverphone';
28
29
  import './Cologne';
29
30
  import './Metaphone';
30
31
  import './Soundex';
31
- export { PhoneticRegistry, PhoneticMappingRegistry, Phonetic, PhoneticCls } from './Phonetic';
32
+ export { Phonetic, PhoneticCls, PhoneticMappingRegistry, PhoneticRegistry } from './Phonetic';
@@ -9,7 +9,7 @@
9
9
  * Please visit CmpStr's documentation for more information:
10
10
  * https://github.com/komed3/cmpstr/wiki/Extending-CmpStr
11
11
  *
12
- * @version 3.1.1
12
+ * @version 3.2.1
13
13
  * @author Paul Köhler (komed3)
14
14
  * @license MIT
15
15
  */
@@ -17,23 +17,23 @@ export * from './index';
17
17
  /**
18
18
  * Export utils to implement new metrics
19
19
  *
20
- * - MetricRegistry: Metric registry service for managing metric implementations.
21
20
  * - Metric: Abstract class representing a generic string metric.
22
21
  * - MetricCls: Type definition for a class constructor that extends the Metric class.
22
+ * - MetricRegistry: Metric registry service for managing metric implementations.
23
23
  */
24
- export { MetricRegistry, Metric, MetricCls } from './metric';
24
+ export { Metric, MetricCls, MetricRegistry } from './metric';
25
25
  /**
26
26
  * Export utils to implement new phonetic algorithms
27
27
  *
28
- * - PhoneticRegistry: Phonetic registry service for managing phonetic algorithm implementations.
29
- * - PhoneticMappingRegistry: Registry for managing phonetic character mappings.
30
28
  * - Phonetic: Abstract class representing a generic phonetic algorithm.
31
29
  * - PhoneticCls: Type definition for a class constructor that extends the Phonetic class.
30
+ * - PhoneticMappingRegistry: Registry for managing phonetic character mappings.
31
+ * - PhoneticRegistry: Phonetic registry service for managing phonetic algorithm implementations.
32
32
  */
33
- export { PhoneticRegistry, PhoneticMappingRegistry, Phonetic, PhoneticCls } from './phonetic';
33
+ export { Phonetic, PhoneticCls, PhoneticMappingRegistry, PhoneticRegistry } from './phonetic';
34
34
  export * as DeepMerge from './utils/DeepMerge';
35
35
  export { Filter } from './utils/Filter';
36
- export { HashTable } from './utils/HashTable';
36
+ export { Hasher, HashTable } from './utils/HashTable';
37
37
  export { Pool } from './utils/Pool';
38
38
  export { Profiler } from './utils/Profiler';
39
39
  export { StructuredData } from './utils/StructuredData';
@@ -14,7 +14,8 @@
14
14
  * - `has`: Check whether a path exists
15
15
  * - `rmv`: Delete a value at a path
16
16
  *
17
- * @module Utils/DeepMerge
17
+ * @module Utils
18
+ * @name DeepMerge
18
19
  * @author Paul Köhler
19
20
  * @license MIT
20
21
  */
@@ -22,12 +23,13 @@
22
23
  * Deeply get a value from an object by a path string.
23
24
  *
24
25
  * @template T - The type of the object to get the value from
26
+ * @template R - The return type of the value
25
27
  * @param {T} t - The object to get the value from
26
28
  * @param {string} path - The path string, e.g. `a.b.c`
27
- * @param {any} fallback - The default value to return if the path does not exist
28
- * @returns {T|R|undefined} - The value at the specified path, otherwise the default value
29
+ * @param {any} fb - The default value to return if the path does not exist
30
+ * @returns {R | undefined} - The value at the specified path, otherwise the default value
29
31
  */
30
- export declare function get<T extends Record<string, any>, R = any>(t: T, path: string, fallback?: any): T | R | undefined;
32
+ export declare function get<T extends Record<string, any>, R = any>(t: T, path: string, fb?: R): R | undefined;
31
33
  /**
32
34
  * Check if a path exists in an object.
33
35
  *
@@ -20,21 +20,25 @@
20
20
  * - Change magnitude calculation (relative to group or line)
21
21
  * - Expand-all mode for full file context
22
22
  *
23
- * @module Utils/DiffChecker
23
+ * @module Utils
24
+ * @name DiffChecker
24
25
  * @author Paul Köhler (komed3)
25
26
  * @license MIT
26
27
  */
27
- import type { DiffOptions, DiffLine, DiffGroup } from './Types';
28
+ import type { DiffGroup, DiffLine, DiffOptions } from './Types';
28
29
  /**
29
30
  * The DiffChecker class provides methods to compare two texts and generate
30
31
  * structured diffs, grouped diffs, and unified diff outputs.
31
32
  */
32
33
  export declare class DiffChecker {
34
+ /** Original input texts and options */
33
35
  private readonly a;
34
36
  private readonly b;
35
37
  private readonly options;
38
+ /** Computed diff entries and groups */
36
39
  private entries;
37
40
  private grouped;
41
+ /** Flag to indicate if the diff has already been computed */
38
42
  private diffRun;
39
43
  /**
40
44
  * Constructs a new DiffChecker instance for comparing two texts.
@@ -45,8 +49,7 @@ export declare class DiffChecker {
45
49
  */
46
50
  constructor(a: string, b: string, opt?: DiffOptions);
47
51
  /**
48
- * Splits both input texts into arrays of lines and returns them
49
- * with the maximum line count.
52
+ * Splits both input texts into arrays of lines and returns them with the maximum line count.
50
53
  *
51
54
  * @returns { linesA: string[], linesB: string[], maxLen: number }
52
55
  */
@@ -115,23 +118,23 @@ export declare class DiffChecker {
115
118
  *
116
119
  * @returns {DiffLine[]} - Array of line-level diffs
117
120
  */
118
- getStructuredDiff(): DiffLine[];
121
+ getStructuredDiff: () => DiffLine[];
119
122
  /**
120
123
  * Returns the grouped diff as an array of DiffGroup objects.
121
124
  *
122
125
  * @returns {DiffGroup[]} - Array of grouped diffs
123
126
  */
124
- getGroupedDiff(): DiffGroup[];
127
+ getGroupedDiff: () => DiffGroup[];
125
128
  /**
126
129
  * Returns the unified diff as a plain ASCII string.
127
130
  *
128
131
  * @returns {string} - Unified diff (ASCII)
129
132
  */
130
- getASCIIDiff(): string;
133
+ getASCIIDiff: () => string;
131
134
  /**
132
135
  * Returns the unified diff as a CLI-colored string.
133
136
  *
134
137
  * @returns {string} - Unified diff (CLI colors)
135
138
  */
136
- getCLIDiff(): string;
139
+ getCLIDiff: () => string;
137
140
  }