(text, query)
| 1456 | } |
| 1457 | |
| 1458 | function getSubsequenceScore(text, query) { |
| 1459 | if (!query) return 0; |
| 1460 | |
| 1461 | let queryIndex = 0; |
| 1462 | let firstMatch = -1; |
| 1463 | let lastMatch = -1; |
| 1464 | |
| 1465 | for (let textIndex = 0; textIndex < text.length && queryIndex < query.length; textIndex++) { |
| 1466 | if (text[textIndex] === query[queryIndex]) { |
| 1467 | if (firstMatch === -1) firstMatch = textIndex; |
| 1468 | lastMatch = textIndex; |
| 1469 | queryIndex++; |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | if (queryIndex !== query.length) { |
| 1474 | return Infinity; |
| 1475 | } |
| 1476 | |
| 1477 | return (lastMatch - firstMatch) + firstMatch; |
| 1478 | } |
| 1479 | |
| 1480 | function updateActiveDropdownItem(dropdown, activeIndex) { |
| 1481 | dropdown.querySelectorAll('.dropdown-item').forEach((item, itemIndex) => { |
no outgoing calls
no test coverage detected