diff --git a/src/packages/cli/src/detach.ts b/src/packages/cli/src/detach.ts index 215725183e..8706d6f24d 100644 --- a/src/packages/cli/src/detach.ts +++ b/src/packages/cli/src/detach.ts @@ -127,6 +127,8 @@ If there is a single instance with an exact prefix match, it is returned as the are similar to `instanceName` are returned as `suggestions`. Names with an exact prefix match are prioritized, followed by increasing Levenshtein distance, up to a maximum distance of `MAX_LEVENSHTEIN_DISTANCE`. +@param {string} instanceName the name for which similarly named instance will be searched +@returns {{ match: string } | { suggestions: string[] }} either a single exact `match` or a number of `suggestions` */ async function getSimilarInstanceNames( instanceName: string @@ -429,6 +431,16 @@ export function formatUptime(ms: number) { return isFuture ? `In ${duration}` : duration; } +/** + * This function calculates the Levenshtein distance between two strings. + * Levenshtein distance is a measure of the difference between two strings, + * defined as the minimum number of edits (insertions, deletions or substitutions) + * required to transform one string into another. + * + * @param {string} a - The first string to compare. + * @param {string} b - The second string to compare. + * @return {number} The Levenshtein distance between the two strings. + */ export function levenshteinDistance(a: string, b: string): number { if (a.length === 0) return b.length; if (b.length === 0) return a.length;