fuzzyMatch
CommandPalette
stable
Score and filter an array of items against a fuzzy query string using a subsequence + positional scoring algorithm. Returns matched items sorted by descending score. An empty query returns all items with score 0.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- itemsrequiredReadonlyArray<T>
- The full list of items to match against.
- queryrequiredstring
- The search string. Matching is case-insensitive. Empty string returns all items.
- getHaystackrequired(item: T) => { label: string, haystack: string }
- Extractor function. "label" is used for display-quality scoring (prefix/word bonuses); "haystack" is the full searchable text for subsequence matching.
API
Return value
The value returned by this util.
- Matched items wrapped in IFuzzyMatchResult { item, score }, sorted by score descending. Non-matching items are omitted.
Usage
Examples
Ready-to-paste usage snippets.
Filter a command list