forked from andyburke/autonomous.contact
		
	
		
			
				
	
	
		
			24 lines
		
	
	
	
		
			447 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			447 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| "use strict";
 | |
| 
 | |
| function fuzzysearch(needle, haystack) {
 | |
| 	var hlen = haystack.length;
 | |
| 	var nlen = needle.length;
 | |
| 	if (nlen > hlen) {
 | |
| 		return false;
 | |
| 	}
 | |
| 	if (nlen === hlen) {
 | |
| 		return needle === haystack;
 | |
| 	}
 | |
| 	outer: for (var i = 0, j = 0; i < nlen; i++) {
 | |
| 		var nch = needle.charCodeAt(i);
 | |
| 		while (j < hlen) {
 | |
| 			if (haystack.charCodeAt(j++) === nch) {
 | |
| 				continue outer;
 | |
| 			}
 | |
| 		}
 | |
| 		return false;
 | |
| 	}
 | |
| 	return true;
 | |
| }
 | |
| 
 | |
| module.exports = fuzzysearch;
 |