MCPcopy Create free account
hub / github.com/TanStack/cli / levenshtein

Function levenshtein

packages/create/src/add-ons.ts:91–108  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

89}
90
91function levenshtein(a: string, b: string): number {
92 const m = a.length
93 const n = b.length
94 let prev = Array.from({ length: n + 1 }, (_, j) => j)
95
96 for (let i = 1; i <= m; i++) {
97 const curr = [i]
98 for (let j = 1; j <= n; j++) {
99 curr[j] =
100 a[i - 1] === b[j - 1]
101 ? prev[j - 1]
102 : 1 + Math.min(prev[j], curr[j - 1], prev[j - 1])
103 }
104 prev = curr
105 }
106
107 return prev[n]
108}
109
110export function populateAddOnOptionsDefaults(
111 chosenAddOns: Array<AddOn>,

Callers 1

findClosestAddOnFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected