@@ -70,8 +70,8 @@ type InstanceOrSuggestions =
70
70
*
71
71
* Note: This does not guarantee that the instance actually stops.
72
72
* @param {string } instanceName
73
- * @returns {InstanceOrSuggestions } either the stopped `instance`, or
74
- * `suggestions` for similar instance names
73
+ * @returns {InstanceOrSuggestions } an object containing either the stopped
74
+ * `instance`, or ` suggestions` for similar instance names
75
75
*/
76
76
export async function stopDetachedInstance (
77
77
instanceName : string
@@ -119,15 +119,19 @@ export async function stopDetachedInstance(
119
119
}
120
120
}
121
121
122
- /*
123
- Find instances with names similar to `instanceName`.
124
-
125
- If there is a single instance with an exact prefix match, it is returned as the
126
- `match` property in the result. Otherwise, up to `MAX_SUGGESTIONS` names that
127
- are similar to `instanceName` are returned as `suggestions`. Names with an exact
128
- prefix match are prioritized, followed by increasing Levenshtein distance, up to
129
- a maximum distance of `MAX_LEVENSHTEIN_DISTANCE`.
130
- */
122
+ /**
123
+ * Find instances with names similar to `instanceName`.
124
+ *
125
+ * If there is a single instance with an exact prefix match, it is returned as
126
+ * the `match` property in the result. Otherwise, up to `MAX_SUGGESTIONS` names
127
+ * that are similar to `instanceName` are returned as `suggestions`. Names with
128
+ * an exact prefix match are prioritized, followed by increasing Levenshtein
129
+ * distance, up to a maximum distance of `MAX_LEVENSHTEIN_DISTANCE`.
130
+ * @param {string } instanceName the name for which similarly named instance will
131
+ * be searched
132
+ * @returns {{ match: string } | { suggestions: string[] } } an object
133
+ * containiner either a single exact `match` or a number of `suggestions`
134
+ */
131
135
async function getSimilarInstanceNames (
132
136
instanceName : string
133
137
) : Promise < { match : string } | { suggestions : string [ ] } > {
@@ -429,6 +433,16 @@ export function formatUptime(ms: number) {
429
433
return isFuture ? `In ${ duration } ` : duration ;
430
434
}
431
435
436
+ /**
437
+ * This function calculates the Levenshtein distance between two strings.
438
+ * Levenshtein distance is a measure of the difference between two strings,
439
+ * defined as the minimum number of edits (insertions, deletions or substitutions)
440
+ * required to transform one string into another.
441
+ *
442
+ * @param {string } a - The first string to compare.
443
+ * @param {string } b - The second string to compare.
444
+ * @return {number } The Levenshtein distance between the two strings.
445
+ */
432
446
export function levenshteinDistance ( a : string , b : string ) : number {
433
447
if ( a . length === 0 ) return b . length ;
434
448
if ( b . length === 0 ) return a . length ;
0 commit comments