forked from MapComplete/MapComplete
Add rewrite of 'special' clauses, various QOLimprovements on import viewer
This commit is contained in:
parent
8df0324572
commit
c47a6d5ea7
22 changed files with 597 additions and 155 deletions
8
Utils.ts
8
Utils.ts
|
@ -407,7 +407,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
*
|
||||
* If a list is encountered, this is tranparently walked recursively on every object.
|
||||
*
|
||||
* The leaf objects are replaced by the function
|
||||
* The leaf objects are replaced in the object itself by the specified function
|
||||
*/
|
||||
public static WalkPath(path: string[], object: any, replaceLeaf: ((leaf: any, travelledPath: string[]) => any), travelledPath: string[] = []) {
|
||||
const head = path[0]
|
||||
|
@ -793,6 +793,12 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
}
|
||||
return new Date(str)
|
||||
}
|
||||
|
||||
public static sortedByLevenshteinDistance<T>(reference: string, ts: T[], getName: (t:T) => string): T[]{
|
||||
const withDistance: [T, number][] = ts.map(t => [t, Utils.levenshteinDistance(getName(t), reference)])
|
||||
withDistance.sort(([_, a], [__, b]) => a - b)
|
||||
return withDistance.map(n => n[0])
|
||||
}
|
||||
|
||||
public static levenshteinDistance(str1: string, str2: string) {
|
||||
const track = Array(str2.length + 1).fill(null).map(() =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue