Skip to content

Instantly share code, notes, and snippets.

@dmorosinotto
Created June 23, 2017 00:23
Show Gist options
  • Save dmorosinotto/98beceb82fd91249df5fecd87f3faa75 to your computer and use it in GitHub Desktop.
Save dmorosinotto/98beceb82fd91249df5fecd87f3faa75 to your computer and use it in GitHub Desktop.
//inspired by https://github.com/bevacqua/fuzzysearch/blob/master/index.js
'use strict';
function fuzzysearch (what, inside) {
var l = inside.length;
var n = what.length;
if (n > l) {
return false;
}
if (n === l) {
return what === inside;
}
outer: for (var i = 0, j = 0; i < n; i++) {
var c = what.charCodeAt(i);
while (j < hlen) {
if (inside.charCodeAt(j++) === c) {
continue outer;
}
}
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment