MCPcopy Create free account
hub / github.com/Effect-TS/effect / suggest

Function suggest

packages/effect/src/unstable/cli/internal/auto-suggest.ts:28–41  ·  view source on GitHub ↗
(input: string, candidates: ReadonlyArray<string>)

Source from the content-addressed store, hash-verified

26 * @internal
27 */
28export const suggest = (input: string, candidates: ReadonlyArray<string>): ReadonlyArray<string> => {
29 const distances = candidates
30 .map((c) => [levenshtein(input, c), c] as const)
31 .filter(([d]) => d <= 2) // Stricter threshold
32 .sort(([a], [b]) => a - b)
33
34 if (distances.length === 0) return []
35
36 // Only return suggestions with the minimum distance found
37 const minDistance = distances[0][0]
38 return distances
39 .filter(([d]) => d === minDistance)
40 .map(([, c]) => c)
41}

Callers 2

resolveFirstValueFunction · 0.90

Calls 3

filterMethod · 0.80
levenshteinFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected