fuzzySearch
Import from @varavel/vdl-plugin-sdk/utils/strings.
Performs a fuzzy search that combines structural matching with a bounded Damerau-Levenshtein distance.
Ranking priority, from best to worst: 1. Exact normalized match 2. Prefix match 3. Suffix match 4. Contains match 5. Edit-distance match
The edit-distance threshold adapts to the normalized query length:
- <= 4 code points: 1
- <= 8 code points: 2
- > 8 code points: 3
The implementation is optimized for interactive lookups: - normalization work is cached per distinct input word - structural matches short-circuit before edit-distance work - edit-distance evaluation is banded and threshold-aware - only the best three matches are retained during the scan
Parameters
| Parameter | Type | Description |
|---|---|---|
data |
readonly string[] |
Candidate words to search. |
query |
string |
Search query. |
Returns
The best matches plus the literal exact-match flag.