Skip to content

Instantly share code, notes, and snippets.

@fallroot
Created March 15, 2019 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fallroot/62492d23058533e1a2e1509b19497563 to your computer and use it in GitHub Desktop.
Save fallroot/62492d23058533e1a2e1509b19497563 to your computer and use it in GitHub Desktop.
Tiny Fuzzzy Search
function search (text, keyword) {
let start = 0
text = text.toLowerCase()
keyword = keyword.toLowerCase()
for (let i = 0; i < keyword.length; ++i) {
const char = keyword[i]
const index = text.indexOf(char, start)
if (index < 0) {
return false
}
start = index + 1
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment