301
}
302
303
>
function doScoreFuzzy2Multiple(target: string, query: IPreparedQueryPiece[], patternStart: number, wordStart: number): FuzzyScore2 {
fuzzyScorer.ts
304
>
let totalScore = 0;
305
>
const totalMatches: IMatch[] = [];
306
>
307
>
for (const queryPiece of query) {
308
>
const [score, matches] = doScoreFuzzy2Single(target, queryPiece, patternStart, wordStart);
309
>
if (typeof score !== 'number') {
310
>
// if a single query value does not match, return with
311
>
// no score entirely, we require all queries to match
312
>
return NO_SCORE2;
313
>
}
314
>
315
>
totalScore += score;
316
>
totalMatches.push(...matches);
317
>
}
318
>
319
>
// if we have a score, ensure that the positions are
320
>
// sorted in ascending order and distinct
321
>
return [totalScore, normalizeMatches(totalMatches)];
322
>
}
323
324
function doScoreFuzzy2Single(target: string, query: IPreparedQueryPiece, patternStart: number, wordStart: number): FuzzyScore2 {
325
const score = fuzzyScore(query.normalized, query.normalizedLowercase, patternStart, target, target.toLowerCase(), wordStart, { firstMatchCanBeWeak: true, boostFullMatch: true });
326
if (!score) {
328
>
}
329
330
return [score[0], createFuzzyMatches(score)];