UNPKG

didyoumean2

Version:

a library for matching human-quality input to a list of potential matches using the Levenshtein distance algorithm

33 lines (28 loc) 1.26 kB
declare enum ReturnTypeEnums { ALL_CLOSEST_MATCHES = "all-closest-matches", ALL_MATCHES = "all-matches", ALL_SORTED_MATCHES = "all-sorted-matches", FIRST_CLOSEST_MATCH = "first-closest-match", FIRST_MATCH = "first-match" } declare enum ThresholdTypeEnums { EDIT_DISTANCE = "edit-distance", SIMILARITY = "similarity" } type MatchItem = Record<string, unknown> | string; type Options = { readonly caseSensitive: boolean; readonly deburr: boolean; readonly matchPath: ReadonlyArray<number | string>; readonly returnType: ReturnTypeEnums; readonly threshold: number; readonly thresholdType: ThresholdTypeEnums; readonly trimSpaces: boolean; }; declare function didYouMean<T extends MatchItem>(input: string, matchList: ReadonlyArray<T>, options?: Partial<Options> & { readonly returnType?: ReturnTypeEnums.FIRST_CLOSEST_MATCH | ReturnTypeEnums.FIRST_MATCH; }): T | null; declare function didYouMean<T extends MatchItem>(input: string, matchList: ReadonlyArray<T>, options: Partial<Options> & { readonly returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES | ReturnTypeEnums.ALL_MATCHES | ReturnTypeEnums.ALL_SORTED_MATCHES; }): T[]; export { ReturnTypeEnums, ThresholdTypeEnums, didYouMean as default };