Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "fuse.js", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"main": "./src/fuse.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
{ | ||
"name": "fuse.js", | ||
"author": "Kirollos Risk", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Lightweight fuzzy-search", | ||
@@ -18,2 +18,2 @@ "license": "Apache", | ||
} | ||
} | ||
} |
@@ -139,10 +139,8 @@ /** | ||
bestLoc = text.indexOf(pattern, MATCH_LOCATION), | ||
binMin, binMid, | ||
binMax = patternLen + textLen, | ||
lastRd, start, finish, rd, charMatch, | ||
start, finish, | ||
bitArr, lastBitArr, | ||
charMatch, | ||
score = 1, | ||
locations = []; | ||
@@ -183,5 +181,5 @@ | ||
// Initialize the bit array | ||
rd = Array(finish + 2); | ||
bitArr = Array(finish + 2); | ||
rd[finish + 1] = (1 << i) - 1; | ||
bitArr[finish + 1] = (1 << i) - 1; | ||
@@ -194,8 +192,8 @@ for (j = finish; j >= start; j--) { | ||
// First pass: exact match. | ||
rd[j] = ((rd[j + 1] << 1) | 1) & charMatch; | ||
bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch; | ||
} else { | ||
// Subsequent passes: fuzzy match. | ||
rd[j] = ((rd[j + 1] << 1) | 1) & charMatch | (((lastRd[j + 1] | lastRd[j]) << 1) | 1) | lastRd[j + 1]; | ||
bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch | (((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1) | lastBitArr[j + 1]; | ||
} | ||
if (rd[j] & matchmask) { | ||
if (bitArr[j] & matchmask) { | ||
score = match_bitapScore(i, j - 1); | ||
@@ -225,3 +223,3 @@ // This match will almost certainly be better than any existing match. | ||
} | ||
lastRd = rd; | ||
lastBitArr = bitArr; | ||
} | ||
@@ -278,4 +276,3 @@ | ||
resultMap = {}, | ||
rawResultsLen, existingResult, results = [], | ||
compute = null; | ||
rawResultsLen, existingResult, results = []; | ||
@@ -282,0 +279,0 @@ /** |
@@ -20,2 +20,2 @@ /** | ||
*/ | ||
!function(e){function t(e,t){function r(e,t){var r=e/h,n=Math.abs(o-t);return i?r+n/i:n?1:r}t=t||{};var o=t.location||n.location,i="distance"in t?t.distance:n.distance,a="threshold"in t?t.threshold:n.threshold,s=t.maxPatternLength||n.maxPatternLength,e=t.caseSensitive?e:e.toLowerCase(),h=e.length;if(h>s)throw new Error("Pattern length is too long");var c=1<<h-1,f=function(){var t={},r=0;for(r=0;h>r;r++)t[e.charAt(r)]=0;for(r=0;h>r;r++)t[e.charAt(r)]|=1<<e.length-r-1;return t}();this.search=function(n){if(n=t.caseSensitive?n:n.toLowerCase(),e===n)return{isMatch:!0,score:0};var i,s,u,l,d,g,m,p,v,M=n.length,x=a,y=n.indexOf(e,o),w=h+M,L=1,b=[];for(-1!=y&&(x=Math.min(r(0,y),x),y=n.lastIndexOf(e,o+h),-1!=y&&(x=Math.min(r(0,y),x))),y=-1,i=0;h>i;i++){for(u=0,l=w;l>u;)r(i,o+l)<=x?u=l:w=l,l=Math.floor((w-u)/2+u);for(w=l,g=Math.max(1,o-l+1),m=Math.min(o+l,M)+h,p=Array(m+2),p[m+1]=(1<<i)-1,s=m;s>=g;s--)if(v=f[n.charAt(s-1)],p[s]=0===i?(p[s+1]<<1|1)&v:(p[s+1]<<1|1)&v|((d[s+1]|d[s])<<1|1)|d[s+1],p[s]&c&&(L=r(i,s-1),x>=L)){if(x=L,y=s-1,b.push(y),!(y>o))break;g=Math.max(1,2*o-y)}if(r(i+1,o)>x)break;d=p}return{isMatch:y>=0,score:L}}}function r(e,r){r=r||{};var n=r.keys||[];this.search=function(i){function a(e,t,r){void 0!==e&&null!==e&&"string"==typeof e&&(f=d.search(e),f.isMatch&&(l=M[r],l?l.score=Math.min(l.score,f.score):(M[r]={item:t,score:f.score},p.push(M[r]))))}var s,h,c,f,u,l,d=new t(i,r),g=e.length,m=n.length,p=[],v=0,M={},x=[];if("string"==typeof e[0])for(;g>v;v++)a(e[v],v,v);else for(;g>v;v++)for(c=e[v],h=0;m>h;h++)a(o.deepValue(c,n[h]),c,v);for(p.sort(function(e,t){return e.score-t.score}),u=p.length,s=0;u>s;s++)x.push(r.id?o.deepValue(p[s].item,r.id):p[s].item);return x}}var n={location:0,distance:100,threshold:.6,maxPatternLength:32},o={deepValue:function(e,t){for(var r=0,t=t.split("."),n=t.length;n>r;r++){if(!e)return null;e=e[t[r]]}return e}};"object"==typeof exports?module.exports=r:"function"==typeof define&&define.amd?define(function(){return r}):e.Fuse=r}(this); | ||
!function(e){function t(e,t){function r(e,t){var r=e/h,n=Math.abs(o-t);return i?r+n/i:n?1:r}t=t||{};var o=t.location||n.location,i="distance"in t?t.distance:n.distance,a="threshold"in t?t.threshold:n.threshold,s=t.maxPatternLength||n.maxPatternLength,e=t.caseSensitive?e:e.toLowerCase(),h=e.length;if(h>s)throw new Error("Pattern length is too long");var c=1<<h-1,f=function(){var t={},r=0;for(r=0;h>r;r++)t[e.charAt(r)]=0;for(r=0;h>r;r++)t[e.charAt(r)]|=1<<e.length-r-1;return t}();this.search=function(n){if(n=t.caseSensitive?n:n.toLowerCase(),e===n)return{isMatch:!0,score:0};var i,s,u,l,d,g,m,p,v,M=n.length,x=a,y=n.indexOf(e,o),w=h+M,L=1,b=[];for(-1!=y&&(x=Math.min(r(0,y),x),y=n.lastIndexOf(e,o+h),-1!=y&&(x=Math.min(r(0,y),x))),y=-1,i=0;h>i;i++){for(u=0,l=w;l>u;)r(i,o+l)<=x?u=l:w=l,l=Math.floor((w-u)/2+u);for(w=l,d=Math.max(1,o-l+1),g=Math.min(o+l,M)+h,m=Array(g+2),m[g+1]=(1<<i)-1,s=g;s>=d;s--)if(v=f[n.charAt(s-1)],m[s]=0===i?(m[s+1]<<1|1)&v:(m[s+1]<<1|1)&v|((p[s+1]|p[s])<<1|1)|p[s+1],m[s]&c&&(L=r(i,s-1),x>=L)){if(x=L,y=s-1,b.push(y),!(y>o))break;d=Math.max(1,2*o-y)}if(r(i+1,o)>x)break;p=m}return{isMatch:y>=0,score:L}}}function r(e,r){r=r||{};var n=r.keys||[];this.search=function(i){function a(e,t,r){void 0!==e&&null!==e&&"string"==typeof e&&(f=d.search(e),f.isMatch&&(l=M[r],l?l.score=Math.min(l.score,f.score):(M[r]={item:t,score:f.score},p.push(M[r]))))}var s,h,c,f,u,l,d=new t(i,r),g=e.length,m=n.length,p=[],v=0,M={},x=[];if("string"==typeof e[0])for(;g>v;v++)a(e[v],v,v);else for(;g>v;v++)for(c=e[v],h=0;m>h;h++)a(o.deepValue(c,n[h]),c,v);for(p.sort(function(e,t){return e.score-t.score}),u=p.length,s=0;u>s;s++)x.push(r.id?o.deepValue(p[s].item,r.id):p[s].item);return x}}var n={location:0,distance:100,threshold:.6,maxPatternLength:32},o={deepValue:function(e,t){for(var r=0,t=t.split("."),n=t.length;n>r;r++){if(!e)return null;e=e[t[r]]}return e}};"object"==typeof exports?module.exports=r:"function"==typeof define&&define.amd?define(function(){return r}):e.Fuse=r}(this); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1971574
87915
1