This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree 1 file changed +12
-0
lines changed 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,8 @@ If there is a single instance with an exact prefix match, it is returned as the
127
127
are similar to `instanceName` are returned as `suggestions`. Names with an exact
128
128
prefix match are prioritized, followed by increasing Levenshtein distance, up to
129
129
a maximum distance of `MAX_LEVENSHTEIN_DISTANCE`.
130
+ @param {string } instanceName the name for which similarly named instance will be searched
131
+ @returns {{ match: string } | { suggestions: string[] } } either a single exact `match` or a number of `suggestions`
130
132
*/
131
133
async function getSimilarInstanceNames (
132
134
instanceName : string
@@ -429,6 +431,16 @@ export function formatUptime(ms: number) {
429
431
return isFuture ? `In ${ duration } ` : duration ;
430
432
}
431
433
434
+ /**
435
+ * This function calculates the Levenshtein distance between two strings.
436
+ * Levenshtein distance is a measure of the difference between two strings,
437
+ * defined as the minimum number of edits (insertions, deletions or substitutions)
438
+ * required to transform one string into another.
439
+ *
440
+ * @param {string } a - The first string to compare.
441
+ * @param {string } b - The second string to compare.
442
+ * @return {number } The Levenshtein distance between the two strings.
443
+ */
432
444
export function levenshteinDistance ( a : string , b : string ) : number {
433
445
if ( a . length === 0 ) return b . length ;
434
446
if ( b . length === 0 ) return a . length ;
You can’t perform that action at this time.
0 commit comments