| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| 'use strict'; | ||
|
|
||
| function fuzzysearch (needle, haystack) { | ||
| var tlen = haystack.length; | ||
| var qlen = needle.length; | ||
| if (qlen > tlen) { | ||
| return false; | ||
| } | ||
| if (qlen === tlen) { | ||
| return needle === haystack; | ||
| } | ||
| outer: for (var i = 0, j = 0; i < qlen; i++) { | ||
| var nch = needle.charCodeAt(i); | ||
| while (j < tlen) { | ||
| if (haystack.charCodeAt(j++) === nch) { | ||
| continue outer; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| module.exports = fuzzysearch; |