32 lines
No EOL
586 B
JavaScript
Executable file
32 lines
No EOL
586 B
JavaScript
Executable file
'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;
|
|
|
|
|
|
|
|
//////////////////
|
|
// WEBPACK FOOTER
|
|
// ./~/fuzzysearch/index.js
|
|
// module id = 252
|
|
// module chunks = 4
|