suggestion.d.ts 991 B

1234567891011121314151617
  1. /**
  2. * Given a name and a list of names that are not equal to the name, return a
  3. * spelling suggestion if there is one that is close enough. Names less than
  4. * length 3 only check for case-insensitive equality, not Levenshtein distance.
  5. *
  6. * - If there is a candidate that's the same except for case, return that.
  7. * - If there is a candidate that's within one edit of the name, return that.
  8. * - Otherwise, return the candidate with the smallest Levenshtein distance,
  9. * except for candidates:
  10. * * With no name
  11. * * Whose length differs from the target name by more than 0.34 of the
  12. * length of the name.
  13. * * Whose levenshtein distance is more than 0.4 of the length of the
  14. * name (0.4 allows 1 substitution/transposition for every 5 characters,
  15. * and 1 insertion/deletion at 3 characters)
  16. */
  17. export declare function getSpellingSuggestion<T>(name: string, candidates: T[], getName: (candidate: T) => string | undefined): T | undefined;