Skip to content

Commit

Permalink
Add TypeScript declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
sunesimonsen committed Aug 14, 2024
1 parent 0bb67a8 commit 8768eb3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* Calculates the edit distance using the Ukkonen algorithm.
*
* @param a - The first string.
* @param b - The second string.
* @param threshold (default Infinity) - The maximum edit distance to calculate.
* @returns The edit distance between string `a` and string `b`.
* If the distance exceeds the threshold, returns the threshold.
*/
function ukkonen(a, b, threshold) {
if (a === b) {
return 0;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"url": "https://github.com/sunesimonsen/ukkonen"
},
"main": "index.js",
"types": "./types/index.d.ts",
"scripts": {
"test": "mocha",
"lint": "eslint . && prettier --check '**/*.{js,md,json}'",
Expand Down
11 changes: 11 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Calculates the edit distance using the Ukkonen algorithm.
* @param a - The first string.
* @param b - The second string.
* @param threshold (default Infinity) - The maximum edit distance to calculate.
* @returns The edit distance between string `a` and string `b`.
* If the distance exceeds the threshold, returns the threshold.
*/
declare function ukkonen(a: string, b: string, threshold?: number): number;

export = ukkonen;

0 comments on commit 8768eb3

Please sign in to comment.