@leeoniya/ufuzzy
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -7,3 +7,3 @@ /** | ||
* A tiny, efficient fuzzy matcher that doesn't suck | ||
* https://github.com/leeoniya/uFuzzy (v1.0.12) | ||
* https://github.com/leeoniya/uFuzzy (v1.0.13) | ||
*/ | ||
@@ -13,3 +13,3 @@ | ||
const cmp = new Intl.Collator('en').compare; | ||
const cmp = new Intl.Collator('en', { numeric: true, sensitivity: 'base' }).compare; | ||
@@ -16,0 +16,0 @@ const inf = Infinity; |
@@ -7,6 +7,6 @@ /** | ||
* A tiny, efficient fuzzy matcher that doesn't suck | ||
* https://github.com/leeoniya/uFuzzy (v1.0.12) | ||
* https://github.com/leeoniya/uFuzzy (v1.0.13) | ||
*/ | ||
const cmp = new Intl.Collator('en').compare; | ||
const cmp = new Intl.Collator('en', { numeric: true, sensitivity: 'base' }).compare; | ||
@@ -13,0 +13,0 @@ const inf = Infinity; |
@@ -7,3 +7,3 @@ /** | ||
* A tiny, efficient fuzzy matcher that doesn't suck | ||
* https://github.com/leeoniya/uFuzzy (v1.0.12) | ||
* https://github.com/leeoniya/uFuzzy (v1.0.13) | ||
*/ | ||
@@ -14,3 +14,3 @@ | ||
const cmp = new Intl.Collator('en').compare; | ||
const cmp = new Intl.Collator('en', { numeric: true, sensitivity: 'base' }).compare; | ||
@@ -17,0 +17,0 @@ const inf = Infinity; |
@@ -1,2 +0,2 @@ | ||
/*! https://github.com/leeoniya/uFuzzy (v1.0.12) */ | ||
var uFuzzy=function(){"use strict";const e=new Intl.Collator("en").compare,t=1/0,l=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n="eexxaacctt",r=(e,t,l)=>e.replace("A-Z",t).replace("a-z",l),i={unicode:!1,alpha:null,interSplit:"[^A-Za-z\\d']+",intraSplit:"[a-z][A-Z]",intraBound:"[A-Za-z]\\d|\\d[A-Za-z]|[a-z][A-Z]",interLft:0,interRgt:0,interChars:".",interIns:t,intraChars:"[a-z\\d']",intraIns:0,intraContr:"'[a-z]{1,2}\\b",intraMode:0,intraSlice:[1,t],intraSub:0,intraTrn:0,intraDel:0,intraFilt:()=>!0,sort:(t,l)=>{let{idx:n,chars:r,terms:i,interLft2:s,interLft1:a,start:g,intraIns:f,interIns:h}=t;return n.map(((e,t)=>t)).sort(((t,c)=>r[c]-r[t]||f[t]-f[c]||i[c]+s[c]+.5*a[c]-(i[t]+s[t]+.5*a[t])||h[t]-h[c]||g[t]-g[c]||e(l[n[t]],l[n[c]])))}},s=(e,l)=>0==l?"":1==l?e+"??":l==t?e+"*?":e+`{0,${l}}?`,a="(?:\\b|_)";function g(e){e=Object.assign({},i,e);let{unicode:t,interLft:g,interRgt:f,intraMode:c,intraSlice:u,intraIns:o,intraSub:p,intraTrn:d,intraDel:m,intraContr:x,intraSplit:R,interSplit:b,intraBound:L,intraChars:A}=e,S=e.letters??e.alpha;if(null!=S){let e=S.toLocaleUpperCase(),t=S.toLocaleLowerCase();b=r(b,e,t),R=r(R,e,t),L=r(L,e,t),A=r(A,e,t),x=r(x,e,t)}let E=t?"u":"";const I='".+?"',z=RegExp(I,"gi"+E),C=RegExp(`(?:\\s+|^)-(?:${A}+|${I})`,"gi"+E);let{intraRules:k}=e;null==k&&(k=e=>{let t=i.intraSlice,l=0,n=0,r=0,s=0;if(/[^\d]/.test(e)){let i=e.length;i>4?(t=u,l=o,n=p,r=d,s=m):3>i||(r=Math.min(d,1),4==i&&(l=Math.min(o,1)))}return{intraSlice:t,intraIns:l,intraSub:n,intraTrn:r,intraDel:s}});let y=!!R,j=RegExp(R,"g"+E),$=RegExp(b,"g"+E),w=RegExp("^"+b+"|"+b+"$","g"+E),Z=RegExp(x,"gi"+E);const M=e=>{let t=[];e=(e=e.replace(z,(e=>(t.push(e),n)))).replace(w,"").toLocaleLowerCase(),y&&(e=e.replace(j,(e=>e[0]+" "+e[1])));let l=0;return e.split($).filter((e=>""!=e)).map((e=>e===n?t[l++]:e))},D=/[^\d]+|\d+/g,T=(t,n=0,r=!1)=>{let i=M(t);if(0==i.length)return[];let h,u=Array(i.length).fill("");if(i=i.map(((e,t)=>e.replace(Z,(e=>(u[t]=e,""))))),1==c)h=i.map(((e,t)=>{if('"'===e[0])return l(e.slice(1,-1));let n="";for(let l of e.matchAll(D)){let e=l[0],{intraSlice:r,intraIns:i,intraSub:a,intraTrn:g,intraDel:f}=k(e);if(i+a+g+f==0)n+=e+u[t];else{let[l,h]=r,c=e.slice(0,l),o=e.slice(h),p=e.slice(l,h);1==i&&1==c.length&&c!=p[0]&&(c+="(?!"+c+")");let d=p.length,m=[e];if(a)for(let e=0;d>e;e++)m.push(c+p.slice(0,e)+A+p.slice(e+1)+o);if(g)for(let e=0;d-1>e;e++)p[e]!=p[e+1]&&m.push(c+p.slice(0,e)+p[e+1]+p[e]+p.slice(e+2)+o);if(f)for(let e=0;d>e;e++)m.push(c+p.slice(0,e+1)+"?"+p.slice(e+1)+o);if(i){let e=s(A,1);for(let t=0;d>t;t++)m.push(c+p.slice(0,t)+e+p.slice(t)+o)}n+="(?:"+m.join("|")+")"+u[t]}}return n}));else{let e=s(A,o);2==n&&o>0&&(e=")("+e+")("),h=i.map(((t,n)=>'"'===t[0]?l(t.slice(1,-1)):t.split("").map(((e,t,l)=>(1==o&&0==t&&l.length>1&&e!=l[t+1]&&(e+="(?!"+e+")"),e))).join(e)+u[n]))}let p=2==g?a:"",d=2==f?a:"",m=d+s(e.interChars,e.interIns)+p;return n>0?r?h=p+"("+h.join(")"+d+"|"+p+"(")+")"+d:(h="("+h.join(")("+m+")(")+")",h="(.??"+p+")"+h+"("+d+".*)"):(h=h.join(m),h=p+h+d),[RegExp(h,"i"+E),i,u]},F=(e,t,l)=>{let[n]=T(t);if(null==n)return null;let r=[];if(null!=l)for(let t=0;l.length>t;t++){let i=l[t];n.test(e[i])&&r.push(i)}else for(let t=0;e.length>t;t++)n.test(e[t])&&r.push(t);return r};let O=!!L,B=RegExp(b,E),U=RegExp(L,E);const v=(t,l,n)=>{let[r,i,s]=T(n,1),[a]=T(n,2),h=i.length,c=t.length,u=Array(c).fill(0),o={idx:Array(c),start:u.slice(),chars:u.slice(),terms:u.slice(),interIns:u.slice(),intraIns:u.slice(),interLft2:u.slice(),interRgt2:u.slice(),interLft1:u.slice(),interRgt1:u.slice(),ranges:Array(c)},p=1==g||1==f,d=0;for(let n=0;t.length>n;n++){let c=l[t[n]],u=c.match(r),m=u.index+u[1].length,x=m,R=!1,b=0,L=0,A=0,S=0,I=0,z=0,C=0,k=0,y=[];for(let t=0,l=2;h>t;t++,l+=2){let n=u[l].toLocaleLowerCase(),r=i[t],a='"'==r[0]?r.slice(1,-1):r+s[t],o=a.length,d=n.length,j=n==a;if(!j&&u[l+1].length>=o){let e=u[l+1].toLocaleLowerCase().indexOf(a);e>-1&&(y.push(x,d,e,o),x+=N(u,l,e,o),n=a,d=o,j=!0,0==t&&(m=x))}if(p||j){let e=x-1,r=x+d,i=!1,s=!1;if(-1==e||B.test(c[e]))j&&b++,i=!0;else{if(2==g){R=!0;break}if(O&&U.test(c[e]+c[e+1]))j&&L++,i=!0;else if(1==g){let e=u[l+1],r=x+d;if(e.length>=o){let s,g=0,f=!1,h=RegExp(a,"ig"+E);for(;s=h.exec(e);){g=s.index;let e=r+g,t=e-1;if(-1==t||B.test(c[t])){b++,f=!0;break}if(U.test(c[t]+c[e])){L++,f=!0;break}}f&&(i=!0,y.push(x,d,g,o),x+=N(u,l,g,o),n=a,d=o,j=!0,0==t&&(m=x))}if(!i){R=!0;break}}}if(r==c.length||B.test(c[r]))j&&A++,s=!0;else{if(2==f){R=!0;break}if(O&&U.test(c[r-1]+c[r]))j&&S++,s=!0;else if(1==f){R=!0;break}}j&&(I+=o,i&&s&&z++)}if(d>o&&(k+=d-o),t>0&&(C+=u[l-1].length),!e.intraFilt(a,n,x)){R=!0;break}h-1>t&&(x+=d+u[l+1].length)}if(!R){o.idx[d]=t[n],o.interLft2[d]=b,o.interLft1[d]=L,o.interRgt2[d]=A,o.interRgt1[d]=S,o.chars[d]=I,o.terms[d]=z,o.interIns[d]=C,o.intraIns[d]=k,o.start[d]=m;let e=c.match(a),l=e.index+e[1].length,r=y.length,i=r>0?0:1/0,s=r-4;for(let t=2;e.length>t;)if(i>s||y[i]!=l)l+=e[t].length,t++;else{let n=y[i+1],r=y[i+2],s=y[i+3],a=t,g="";for(let t=0;n>t;a++)g+=e[a],t+=e[a].length;e.splice(t,a-t,g),l+=N(e,t,r,s),i+=4}l=e.index+e[1].length;let g=o.ranges[d]=[],f=l,h=l;for(let t=2;e.length>t;t++){let n=e[t].length;l+=n,t%2==0?h=l:n>0&&(g.push(f,h),f=h=l)}h>f&&g.push(f,h),d++}}if(t.length>d)for(let e in o)o[e]=o[e].slice(0,d);return o},N=(e,t,l,n)=>{let r=e[t]+e[t+1].slice(0,l);return e[t-1]+=r,e[t]=e[t+1].slice(l,l+n),e[t+1]=e[t+1].slice(l+n),r.length};return{search:(...t)=>((t,n,r,i=1e3,s)=>{r=r?!0===r?5:r:0;let a=null,g=null,f=[];n=n.replace(C,(e=>{let t=e.trim().slice(1);return'"'===t[0]&&(t=l(t.slice(1,-1))),f.push(t),""}));let c,u=M(n);if(f.length>0){if(c=RegExp(f.join("|"),"i"+E),0==u.length){let e=[];for(let l=0;t.length>l;l++)c.test(t[l])||e.push(l);return[e,null,null]}}else if(0==u.length)return[null,null,null];if(r>0){let e=M(n);if(e.length>1){let l=e.slice().sort(((e,t)=>t.length-e.length));for(let e=0;l.length>e;e++){if(0==s?.length)return[[],null,null];s=F(t,l[e],s)}if(e.length>r)return[s,null,null];a=h(e).map((e=>e.join(" "))),g=[];let n=new Set;for(let e=0;a.length>e;e++)if(s.length>n.size){let l=s.filter((e=>!n.has(e))),r=F(t,a[e],l);for(let e=0;r.length>e;e++)n.add(r[e]);g.push(r)}else g.push([])}}null==a&&(a=[n],g=[s?.length>0?s:F(t,n)]);let o=null,p=null;if(f.length>0&&(g=g.map((e=>e.filter((e=>!c.test(t[e])))))),i>=g.reduce(((e,t)=>e+t.length),0)){o={},p=[];for(let l=0;g.length>l;l++){let n=g[l];if(null==n||0==n.length)continue;let r=a[l],i=v(n,t,r),s=e.sort(i,t,r);if(l>0)for(let e=0;s.length>e;e++)s[e]+=p.length;for(let e in i)o[e]=(o[e]??[]).concat(i[e]);p=p.concat(s)}}return[[].concat(...g),o,p]})(...t),split:M,filter:F,info:v,sort:e.sort}}const f=(()=>{let e={A:"ÁÀÃÂÄĄ",a:"áàãâäą",E:"ÉÈÊËĖ",e:"éèêëę",I:"ÍÌÎÏĮ",i:"íìîïį",O:"ÓÒÔÕÖ",o:"óòôõö",U:"ÚÙÛÜŪŲ",u:"úùûüūų",C:"ÇČĆ",c:"çčć",L:"Ł",l:"ł",N:"ÑŃ",n:"ñń",S:"ŠŚ",s:"šś",Z:"ŻŹ",z:"żź"},t=new Map,l="";for(let n in e)e[n].split("").forEach((e=>{l+=e,t.set(e,n)}));let n=RegExp(`[${l}]`,"g"),r=e=>t.get(e);return e=>{if("string"==typeof e)return e.replace(n,r);let t=Array(e.length);for(let l=0;e.length>l;l++)t[l]=e[l].replace(n,r);return t}})();function h(e){let t,l,n=(e=e.slice()).length,r=[e.slice()],i=Array(n).fill(0),s=1;for(;n>s;)s>i[s]?(t=s%2&&i[s],l=e[s],e[s]=e[t],e[t]=l,++i[s],s=1,r.push(e.slice())):(i[s]=0,++s);return r}const c=(e,t)=>t?`<mark>${e}</mark>`:e,u=(e,t)=>e+t;return g.latinize=f,g.permute=e=>h([...Array(e.length).keys()]).sort(((e,t)=>{for(let l=0;e.length>l;l++)if(e[l]!=t[l])return e[l]-t[l];return 0})).map((t=>t.map((t=>e[t])))),g.highlight=function(e,t,l=c,n="",r=u){n=r(n,l(e.substring(0,t[0]),!1))??n;for(let i=0;t.length>i;i+=2)n=r(n,l(e.substring(t[i],t[i+1]),!0))??n,t.length-3>i&&(n=r(n,l(e.substring(t[i+1],t[i+2]),!1))??n);return r(n,l(e.substring(t[t.length-1]),!1))??n},g}(); | ||
/*! https://github.com/leeoniya/uFuzzy (v1.0.13) */ | ||
var uFuzzy=function(){"use strict";const e=new Intl.Collator("en",{numeric:!0,sensitivity:"base"}).compare,t=1/0,l=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n="eexxaacctt",r=(e,t,l)=>e.replace("A-Z",t).replace("a-z",l),i={unicode:!1,alpha:null,interSplit:"[^A-Za-z\\d']+",intraSplit:"[a-z][A-Z]",intraBound:"[A-Za-z]\\d|\\d[A-Za-z]|[a-z][A-Z]",interLft:0,interRgt:0,interChars:".",interIns:t,intraChars:"[a-z\\d']",intraIns:0,intraContr:"'[a-z]{1,2}\\b",intraMode:0,intraSlice:[1,t],intraSub:0,intraTrn:0,intraDel:0,intraFilt:()=>!0,sort:(t,l)=>{let{idx:n,chars:r,terms:i,interLft2:s,interLft1:a,start:g,intraIns:f,interIns:h}=t;return n.map(((e,t)=>t)).sort(((t,c)=>r[c]-r[t]||f[t]-f[c]||i[c]+s[c]+.5*a[c]-(i[t]+s[t]+.5*a[t])||h[t]-h[c]||g[t]-g[c]||e(l[n[t]],l[n[c]])))}},s=(e,l)=>0==l?"":1==l?e+"??":l==t?e+"*?":e+`{0,${l}}?`,a="(?:\\b|_)";function g(e){e=Object.assign({},i,e);let{unicode:t,interLft:g,interRgt:f,intraMode:c,intraSlice:u,intraIns:o,intraSub:p,intraTrn:d,intraDel:m,intraContr:x,intraSplit:b,interSplit:R,intraBound:L,intraChars:A}=e,S=e.letters??e.alpha;if(null!=S){let e=S.toLocaleUpperCase(),t=S.toLocaleLowerCase();R=r(R,e,t),b=r(b,e,t),L=r(L,e,t),A=r(A,e,t),x=r(x,e,t)}let E=t?"u":"";const I='".+?"',z=RegExp(I,"gi"+E),C=RegExp(`(?:\\s+|^)-(?:${A}+|${I})`,"gi"+E);let{intraRules:y}=e;null==y&&(y=e=>{let t=i.intraSlice,l=0,n=0,r=0,s=0;if(/[^\d]/.test(e)){let i=e.length;i>4?(t=u,l=o,n=p,r=d,s=m):3>i||(r=Math.min(d,1),4==i&&(l=Math.min(o,1)))}return{intraSlice:t,intraIns:l,intraSub:n,intraTrn:r,intraDel:s}});let k=!!b,j=RegExp(b,"g"+E),$=RegExp(R,"g"+E),w=RegExp("^"+R+"|"+R+"$","g"+E),Z=RegExp(x,"gi"+E);const M=e=>{let t=[];e=(e=e.replace(z,(e=>(t.push(e),n)))).replace(w,"").toLocaleLowerCase(),k&&(e=e.replace(j,(e=>e[0]+" "+e[1])));let l=0;return e.split($).filter((e=>""!=e)).map((e=>e===n?t[l++]:e))},D=/[^\d]+|\d+/g,T=(t,n=0,r=!1)=>{let i=M(t);if(0==i.length)return[];let h,u=Array(i.length).fill("");if(i=i.map(((e,t)=>e.replace(Z,(e=>(u[t]=e,""))))),1==c)h=i.map(((e,t)=>{if('"'===e[0])return l(e.slice(1,-1));let n="";for(let l of e.matchAll(D)){let e=l[0],{intraSlice:r,intraIns:i,intraSub:a,intraTrn:g,intraDel:f}=y(e);if(i+a+g+f==0)n+=e+u[t];else{let[l,h]=r,c=e.slice(0,l),o=e.slice(h),p=e.slice(l,h);1==i&&1==c.length&&c!=p[0]&&(c+="(?!"+c+")");let d=p.length,m=[e];if(a)for(let e=0;d>e;e++)m.push(c+p.slice(0,e)+A+p.slice(e+1)+o);if(g)for(let e=0;d-1>e;e++)p[e]!=p[e+1]&&m.push(c+p.slice(0,e)+p[e+1]+p[e]+p.slice(e+2)+o);if(f)for(let e=0;d>e;e++)m.push(c+p.slice(0,e+1)+"?"+p.slice(e+1)+o);if(i){let e=s(A,1);for(let t=0;d>t;t++)m.push(c+p.slice(0,t)+e+p.slice(t)+o)}n+="(?:"+m.join("|")+")"+u[t]}}return n}));else{let e=s(A,o);2==n&&o>0&&(e=")("+e+")("),h=i.map(((t,n)=>'"'===t[0]?l(t.slice(1,-1)):t.split("").map(((e,t,l)=>(1==o&&0==t&&l.length>1&&e!=l[t+1]&&(e+="(?!"+e+")"),e))).join(e)+u[n]))}let p=2==g?a:"",d=2==f?a:"",m=d+s(e.interChars,e.interIns)+p;return n>0?r?h=p+"("+h.join(")"+d+"|"+p+"(")+")"+d:(h="("+h.join(")("+m+")(")+")",h="(.??"+p+")"+h+"("+d+".*)"):(h=h.join(m),h=p+h+d),[RegExp(h,"i"+E),i,u]},F=(e,t,l)=>{let[n]=T(t);if(null==n)return null;let r=[];if(null!=l)for(let t=0;l.length>t;t++){let i=l[t];n.test(e[i])&&r.push(i)}else for(let t=0;e.length>t;t++)n.test(e[t])&&r.push(t);return r};let O=!!L,v=RegExp(R,E),B=RegExp(L,E);const U=(t,l,n)=>{let[r,i,s]=T(n,1),[a]=T(n,2),h=i.length,c=t.length,u=Array(c).fill(0),o={idx:Array(c),start:u.slice(),chars:u.slice(),terms:u.slice(),interIns:u.slice(),intraIns:u.slice(),interLft2:u.slice(),interRgt2:u.slice(),interLft1:u.slice(),interRgt1:u.slice(),ranges:Array(c)},p=1==g||1==f,d=0;for(let n=0;t.length>n;n++){let c=l[t[n]],u=c.match(r),m=u.index+u[1].length,x=m,b=!1,R=0,L=0,A=0,S=0,I=0,z=0,C=0,y=0,k=[];for(let t=0,l=2;h>t;t++,l+=2){let n=u[l].toLocaleLowerCase(),r=i[t],a='"'==r[0]?r.slice(1,-1):r+s[t],o=a.length,d=n.length,j=n==a;if(!j&&u[l+1].length>=o){let e=u[l+1].toLocaleLowerCase().indexOf(a);e>-1&&(k.push(x,d,e,o),x+=N(u,l,e,o),n=a,d=o,j=!0,0==t&&(m=x))}if(p||j){let e=x-1,r=x+d,i=!1,s=!1;if(-1==e||v.test(c[e]))j&&R++,i=!0;else{if(2==g){b=!0;break}if(O&&B.test(c[e]+c[e+1]))j&&L++,i=!0;else if(1==g){let e=u[l+1],r=x+d;if(e.length>=o){let s,g=0,f=!1,h=RegExp(a,"ig"+E);for(;s=h.exec(e);){g=s.index;let e=r+g,t=e-1;if(-1==t||v.test(c[t])){R++,f=!0;break}if(B.test(c[t]+c[e])){L++,f=!0;break}}f&&(i=!0,k.push(x,d,g,o),x+=N(u,l,g,o),n=a,d=o,j=!0,0==t&&(m=x))}if(!i){b=!0;break}}}if(r==c.length||v.test(c[r]))j&&A++,s=!0;else{if(2==f){b=!0;break}if(O&&B.test(c[r-1]+c[r]))j&&S++,s=!0;else if(1==f){b=!0;break}}j&&(I+=o,i&&s&&z++)}if(d>o&&(y+=d-o),t>0&&(C+=u[l-1].length),!e.intraFilt(a,n,x)){b=!0;break}h-1>t&&(x+=d+u[l+1].length)}if(!b){o.idx[d]=t[n],o.interLft2[d]=R,o.interLft1[d]=L,o.interRgt2[d]=A,o.interRgt1[d]=S,o.chars[d]=I,o.terms[d]=z,o.interIns[d]=C,o.intraIns[d]=y,o.start[d]=m;let e=c.match(a),l=e.index+e[1].length,r=k.length,i=r>0?0:1/0,s=r-4;for(let t=2;e.length>t;)if(i>s||k[i]!=l)l+=e[t].length,t++;else{let n=k[i+1],r=k[i+2],s=k[i+3],a=t,g="";for(let t=0;n>t;a++)g+=e[a],t+=e[a].length;e.splice(t,a-t,g),l+=N(e,t,r,s),i+=4}l=e.index+e[1].length;let g=o.ranges[d]=[],f=l,h=l;for(let t=2;e.length>t;t++){let n=e[t].length;l+=n,t%2==0?h=l:n>0&&(g.push(f,h),f=h=l)}h>f&&g.push(f,h),d++}}if(t.length>d)for(let e in o)o[e]=o[e].slice(0,d);return o},N=(e,t,l,n)=>{let r=e[t]+e[t+1].slice(0,l);return e[t-1]+=r,e[t]=e[t+1].slice(l,l+n),e[t+1]=e[t+1].slice(l+n),r.length};return{search:(...t)=>((t,n,r,i=1e3,s)=>{r=r?!0===r?5:r:0;let a=null,g=null,f=[];n=n.replace(C,(e=>{let t=e.trim().slice(1);return'"'===t[0]&&(t=l(t.slice(1,-1))),f.push(t),""}));let c,u=M(n);if(f.length>0){if(c=RegExp(f.join("|"),"i"+E),0==u.length){let e=[];for(let l=0;t.length>l;l++)c.test(t[l])||e.push(l);return[e,null,null]}}else if(0==u.length)return[null,null,null];if(r>0){let e=M(n);if(e.length>1){let l=e.slice().sort(((e,t)=>t.length-e.length));for(let e=0;l.length>e;e++){if(0==s?.length)return[[],null,null];s=F(t,l[e],s)}if(e.length>r)return[s,null,null];a=h(e).map((e=>e.join(" "))),g=[];let n=new Set;for(let e=0;a.length>e;e++)if(s.length>n.size){let l=s.filter((e=>!n.has(e))),r=F(t,a[e],l);for(let e=0;r.length>e;e++)n.add(r[e]);g.push(r)}else g.push([])}}null==a&&(a=[n],g=[s?.length>0?s:F(t,n)]);let o=null,p=null;if(f.length>0&&(g=g.map((e=>e.filter((e=>!c.test(t[e])))))),i>=g.reduce(((e,t)=>e+t.length),0)){o={},p=[];for(let l=0;g.length>l;l++){let n=g[l];if(null==n||0==n.length)continue;let r=a[l],i=U(n,t,r),s=e.sort(i,t,r);if(l>0)for(let e=0;s.length>e;e++)s[e]+=p.length;for(let e in i)o[e]=(o[e]??[]).concat(i[e]);p=p.concat(s)}}return[[].concat(...g),o,p]})(...t),split:M,filter:F,info:U,sort:e.sort}}const f=(()=>{let e={A:"ÁÀÃÂÄĄ",a:"áàãâäą",E:"ÉÈÊËĖ",e:"éèêëę",I:"ÍÌÎÏĮ",i:"íìîïį",O:"ÓÒÔÕÖ",o:"óòôõö",U:"ÚÙÛÜŪŲ",u:"úùûüūų",C:"ÇČĆ",c:"çčć",L:"Ł",l:"ł",N:"ÑŃ",n:"ñń",S:"ŠŚ",s:"šś",Z:"ŻŹ",z:"żź"},t=new Map,l="";for(let n in e)e[n].split("").forEach((e=>{l+=e,t.set(e,n)}));let n=RegExp(`[${l}]`,"g"),r=e=>t.get(e);return e=>{if("string"==typeof e)return e.replace(n,r);let t=Array(e.length);for(let l=0;e.length>l;l++)t[l]=e[l].replace(n,r);return t}})();function h(e){let t,l,n=(e=e.slice()).length,r=[e.slice()],i=Array(n).fill(0),s=1;for(;n>s;)s>i[s]?(t=s%2&&i[s],l=e[s],e[s]=e[t],e[t]=l,++i[s],s=1,r.push(e.slice())):(i[s]=0,++s);return r}const c=(e,t)=>t?`<mark>${e}</mark>`:e,u=(e,t)=>e+t;return g.latinize=f,g.permute=e=>h([...Array(e.length).keys()]).sort(((e,t)=>{for(let l=0;e.length>l;l++)if(e[l]!=t[l])return e[l]-t[l];return 0})).map((t=>t.map((t=>e[t])))),g.highlight=function(e,t,l=c,n="",r=u){n=r(n,l(e.substring(0,t[0]),!1))??n;for(let i=0;t.length>i;i+=2)n=r(n,l(e.substring(t[i],t[i+1]),!0))??n,t.length-3>i&&(n=r(n,l(e.substring(t[i+1],t[i+2]),!1))??n);return r(n,l(e.substring(t[t.length-1]),!1))??n},g}(); |
{ | ||
"name": "@leeoniya/ufuzzy", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "A tiny, efficient fuzzy matcher that doesn't suck", | ||
@@ -5,0 +5,0 @@ "main": "./dist/uFuzzy.cjs.js", |
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
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
128448