Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 640472d

Browse files
authored
Add comments
1 parent 667e567 commit 640472d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/packages/cli/src/detach.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ If there is a single instance with an exact prefix match, it is returned as the
127127
are similar to `instanceName` are returned as `suggestions`. Names with an exact
128128
prefix match are prioritized, followed by increasing Levenshtein distance, up to
129129
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`
130132
*/
131133
async function getSimilarInstanceNames(
132134
instanceName: string
@@ -429,6 +431,16 @@ export function formatUptime(ms: number) {
429431
return isFuture ? `In ${duration}` : duration;
430432
}
431433

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+
*/
432444
export function levenshteinDistance(a: string, b: string): number {
433445
if (a.length === 0) return b.length;
434446
if (b.length === 0) return a.length;

0 commit comments

Comments
 (0)