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
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- itemsrequisReadonlyArray<T>
- The full list of items to match against.
- queryrequisstring
- The search string. Matching is case-insensitive. Empty string returns all items.
- getHaystackrequis(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
Valeur de retour
La valeur retournée par cet util.
- Matched items wrapped in IFuzzyMatchResult { item, score }, sorted by score descending. Non-matching items are omitted.
Usage
Exemples
Extraits de code prêts à coller.
Filter a command list