diff options
| author | Fuwn <[email protected]> | 2024-10-09 00:41:20 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-09 00:41:43 -0700 |
| commit | 998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch) | |
| tree | 50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/lib/Error/path.ts | |
| parent | feat(graphql): add badgeCount field (diff) | |
| download | due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip | |
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/lib/Error/path.ts')
| -rw-r--r-- | src/lib/Error/path.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/Error/path.ts b/src/lib/Error/path.ts index 1e36268c..a35a4cb8 100644 --- a/src/lib/Error/path.ts +++ b/src/lib/Error/path.ts @@ -1,20 +1,20 @@ import levenshtein from 'fast-levenshtein'; export const closest = (path: string, suggestions: string[]) => { - const partialMatches = suggestions.filter((suggestion) => suggestion.includes(path)); + const partialMatches = suggestions.filter((suggestion) => suggestion.includes(path)); - if (partialMatches.length) return partialMatches[0]; + if (partialMatches.length) return partialMatches[0]; - const suggestionsWithDistance = suggestions.map((suggestion) => { - const distance = levenshtein.get(path, suggestion); + const suggestionsWithDistance = suggestions.map((suggestion) => { + const distance = levenshtein.get(path, suggestion); - return { suggestion, distance }; - }); + return { suggestion, distance }; + }); - suggestionsWithDistance.sort((a, b) => a.distance - b.distance); + suggestionsWithDistance.sort((a, b) => a.distance - b.distance); - for (const suggestion of suggestionsWithDistance) - if (suggestion.distance < suggestion.suggestion.length / 2) return suggestion.suggestion; + for (const suggestion of suggestionsWithDistance) + if (suggestion.distance < suggestion.suggestion.length / 2) return suggestion.suggestion; - return suggestionsWithDistance[0].suggestion; + return suggestionsWithDistance[0].suggestion; }; |