hugo-theme-zzo/assets/js/fuzzysort.min.js

8 lines
7.2 KiB
JavaScript
Raw Normal View History

2020-02-05 17:23:27 +00:00
/**
* Minified by jsDelivr using UglifyJS v3.4.4.
* Original file: /npm/fuzzysort@1.1.4/fuzzysort.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
!function(e,r){"function"==typeof define&&define.amd?define([],r):"object"==typeof module&&module.exports?module.exports=r():e.fuzzysort=r()}(this,function(){var P="undefined"!=typeof require&&"undefined"==typeof window,n=new Map,o=new Map,j=[];j.total=0;var m=[],T=[];function r(){n.clear(),o.clear(),m=[],T=[]}function N(e){for(var r=-9007199254740991,n=e.length-1;0<=n;--n){var o=e[n];if(null!==o){var t=o.score;r<t&&(r=t)}}return-9007199254740991===r?null:r}function S(e,r){var n=e[r];if(void 0!==n)return n;var o=r;Array.isArray(r)||(o=r.split("."));for(var t=o.length,i=-1;e&&++i<t;)e=e[o[i]];return e}function D(e){return"object"==typeof e}var t=function(){var i=[],a=0,e={};function r(){for(var e=0,r=i[e],n=1;n<a;){var o=n+1;e=n,o<a&&i[o].score<i[n].score&&(e=o),i[e-1>>1]=i[e],n=1+(e<<1)}for(var t=e-1>>1;0<e&&r.score<i[t].score;t=(e=t)-1>>1)i[e]=i[t];i[e]=r}return e.add=function(e){var r=a;i[a++]=e;for(var n=r-1>>1;0<r&&e.score<i[n].score;n=(r=n)-1>>1)i[r]=i[n];i[r]=e},e.poll=function(){if(0!==a){var e=i[0];return i[0]=i[--a],r(),e}},e.peek=function(e){if(0!==a)return i[0]},e.replaceTop=function(e){i[0]=e,r()},e},k=t();return function e(A){var L={single:function(e,r,n){return e?(D(e)||(e=L.getPreparedSearch(e)),r?(D(r)||(r=L.getPrepared(r)),((n&&void 0!==n.allowTypo?n.allowTypo:!A||void 0===A.allowTypo||A.allowTypo)?L.algorithm:L.algorithmNoTypo)(e,r,e[0])):null):null},go:function(e,r,n){if(!e)return j;var o=(e=L.prepareSearch(e))[0],t=n&&n.threshold||A&&A.threshold||-9007199254740991,i=n&&n.limit||A&&A.limit||9007199254740991,a=(n&&void 0!==n.allowTypo?n.allowTypo:!A||void 0===A.allowTypo||A.allowTypo)?L.algorithm:L.algorithmNoTypo,l=0,f=0,u=r.length;if(n&&n.keys)for(var s=n.scoreFn||N,p=n.keys,d=p.length,c=u-1;0<=c;--c){for(var g=r[c],v=new Array(d),h=d-1;0<=h;--h)(y=S(g,x=p[h]))?(D(y)||(y=L.getPrepared(y)),v[h]=a(e,y,o)):v[h]=null;v.obj=g;var w=s(v);null!==w&&(w<t||(v.score=w,l<i?(k.add(v),++l):(++f,w>k.peek().score&&k.replaceTop(v))))}else if(n&&n.key){var x=n.key;for(c=u-1;0<=c;--c)(y=S(g=r[c],x))&&(D(y)||(y=L.getPrepared(y)),null!==(m=a(e,y,o))&&(m.score<t||(m={target:m.target,_targetLowerCodes:null,_nextBeginningIndexes:null,score:m.score,indexes:m.indexes,obj:g},l<i?(k.add(m),++l):(++f,m.score>k.peek().score&&k.replaceTop(m)))))}else for(c=u-1;0<=c;--c){var y,m;(y=r[c])&&(D(y)||(y=L.getPrepared(y)),null!==(m=a(e,y,o))&&(m.score<t||(l<i?(k.add(m),++l):(++f,m.score>k.peek().score&&k.replaceTop(m)))))}if(0===l)return j;var T=new Array(l);for(c=l-1;0<=c;--c)T[c]=k.poll();return T.total=l+f,T},goAsync:function(I,B,_){var C=!1,e=new Promise(function(c,g){if(!I)return c(j);var v=(I=L.prepareSearch(I))[0],h=t(),w=B.length-1,x=_&&_.threshold||A&&A.threshold||-9007199254740991,y=_&&_.limit||A&&A.limit||9007199254740991,m=(_&&void 0!==_.allowTypo?_.allowTypo:!A||void 0===A.allowTypo||A.allowTypo)?L.algorithm:L.algorithmNoTypo,T=0,k=0;function b(){if(C)return g("canceled");var e=Date.now();if(_&&_.keys)for(var r=_.scoreFn||N,n=_.keys,o=n.length;0<=w;--w){for(var t=B[w],i=new Array(o),a=o-1;0<=a;--a)(u=S(t,f=n[a]))?(D(u)||(u=L.getPrepared(u)),i[a]=m(I,u,v)):i[a]=null;i.obj=t;var l=r(i);if(null!==l&&!(l<x)&&(i.score=l,T<y?(h.add(i),++T):(++k,l>h.peek().score&&h.replaceTop(i)),w%1e3==0&&10<=Date.now()-e))return void(P?setImmediate(b):setTimeout(b))}else if(_&&_.key){for(var f=_.key;0<=w;--w)if((u=S(t=B[w],f))&&(D(u)||(u=L.getPrepared(u)),null!==(s=m(I,u,v))&&!(s.score<x)&&(s={target:s.target,_targetLowerCodes:null,_nextBeginningIndexes:null,score:s.score,indexes:s.indexes,obj:t},T<y?(h.add(s),++T):(++k,s.score>h.peek().score&&h.replaceTop(s)),w%1e3==0&&10<=Date.now()-e)))return void(P?setImmediate(b):setTimeout(b))}else for(;0<=w;--w){var u,s;if((u=B[w])&&(D(u)||(u=L.getPrepared(u)),null!==(s=m(I,u,v))&&!(s.score<x)&&(T<y?(h.add(s),++T):(++k,s.score>h.peek().score&&h.replaceTop(s)),w%1e3==0&&10<=Date.now()-e)))return void(P?setImmediate(b):setTimeout(b))}if(0===T)return c(j);for(var p=new Array(T),d=T-1;0<=d;--d)p[d]=h.poll();p.total=T+k,c(p)}P?setImmediate(b):b()});return e.cancel=function(){C=!0},e},highlight:function(e,r,n){
//# sourceMappingURL=/sm/57e217d47ad2be09f5ef2bc70608da208649aef7bbc194f7ee23c51727f8955a.map