trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
33 lines • 1.35 kB
TypeScript
/**
* Fuzzy matching utilities — shared furniture (ADR 0034 §3).
*
* Score is a plain subsequence match: every query character must appear in
* order in the target (case-insensitive), or the score is 0 (no match).
* Longer consecutive runs and earlier positions score higher, so "psh" beats
* "psh" in "push" vs "pin-shed", and exact-prefix matches get a bonus.
*
* Also exports `fuzzyRanges` — the matched character index pairs per result,
* used by combobox highlight rendering.
*
* @module trellis/headless
*/
/**
* Score `query` against `target`; 0 means no match.
* Empty query matches everything with score 1.
*/
export declare function fuzzyScore(query: string, target: string): number;
/**
* Score an item across its searchable text: label first, then keywords and
* description. Returns the best (highest) score; 0 = no match.
*/
export declare function fuzzyMatch(query: string, text: string[]): number;
/**
* Return the matched character ranges for `query` inside `target`.
* Each range is `[start, end)` (end-exclusive). Consecutive matched
* characters merge into one range.
*
* Returns an empty array when query is empty or any query character is
* absent from target (no match).
*/
export declare function fuzzyRanges(query: string, target: string): Array<[number, number]>;
//# sourceMappingURL=fuzzy.d.ts.map