Skip to content

PromptScript API


Function: findClosestMatch()

findClosestMatch(input, candidates, maxDistance?): { distance: number; match: string; } | undefined

Defined in: core/src/utils/levenshtein.ts:39

Find the closest match from a list of candidates.

Parameters

input

string

The input string to match

candidates

readonly string[]

List of candidate strings

maxDistance?

number = 2

Maximum Levenshtein distance (default: 2)

Returns

{ distance: number; match: string; } | undefined

The closest match and its distance, or undefined if none within threshold