forked from MapComplete/MapComplete
Refactoring: fix small errors, simplify 'sortedByLevehnstein'-function, improve error messgae
This commit is contained in:
parent
97b8202b14
commit
8a0023377a
13 changed files with 27 additions and 19 deletions
10
src/Utils.ts
10
src/Utils.ts
|
|
@ -1259,11 +1259,21 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
}
|
||||
}
|
||||
|
||||
public static sortedByLevenshteinDistance(
|
||||
reference: string,
|
||||
ts: ReadonlyArray<string>
|
||||
): string[]
|
||||
public static sortedByLevenshteinDistance<T>(
|
||||
reference: string,
|
||||
ts: ReadonlyArray<T>,
|
||||
getName: (t: T) => string
|
||||
): string[]
|
||||
public static sortedByLevenshteinDistance<T>(
|
||||
reference: string,
|
||||
ts: ReadonlyArray<T>,
|
||||
getName?: (t: T) => string
|
||||
): T[] {
|
||||
getName ??= (str) => <string> str;
|
||||
const withDistance: [T, number][] = ts.map((t) => [
|
||||
t,
|
||||
Utils.levenshteinDistance(getName(t), reference),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue