blob: ab26035b804a87e125eadda1f3f965f1a6ffa391 [file] [log] [blame]
bigbiffd006b302015-03-06 18:36:03 -05001module.exports = new FuzzySearchStrategy();
2
3function FuzzySearchStrategy(){
4 var self = this;
5
6 function createFuzzyRegExpFromString(string){
7 return new RegExp( string.split('').join('.*?'), 'gi');
8 }
9
10 self.matches = function(string,crit){
11 if( typeof string !== 'string' ) return false;
12 string = string.trim();
13 return !!string.match(createFuzzyRegExpFromString(crit));
14 };
15};