(
query: string,
options: MatcherOptions = {},
)
| 287 | * @returns A function that returns detailed match results |
| 288 | */ |
| 289 | export function createDetailedMatcher( |
| 290 | query: string, |
| 291 | options: MatcherOptions = {}, |
| 292 | ): (text: string) => MatchResult { |
| 293 | const prepared = prepareQuery(query, options); |
| 294 | const queryLower = query.toLowerCase().trim(); |
| 295 | |
| 296 | // If query is empty, return a function that always returns empty result |
| 297 | if (queryLower.length === 0 || prepared.termSet.size === 0) { |
| 298 | return () => ({ |
| 299 | score: 0, |
| 300 | termScore: 0, |
| 301 | exactBonus: 0, |
| 302 | prefixBonus: 0, |
| 303 | consecutiveBonus: 0, |
| 304 | positionScore: 0, |
| 305 | matchedTerms: 0, |
| 306 | totalTerms: 0, |
| 307 | }); |
| 308 | } |
| 309 | |
| 310 | return (text: string): MatchResult => { |
| 311 | return matchWithDetails(prepared, queryLower, text); |
| 312 | }; |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * Internal function to perform matching with full details. |
no test coverage detected