UNPKG

adwaveui

Version:

Interactive Web Components inspired by the Gtk Adwaita theme.

31 lines (29 loc) 713 B
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/utils/fuzzy-search.ts function fuzzyCmp(q, text) { q = q.toLowerCase(); text = text.toLowerCase(); const searchLength = q.length; const textLength = text.length; if (searchLength > textLength) { return false; } if (text.indexOf(q) >= 0) { return true; } mainLoop: for (let i = 0, j = 0; i < searchLength; i += 1) { const ch = q.charCodeAt(i); while (j < textLength) { if (text.charCodeAt(j++) === ch) { continue mainLoop; } } return false; } return true; } __name(fuzzyCmp, "fuzzyCmp"); export { fuzzyCmp };