Skip to content

closest

closest(query, items, minScore?): string | null

Find the closest matching string from a list.

Returns the best match, or null if no match is found. Like SearchResult.item, the returned string is converted to UTF-8: a lone UTF-16 surrogate in it becomes U+FFFD. If minScore is provided, returns null when the best match scores below the threshold. A NaN minScore throws an InvalidArg error.

Parameter Type
query string
items readonly string[]
minScore? number | null

string | null