* @param {string} input * @param {Object[]} args * @returns {html}
(input, args)
| 81 | * @returns {html} |
| 82 | */ |
| 83 | run(input, args) { |
| 84 | const searchStr = args[0]; |
| 85 | const weights = { |
| 86 | sequentialBonus: args[1], |
| 87 | separatorBonus: args[2], |
| 88 | camelBonus: args[3], |
| 89 | firstLetterBonus: args[4], |
| 90 | leadingLetterPenalty: args[5], |
| 91 | maxLeadingLetterPenalty: args[6], |
| 92 | unmatchedLetterPenalty: args[7] |
| 93 | }; |
| 94 | const matches = fuzzyMatch(searchStr, input, true, weights); |
| 95 | |
| 96 | if (!matches) { |
| 97 | return "No matches."; |
| 98 | } |
| 99 | |
| 100 | let result = "", pos = 0, hlClass = "hl1"; |
| 101 | matches.forEach(([matches, score, idxs]) => { |
| 102 | const matchRanges = calcMatchRanges(idxs); |
| 103 | |
| 104 | matchRanges.forEach(([start, length], i) => { |
| 105 | result += Utils.escapeHtml(input.slice(pos, start)); |
| 106 | if (i === 0) result += `<span class="${hlClass}">`; |
| 107 | pos = start + length; |
| 108 | result += `<b>${Utils.escapeHtml(input.slice(start, pos))}</b>`; |
| 109 | }); |
| 110 | result += "</span>"; |
| 111 | hlClass = hlClass === "hl1" ? "hl2" : "hl1"; |
| 112 | }); |
| 113 | |
| 114 | result += Utils.escapeHtml(input.slice(pos, input.length)); |
| 115 | |
| 116 | return result; |
| 117 | } |
| 118 | |
| 119 | } |
| 120 |
nothing calls this directly
no test coverage detected