Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typescript definitions #21

Open
adroste opened this issue Feb 22, 2023 · 1 comment
Open

Add typescript definitions #21

adroste opened this issue Feb 22, 2023 · 1 comment

Comments

@adroste
Copy link

adroste commented Feb 22, 2023

Great library!

Would be nice, if you'd add some simple typings like:

// index.d.ts
declare module 'levenshtein-search' {
  export function fuzzySearch(pattern: string, text: string, maxDistance: number): 
    IterableIterator<{ start: number, end: number, dist: number }>;

  export function editDistance(string1: string, string2: string): number;

  export function isEditDistanceNoGreaterThan(string1: string, string2: string, maxDistance: number): boolean;
}
@LoganDark
Copy link

Here's what I use:

declare module 'levenshtein-search' {
  export type FuzzyMatch = { start: number, end: number, dist: number }
  export function editDistance(a: string, b: string): number
  export function fuzzySearch(needle: string, haystack: string, maxDist: number): Iterable<FuzzyMatch>
  export function isEditDistanceNoGreaterThan(a: string, b: string, maxDist: number): boolean
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants