cmpstr 2.0.0 → 2.0.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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  CmpStr is a lightweight and powerful npm package for calculating string similarity, finding the closest matches in arrays, performing phonetic searches, and more. It supports a variety of built-in algorithms (e.g., Levenshtein, Dice-Sørensen, Damerau-Levenshtein, Soundex) and allows users to add custom algorithms and normalization filters.
4
4
 
5
- #### Key Features
5
+ **Key Features**
6
6
 
7
7
  - Built-in support for multiple similarity algorithms.
8
8
  - Phonetic search with language-specific configurations (e.g., Soundex).
@@ -10,6 +10,7 @@ CmpStr is a lightweight and powerful npm package for calculating string similari
10
10
  - Customizable normalization with global flags and caching.
11
11
  - Asynchronous support for non-blocking workflows.
12
12
  - Extensible with custom algorithms and filters.
13
+ - TypeScript definitions for better developer experience.
13
14
 
14
15
  ## Installation
15
16
 
package/package.json CHANGED
@@ -7,8 +7,9 @@
7
7
  "url" : "https://komed3.de"
8
8
  },
9
9
  "homepage": "https://github.com/komed3/cmpstr#readme",
10
- "version": "2.0.0",
10
+ "version": "2.0.1",
11
11
  "main": "src/index.js",
12
+ "types": "src/index.d.ts",
12
13
  "license": "MIT",
13
14
  "keywords": [
14
15
  "string-similarity",
@@ -35,7 +36,8 @@
35
36
  "text-processing",
36
37
  "fuzzy-matching",
37
38
  "string-matching",
38
- "text-similarity"
39
+ "text-similarity",
40
+ "typescript-definitions"
39
41
  ],
40
42
  "repository": {
41
43
  "type": "git",
@@ -0,0 +1,64 @@
1
+ export interface Config {
2
+ flags?: string;
3
+ threshold?: number;
4
+ options?: Record<string, any>;
5
+ }
6
+
7
+ export interface BatchResult {
8
+ target: string;
9
+ match: number | any;
10
+ }
11
+
12
+ export declare class CmpStr {
13
+
14
+ constructor ( algo?: string, str?: string );
15
+
16
+ isReady () : boolean;
17
+
18
+ setStr ( str: string ) : boolean;
19
+
20
+ listAlgo () : string[];
21
+
22
+ isAlgo ( algo: string ) : boolean;
23
+
24
+ setAlgo ( algo: string ) : boolean;
25
+
26
+ addAlgo ( algo: string, callback: (
27
+ a: string, b: string, ...args : any
28
+ ) => number | any, useIt?: boolean ) : boolean;
29
+
30
+ rmvAlgo( algo: string ) : boolean;
31
+
32
+ listFilter () : string[];
33
+
34
+ addFilter ( name: string, callback: (
35
+ str: string
36
+ ) => string, priority?: number ) : boolean;
37
+
38
+ rmvFilter ( name: string ) : boolean;
39
+
40
+ pauseFilter ( name: string ) : boolean;
41
+
42
+ resumeFilter ( name: string ) : boolean;
43
+
44
+ clearFilter () : boolean;
45
+
46
+ setFlags( flags: string ) : void;
47
+
48
+ normalize ( str: string, flags?: string ) : string;
49
+
50
+ clearCache () : boolean;
51
+
52
+ compare ( algo: string, a: string, b: string, config?: Config ) : number | any;
53
+
54
+ test ( str: string, config?: Config ) : number | any;
55
+
56
+ batchTest ( arr: string[], config?: Config ) : BatchResult[];
57
+
58
+ match ( arr: string[], config?: Config ) : BatchResult[];
59
+
60
+ closest ( arr: string[], config?: Config ) : string | undefined;
61
+
62
+ similarityMatrix ( algo: string, arr: string[], config?: Config ) : number[][];
63
+
64
+ }
@@ -0,0 +1,17 @@
1
+ import { CmpStr, Config, BatchResult } from './CmpStr';
2
+
3
+ export declare class CmpStrAsync extends CmpStr {
4
+
5
+ compareAsync ( algo: string, a: string, b: string, config?: Config ) : Promise<number | any>;
6
+
7
+ testAsync ( str: string, config?: Config ) : Promise<number | any>;
8
+
9
+ batchTestAsync ( arr: string[], config?: Config ) : Promise<BatchResult[]>;
10
+
11
+ matchAsync ( arr: string[], config?: Config ) : Promise<BatchResult[]>;
12
+
13
+ closestAsync ( arr: string[], config?: Config ) : Promise<string | undefined>;
14
+
15
+ similarityMatrixAsync ( algo: string, arr: string[], config?: Config ) : Promise<number[][]>;
16
+
17
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { CmpStr, Config, BatchResult } from './CmpStr';
2
+
3
+ export { CmpStrAsync } from './CmpStrAsync';
package/src/index.js CHANGED
@@ -22,7 +22,7 @@
22
22
  * - generate similarity matrices for cross-comparisons
23
23
  *
24
24
  * @author Paul Köhler (komed3)
25
- * @version 2.0.0
25
+ * @version 2.0.1
26
26
  * @license MIT
27
27
  */
28
28