1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-08-21 21:25:38 +02:00

add source code v0.7.0 (pre-alpha)

This commit is contained in:
Thomas Wilkerling
2021-05-16 20:01:45 +02:00
parent addab0a3c3
commit 4dd44d2f6b
74 changed files with 2541 additions and 6832 deletions

View File

@@ -1,29 +0,0 @@
/**!
* FlexSearch.js v0.7.0
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(){'use strict';Object.assign||(Object.assign=function(){for(var a=arguments,b=a.length,c=a[0],d=1,e,g,f;d<b;d++){e=a[d];g=Object.keys(e);f=g.length;for(var h=0,k;h<f;h++)k=g[h],c[k]=e[k]}return c});window.requestAnimationFrame||(window.requestAnimationFrame=window.setTimeout);window.cancelAnimationFrame||(window.cancelAnimationFrame=window.clearTimeout);window.Promise||(window.Promise=function(){function a(b){this.a=null;var c=this;b(function(d){c.a&&(c.a(d),c.a=null)})}a.prototype.then=function(b){this.a=b};return a}());function q(a){return"string"===typeof a}function y(a){return a.constructor===Array}function A(a){return"object"===typeof a}function C(a){for(var b=Array(a),c=0;c<a;c++)b[c]=F();return b}function F(){return Object.create(null)}function H(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function I(a){return new RegExp(a,"g")}function J(a){for(var b="",c="",d=0,e=a.length,g=void 0;d<e;d++)(g=a[d])!==c&&(b+=c=g);return b}
function L(a,b,c,d){if(b&&(c&&b&&(b=H(b,c)),b&&a.j&&(b=H(b,a.j)),a.l&&1<b.length&&(b=H(b,a.l)),b&&(d||""===d)&&(b=b.split(d),a.filter))){a=a.filter;c=b.length;d=[];for(var e=0,g=0;e<c;e++){var f=b[e];f&&!a[f]&&(d[g++]=f)}b=d}return b};var N={memory:{charset:"latin:extra",threshold:0,b:1},speed:{threshold:1,b:3,depth:2},match:{charset:"latin:extra",m:"full",threshold:1,b:3},score:{charset:"latin:extra",threshold:1,b:9,depth:4},balance:{charset:"latin:balance",threshold:0,b:3,depth:3},fast:{threshold:8,b:9,depth:1}};var aa={encode:P,c:!1},ba=/[\W_]+/;function P(a){return L(this,a.toLowerCase(),!1,ba)};var ca=0,da={},Q={};function S(a){if(!(this instanceof S))return new S(a);var b=a&&a.id;this.id=b||0===b?b:ca++;this.init(a);ea(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});ea(this,"length",function(){return this.index.length})}S.registerCharset=function(a,b){Q[a]=b;return S};S.registerLanguage=function(a,b){da[a]=b;return S};
S.prototype.init=function(a){var b;if(a)if(q(a))a=N[a];else if(b=a.preset)a=Object.assign({},N[b],a);a||(a={});this.async=a.async;var c=a.charset,d=a.lang;q(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=Q[c]);q(d)&&(d=da[d]);this.o=b=c&&c.m||a.tokenize||"strict";this.depth="strict"===b&&a.depth||0;this.c=c&&c.c||a.rtl||!1;this.b=a.resolution||9;this.threshold=b=a.threshold||0;this.b<=b&&(this.b=b+1);this.encode=a.encode||c&&c.encode||P;this.j=(b=a.matcher||d&&d.j)&&fa(b,!1);this.l=(b=a.stemmer||d&&
d.l)&&fa(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=F();var e=0;for(var g=c.length;e<g;e++)d[c[e]]=1;c=d}this.filter=c;(this.a=e=(b=a.doc)&&ha(b))&&(a.doc=null);this.i=C(this.b-this.threshold);this.g=F();this.f=F();if(e){this.h=F();b=e.index={};c=e.keys=[];d=e.field;g=e.store;y(e.id)||(e.id=e.id.split(":"));if(g){var f=F();if(q(g))f[g]=1;else if(y(g))for(var h=0;h<g.length;h++)f[g[h]]=1;else A(g)&&(f=g);e.store=f}if(d){if(!y(d))if(A(d)){var k=d;e.field=d=Object.keys(d)}else e.field=d=[d];for(e=0;e<
d.length;e++)g=d[e],y(g)||(k&&(a=k[g]),c[e]=g,d[e]=g.split(":")),b[g]=new S(a)}}return this};function ha(a){var b=F(),c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];b[c]=y(d)?d.slice(0):A(d)?ha(d):d}return b}
S.prototype.add=function(a,b,c,d,e){if(this.a&&A(a))return T(this,"add",a,b);if(b&&q(b)&&(a||0===a)){if(this.f[a]&&!d)return this.update(a,b);if(!e){if(this.async){var g=this,f=new Promise(function(O){setTimeout(function(){g.add(a,b,null,d,!0);g=null;O()})});if(c)f.then(c);else return f;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=b;e=F();e._ctx=F();for(var h=c.length,k=this.threshold,p=this.depth,m=this.b,l=this.i,n=this.c,t=0;t<h;t++){var u=
c[t];if(u){f=1;var w=u.length,r=(n?t+1:h-t)/h,v="";switch(this.o){case "reverse":case "both":for(var x=w;--x;)v=u[x]+v,U(l,e,v,a,n?1:(w-x)/w,r,k,m-1);v="";case "forward":for(x=0;x<w;x++)v+=u[x],U(l,e,v,a,n?(x+1)/w:1,r,k,m-1);break;case "full":for(x=0;x<w;x++)for(var K=(n?x+1:w-x)/w,B=w;B>x;B--)v=u.substring(x,B),U(l,e,v,a,K,r,k,m-1);break;default:if(w=U(l,e,u,a,1,r,k,m-1),p&&1<h&&w>=k)for(w=e._ctx[u]||(e._ctx[u]=F()),u=this.g[u]||(this.g[u]=C(m-(k||0))),r=t-p,v=t+p+1,0>r&&(r=0),v>h&&(v=h);r<v;r++)r!==
t&&U(u,w,c[r],a,0,m-(r<t?t-r:r-t),k,m-1)}}}f&&(this.f[a]=1)}return this};
function T(a,b,c,d){if(y(c)){var e=c.length;if(e)for(var g=0;g<e;g++)T(a,b,c[g],g===e-1&&d)}else{var f=a.a.index,h=a.a.keys,k=a.a.tag;g=a.a.store;var p;var m=a.a.id;e=c;for(var l=0;l<m.length;l++)e=e[m[l]];if("remove"===b){if(delete a.h[e],c=h.length)for(g=0;g<c;g++)f[h[g]].remove(e,g===c-1&&d)}else{if(k){for(p=0;p<k.length;p++){var n=k[p];var t=c;m=n.split(":");for(l=0;l<m.length;l++)t=t[m[l]];t="@"+t}p=a.s[n];p=p[t]||(p[t]=[])}m=a.a.field;k=0;for(n=m.length;k<n;k++){l=m[k];t=c;for(var u=0;u<l.length;u++)t=
t[l[u]];l=f[h[k]];"add"===b?l.add(e,t,k===n-1&&d):l.update(e,t,k===n-1&&d)}if(g){d=Object.keys(g);b=F();for(f=0;f<d.length;f++)if(h=d[f],g[h])for(h=h.split(":"),k=m=void 0,n=0;n<h.length;n++)t=h[n],m=(m||c)[t],k=(k||b)[t]=m;c=b}p&&(p[p.length]=c);a.h[e]=c}}return a}S.prototype.update=function(a,b,c){if(this.a&&A(a))return T(this,"update",a,b);this.f[a]&&q(b)&&(this.remove(a),this.add(a,b,c,!0));return this};
S.prototype.remove=function(a,b,c){if(this.a&&A(a))return T(this,"remove",a,b);if(this.f[a]){if(!c){if(this.async&&"function"!==typeof importScripts){var d=this;c=new Promise(function(e){setTimeout(function(){d.remove(a,null,!0);d=null;e()})});if(b)c.then(b);else return c;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.b-(this.threshold||0);b++)W(this.i[b],a);this.depth&&W(this.g,a);delete this.f[a]}return this};var X;
function Y(a,b,c,d,e,g,f,h){c=ia(c,e,!1,b,f,h);if(g){g=c.page;var k=c.next;c=c.result}b=c;a=a.h;c=b.length;e=Array(c);for(f=0;f<c;f++)e[f]=a[b[f]];c=e;d&&("function"!==typeof d&&(X=d.split(":"),d=1<X.length?ja:ka),c.sort(d));return c=Z(g,k,c)}
S.prototype.search=function(a,b,c,d){if(A(b)){if(y(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&"function"===typeof b?(c=b,b=1E3):b||0===b||(b=1E3);var g=[],f=a;if(A(a)&&!y(a)){c||(c=a.callback)&&(f.callback=null);var h=a.sort;var k=!1;b=a.limit;var p=a.threshold;var m=!1;a=a.query}if(this.a){p=this.a.index;var l=f.bool||"or";m=f.field;var n=l,t,u;if(m)y(m)||(m=[m]);else if(y(f)){var w=f;m=[];n=[];for(var r=0;r<f.length;r++){var v=f[r];a=v.bool||l;m[r]=v.field;n[r]=
a;"not"===a?t=!0:"and"===a&&(u=!0)}}else m=this.a.keys;l=m.length;for(r=0;r<l;r++)w&&(f=w[r]),k&&!q(f)&&(f.page=null,f.limit=0),g[r]=p[m[r]].search(f,0);if(c)return c(Y(this,n,g,h,b,k,u,t));if(this.async){var x=this;return new Promise(function(V){Promise.all(g).then(function(oa){V(Y(x,n,oa,h,b,k,u,t))})})}return Y(this,n,g,h,b,k,u,t)}p||(p=this.threshold||0);if(!d){if(this.async&&"function"!==typeof importScripts){var K=this;p=new Promise(function(V){setTimeout(function(){V(K.search(f,b,null,!0));
K=null})});if(c)p.then(c);else return p;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!q(a))return g;f=a;f=this.encode(f);if(!f.length)return g;c=f;w=c.length;a=!0;d=[];e=F();var B=0;1<w&&(this.depth?l=!0:c.sort(la));if(!l||(r=this.g))for(var O=this.b;B<w;B++){var z=c[B];if(z){if(l){if(!v)if(r[z])v=z,e[z]=1;else if(!m)return g;if(m&&B===w-1&&!d.length)l=!1,z=v||z,e[z]=0;else if(!v)continue}if(!e[z]){var G=[],D=!1,M=0;if(v=l?r[v]:this.i)for(var R=void 0,E=0;E<O-p;E++)if(R=v[E]&&v[E][z])G[M++]=
R,D=!0;if(D)v=z,d[d.length]=1<M?G.concat.apply([],G):G[0];else{a=!1;break}e[z]=1}}}else a=!1;a&&(g=ia(d,b,k));return g};S.prototype.clear=function(){return this.destroy().init()};S.prototype.destroy=function(){this.i=this.g=this.f=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.h=null}return this};function ea(a,b,c){Object.defineProperty(a,b,{get:c})}
function U(a,b,c,d,e,g,f,h){if(b[c])return b[c];e=e?(h-(f||h/1.5))*g+(f||h/1.5)*e:g;b[c]=e;e>=f&&(a=a[h-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function W(a,b){if(a)for(var c=Object.keys(a),d=0,e=c.length;d<e;d++){var g=c[d],f=a[g];if(f)for(var h=0,k=f.length;h<k;h++)if(f[h]===b){1===k?delete a[g]:f.splice(h,1);break}else A(f[h])&&W(f[h],b)}}
function fa(a,b){for(var c=Object.keys(a),d=c.length,e=[],g="",f=0,h=0,k;h<d;h++){var p=c[h];(k=a[p])?(e[f++]=I(b?"(?!\\b)"+p+"(\\b|_)":p),e[f++]=k):g+=(g?"|":"")+p}g&&(e[f++]=I(b?"(?!\\b)("+g+")(\\b|_)":"("+g+")"),e[f]="");return e}function la(a,b){return b.length-a.length}function ka(a,b){a=a[X];b=b[X];return a<b?-1:a>b?1:0}function ja(a,b){for(var c=X.length,d=0;d<c;d++)a=a[X[d]],b=b[X[d]];return a<b?-1:a>b?1:0}function Z(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}
function ia(a,b,c,d,e,g){var f=[];if(!0===c){c="0";var h=""}else h=c&&c.split(":");var k=a.length;if(1<k){var p=F(),m,l=0,n,t=!0,u=0,w;h&&(2===h.length?h=!1:h=w=parseInt(h[0],10));if(g){for(m=F();l<k;l++)if("not"===d[l]){var r=a[l];var v=r.length;for(n=0;n<v;n++)m["@"+r[n]]=1}else var x=l+1;if("undefined"===typeof x)return Z(c,E,f);l=0}else var K=q(d)&&d;for(var B;l<k;l++){var O=l===(x||k)-1;if(!K||!l)if((n=K||d&&d[l])&&"and"!==n)if("or"===n)B=!1;else continue;else B=e=!0;r=a[l];if(v=r.length){if(t)if(D){t=
D.length;for(n=0;n<t;n++){var z=D[n];var G="@"+z;g&&m[G]||(p[G]=1,e||(f[u++]=z))}var D=null;t=!1}else{D=r;continue}G=!1;for(n=0;n<v;n++){z=r[n];var M="@"+z,R=e?p[M]||0:l;if(!(!R||g&&m[M]||!e&&p[M])&&R===l){if(O){if(!w||--w<u)if(f[u++]=z,b&&u===b)return Z(c,u+(h||0),f)}else p[M]=l+1;G=!0}}if(B&&!G)break}else if(B)return Z(c,E,r)}if(D)if(a=D.length,g)for(n=h?parseInt(h,10):0;n<a;n++)g=D[n],m["@"+g]||(f[u++]=g);else f=D}else!k||d&&"not"===d[0]||(f=a[0],h&&(h=parseInt(h[0],10)));if(b){m=f.length;h&&h>
m&&(h=0);h=h||0;var E=h+b;E<m?f=f.slice(h,E):(E=0,h&&(f=f.slice(h)))}return Z(c,E,f)};var na={encode:ma,c:!1},pa=/[\W_]+/,qa=[I("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",I("[\u00e8\u00e9\u00ea\u00eb]"),"e",I("[\u00ec\u00ed\u00ee\u00ef]"),"i",I("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",I("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",I("[\u00fd\u0177\u00ff]"),"y",I("\u00f1"),"n",I("[\u00e7c]"),"k",I("\u00df"),"s",I(" & ")," and "];function ma(a,b){return L(b||this,a.toLowerCase(),qa,pa)};var ra=[I("ae"),"a",I("ai"),"ei",I("ay"),"ei",I("ey"),"ei",I("oe"),"o",I("ue"),"u",I("ie"),"i",I("sz"),"s",I("zs"),"s",I("sh"),"s",I("ck"),"k",I("cc"),"k",I("th"),"t",I("dt"),"t",I("ph"),"f",I("pf"),"f",I("ou"),"o",I("uo"),"u"];function sa(a,b,c){a&&(a=ma(a,b||this).join(" "),2<a.length&&(a=H(a,ra)),c||(1<a.length&&(a=J(a)),a&&(a=a.split(" "))));return a};var ua={encode:ta,c:!1},va=/[\W_]+/;function ta(a){return L(this,a.toLowerCase(),!1,va)};var xa={encode:wa,c:!1},ya=[I("(?!\\b)p"),"b",I("(?!\\b)z"),"s",I("(?!\\b)[cgq]"),"k",I("(?!\\b)n"),"m",I("(?!\\b)d"),"t",I("(?!\\b)[vw]"),"f",I("(?!\\b)[aeiouy]"),""];function wa(a){a&&(a=sa(a,this,!0),1<a.length&&(a=H(a,ya)),1<a.length&&(a=J(a)),a&&(a=a.split(" ")));return a};var Aa={encode:za,c:!1,m:"strict"},Ba=/[^a-z]+/;function za(a){a=L(this,a.toLowerCase(),!1,!1);var b=[];if(a)for(var c=a.split(Ba),d=c.length,e=0,g=0;e<d;e++)if((a=c[e])&&2<a.length&&(!this.filter||!this.filter[a])){for(var f=a[0],h=Ca(f),k=1;k<a.length;k++){var p=Ca(a[k]);if(p!==h&&(f+=p,h=p,4===f.length))break}b[g++]=(f+"0000").substring(0,4)}return b}
function Ca(a){switch(a){case "b":case "f":case "p":case "v":return 1;case "c":case "g":case "j":case "k":case "q":case "s":case "x":case "z":return 2;case "d":case "t":return 3;case "l":return 4;case "m":case "n":return 5;case "r":return 6}return""};var Ea={encode:Da,c:!0},Fa=/[\x00-\x7F]+/g;function Da(a){return L(this,a.replace(Fa," "),!1," ")};var Ha={encode:Ga,c:!1,m:"strict"},Ia=/[\x00-\x7F]+/g;function Ga(a){return L(this,a.replace(Ia,""),!1,"")};var Ka={encode:Ja,c:!1},La=/[\x00-\x7F]+/g;function Ja(a){return L(this,a.replace(La," "),!1," ")};Q["latin:advanced"]={encode:sa,c:!1};Q["latin:balance"]=ua;Q["latin:default"]=aa;Q["latin:extra"]=xa;Q["latin:simple"]=na;Q["latin:soundex"]=Aa;Q["arabic:default"]=Ea;Q["cjk:default"]=Ha;Q["cyrillic:default"]=Ka;(function(){var a=this||window,b;(b=a.define)&&b.amd?b([],function(){return S}):"object"===typeof a.exports?a.module.exports=S:a.FlexSearch=S})();}).call(this);

1864
dist/flexsearch.debug.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +0,0 @@
/**!
* FlexSearch.js v0.7.0 (ES5)
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(){'use strict';Object.assign||(Object.assign=function(){for(var a=arguments,b=a.length,c=a[0],d=1,e,f,g;d<b;d++){e=a[d];f=Object.keys(e);g=f.length;for(var h=0,k;h<g;h++)k=f[h],c[k]=e[k]}return c});window.requestAnimationFrame||(window.requestAnimationFrame=window.setTimeout);window.cancelAnimationFrame||(window.cancelAnimationFrame=window.clearTimeout);window.Promise||(window.Promise=function(){function a(b){this.b=null;var c=this;b(function(d){c.b&&(c.b(d),c.b=null)})}a.prototype.then=function(b){this.b=b};return a}());function t(a){return"string"===typeof a}function y(a){return a.constructor===Array}function aa(a){return"function"===typeof a}function z(a){return"object"===typeof a}function E(a){return"undefined"===typeof a}function ba(a){for(var b=Array(a),c=0;c<a;c++)b[c]=F();return b}function F(){return Object.create(null)}function G(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function K(a){return new RegExp(a,"g")}
function ca(a){for(var b="",c="",d=0,e=a.length,f=void 0;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b}function L(a,b,c,d){if(b&&(c&&b&&(b=G(b,c)),b&&a.u&&(b=G(b,a.u)),a.A&&1<b.length&&(b=G(b,a.A)),b&&(d||""===d)&&(b=b.split(d),a.filter))){a=a.filter;c=b.length;d=[];for(var e=0,f=0;e<c;e++){var g=b[e];g&&!a[g]&&(d[f++]=g)}b=d}return b};O.prototype.export=function(a){var b=!a||E(a.serialize)||a.serialize;if(this.a){var c=!a||E(a.doc)||a.doc,d=!a||E(a.index)||a.index;a=[];var e=0;if(d)for(d=this.a.keys;e<d.length;e++){var f=this.a.index[d[e]];a[e]=[f.j,f.i,Object.keys(f.f)]}c&&(a[e]=this.l)}else a=[this.j,this.i,Object.keys(this.f)];b&&(a=JSON.stringify(a));return a};
O.prototype.import=function(a,b){if(!b||E(b.serialize)||b.serialize)a=JSON.parse(a);var c={};if(this.a){var d=!b||E(b.doc)||b.doc,e=0;if(!b||E(b.index)||b.index){b=this.a.keys;for(var f=b.length,g=a[0][2];e<g.length;e++)c[g[e]]=1;for(e=0;e<f;e++){g=this.a.index[b[e]];var h=a[e];h&&(g.j=h[0],g.i=h[1],g.f=c)}}d&&(this.l=z(d)?d:a[e])}else{d=a[2];for(e=0;e<d.length;e++)c[d[e]]=1;this.j=a[0];this.i=a[1];this.f=c}};O.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};
O.prototype.where=function(a,b,c,d){var e=this.l,f=[],g=0,h;if(z(a)){c||(c=b);var k=Object.keys(a);var m=k.length;var q=!1;if(1===m&&"id"===k[0])return[e[a.id]];if((h=this.F)&&!d)for(var r=0;r<h.length;r++){var p=h[r],l=a[p];if(!E(l)){var n=this.w[p]["@"+l];if(0===--m)return n;k.splice(k.indexOf(p),1);delete a[p];break}}h=Array(m);for(r=0;r<m;r++)h[r]=k[r].split(":")}else{if(aa(a)){b=d||Object.keys(e);c=b.length;for(k=0;k<c;k++)m=e[b[k]],a(m)&&(f[g++]=m);return f}if(E(b))return[e[a]];if("id"===a)return[e[b]];
k=[a];m=1;h=[a.split(":")];q=!0}d=n||d||Object.keys(e);r=d.length;for(p=0;p<r;p++){l=n?d[p]:e[d[p]];for(var w=!0,v=0;v<m;v++){q||(b=a[k[v]]);var x=h[v],u=x.length,A=l;if(1<u)for(var B=0;B<u;B++)A=A[x[B]];else A=A[x[0]];if(A!==b){w=!1;break}}if(w&&(f[g++]=l,c&&g===c))break}return f};function P(a){this.clear();this.m=!0!==a&&a}P.prototype.clear=function(){this.cache=F();this.count=F();this.index=F();this.b=[]};P.prototype.set=function(a,b){if(this.m&&E(this.cache[a])){var c=this.b.length;if(c===this.m){c--;var d=this.b[c];delete this.cache[d];delete this.count[d];delete this.index[d]}this.b[c]=a;this.index[a]=c;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};
P.prototype.get=function(a){var b=this.cache[a];if(this.m&&b){var c=++this.count[a],d=this.index,e=d[a];if(0<e){for(var f=this.b,g=e;this.count[f[--e]]<=c&&-1!==e;);e++;if(e!==g){for(c=g;c>e;c--)g=f[c-1],f[c]=g,d[g]=c;f[e]=a;d[a]=e}}}return b};var S={},ea="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;function fa(a,b,c){var d=ha,e="flexsearch";d=ea?URL.createObjectURL(new Blob(["("+d.toString()+")()"],{type:"text/javascript"})):e+".browser.js";e+="-"+a;S[e]||(S[e]=[]);S[e][c]=new Worker(d);S[e][c].onmessage=b;console.log("Register Worker: "+e+"@"+c);return S[e][c]}
function ha(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+
1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ia(a,b,c,d){a=fa("id"+a,function(f){(f=f.data)&&f.result&&d(f.id,f.content,f.result,f.limit,f.where,f.cursor,f.suggest)},b);var e=O.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}O.prototype.G=function(a,b,c,d){this.s!==this.v&&(this.o=this.o.concat(c),this.s++,d&&this.o.length>=d&&(this.s=this.v),this.s===this.v&&(this.cache&&this.g.set(b,this.o),this.C&&this.C(this.o)));return this};var U={memory:{charset:"latin:extra",threshold:0,c:1},speed:{threshold:1,c:3,depth:2},match:{charset:"latin:extra",B:"full",threshold:1,c:3},score:{charset:"latin:extra",threshold:1,c:9,depth:4},balance:{charset:"latin:balance",threshold:0,c:3,depth:3},fast:{threshold:8,c:9,depth:1}};var ka={encode:ja,h:!1},la=/[\W_]+/;function ja(a){return L(this,a.toLowerCase(),!1,la)};var ma=0,na={},V={};function O(a){if(!(this instanceof O))return new O(a);var b=a&&a.id;this.id=b||0===b?b:ma++;this.init(a);oa(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});oa(this,"length",function(){return this.index.length})}O.registerCharset=function(a,b){V[a]=b;return O};O.registerLanguage=function(a,b){na[a]=b;return O};
O.prototype.init=function(a){var b,c;if(a)if(t(a))U[a]||console.warn("Preset not found: "+a),a=U[a];else if(b=a.preset)U[b]||console.warn("Preset not found: "+b),a=Object.assign({},U[b],a);a||(a={});if(b=a.worker){if("undefined"===typeof fa)a.worker=!1,this.m=null;else{var d=parseInt(b,10)||4;this.s=0;this.o=[];this.C=null;this.m=Array(d);for(var e=0;e<d;e++)this.m[e]=ia(this.id,e,a,this.G)}this.v=b}this.async=a.async;d=a.charset;e=a.lang;t(d)&&(-1===d.indexOf(":")&&(d+=":default"),d=V[d]);t(e)&&
(e=na[e]);this.D=b=d&&d.B||a.tokenize||"strict";this.depth="strict"===b&&a.depth||0;this.h=d&&d.h||a.rtl||!1;this.c=a.resolution||9;this.threshold=b=a.threshold||0;this.c<=b&&(this.c=b+1);this.encode=a.encode||d&&d.encode||ja;this.u=(b=a.matcher||e&&e.u)&&pa(b,!1);this.A=(b=a.stemmer||e&&e.A)&&pa(b,!0);if(d=b=a.filter||e&&e.filter){d=b;e=F();var f=0;for(c=d.length;f<c;f++)e[d[f]]=1;d=e}this.filter=d;(this.a=c=(b=a.doc)&&qa(b))&&(a.doc=null);this.j=ba(this.c-this.threshold);this.i=F();this.f=F();if(c){this.l=
F();d=c.index={};e=c.keys=[];f=c.field;var g=c.tag,h=c.store;y(c.id)||(c.id=c.id.split(":"));if(h){var k=F();if(t(h))k[h]=1;else if(y(h))for(var m=0;m<h.length;m++)k[h[m]]=1;else z(h)&&(k=h);c.store=k}if(g){this.w=F();h=F();if(f)if(t(f))h[f]=a;else if(y(f))for(k=0;k<f.length;k++)h[f[k]]=a;else z(f)&&(h=f);y(g)||(c.tag=g=[g]);for(f=0;f<g.length;f++)this.w[g[f]]=F();this.F=g;f=h}if(f){if(!y(f))if(z(f)){var q=f;c.field=f=Object.keys(f)}else c.field=f=[f];for(c=0;c<f.length;c++)g=f[c],y(g)||(q&&(a=q[g]),
e[c]=g,f[c]=g.split(":")),d[g]=new O(a)}}this.b=!0;this.g=(b=a.cache)&&new P(b);return this};function qa(a){var b=F(),c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];b[c]=y(d)?d.slice(0):z(d)?qa(d):d}return b}
O.prototype.add=function(a,b,c,d,e){if(this.a&&z(a))return W(this,"add",a,b);if(b&&t(b)&&(a||0===a)){if(this.f[a]&&!d)return this.update(a,b);if(!e){if(this.async&&"function"!==typeof importScripts){var f=this,g=new Promise(function(M){setTimeout(function(){f.add(a,b,null,d,!0);f=null;M()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=b;e=F();e._ctx=F();for(var h=c.length,k=this.threshold,m=this.depth,q=this.c,
r=this.j,p=this.h,l=0;l<h;l++){var n=c[l];if(n){g=1;var w=n.length,v=(p?l+1:h-l)/h,x="";switch(this.D){case "reverse":case "both":for(var u=w;--u;)x=n[u]+x,X(r,e,x,a,p?1:(w-u)/w,v,k,q-1);x="";case "forward":for(u=0;u<w;u++)x+=n[u],X(r,e,x,a,p?(u+1)/w:1,v,k,q-1);break;case "full":for(u=0;u<w;u++)for(var A=(p?u+1:w-u)/w,B=w;B>u;B--)x=n.substring(u,B),X(r,e,x,a,A,v,k,q-1);break;default:if(w=X(r,e,n,a,1,v,k,q-1),m&&1<h&&w>=k)for(w=e._ctx[n]||(e._ctx[n]=F()),n=this.i[n]||(this.i[n]=ba(q-(k||0))),v=l-m,
x=l+m+1,0>v&&(v=0),x>h&&(x=h);v<x;v++)v!==l&&X(n,w,c[v],a,0,q-(v<l?l-v:v-l),k,q-1)}}}g&&(this.f[a]=1);this.b=!1}return this};
function W(a,b,c,d){if(y(c)){var e=c.length;if(e)for(var f=0;f<e;f++)W(a,b,c[f],f===e-1&&d)}else{var g=a.a.index,h=a.a.keys,k=a.a.tag;f=a.a.store;var m;var q=a.a.id;e=c;for(var r=0;r<q.length;r++)e=e[q[r]];if("remove"===b){if(delete a.l[e],c=h.length)for(f=0;f<c;f++)g[h[f]].remove(e,f===c-1&&d)}else{if(k){for(m=0;m<k.length;m++){var p=k[m];var l=c;q=p.split(":");for(r=0;r<q.length;r++)l=l[q[r]];l="@"+l}m=a.w[p];m=m[l]||(m[l]=[])}q=a.a.field;k=0;for(p=q.length;k<p;k++){r=q[k];l=c;for(var n=0;n<r.length;n++)l=
l[r[n]];r=g[h[k]];"add"===b?r.add(e,l,k===p-1&&d):r.update(e,l,k===p-1&&d)}if(f){d=Object.keys(f);b=F();for(g=0;g<d.length;g++)if(h=d[g],f[h])for(h=h.split(":"),k=q=void 0,p=0;p<h.length;p++)l=h[p],q=(q||c)[l],k=(k||b)[l]=q;c=b}m&&(m[m.length]=c);a.l[e]=c}}return a}O.prototype.update=function(a,b,c){if(this.a&&z(a))return W(this,"update",a,b);this.f[a]&&t(b)&&(this.remove(a),this.add(a,b,c,!0));return this};
O.prototype.remove=function(a,b,c){if(this.a&&z(a))return W(this,"remove",a,b);if(this.f[a]){if(!c){if(this.async&&"function"!==typeof importScripts){var d=this;c=new Promise(function(e){setTimeout(function(){d.remove(a,null,!0);d=null;e()})});if(b)c.then(b);else return c;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.c-(this.threshold||0);b++)ra(this.j[b],a);this.depth&&ra(this.i,a);delete this.f[a];this.b=!1}return this};var Y;
function sa(a,b,c,d,e,f,g,h,k,m,q){d=ta(d,h?0:f,k,g,c,m,q);if(k){k=d.page;var r=d.next;d=d.result}if(h)d=a.where(h,null,f,d);else{c=d;d=a.l;f=c.length;g=Array(f);for(h=0;h<f;h++)g[h]=d[c[h]];d=g}e&&(aa(e)||(Y=e.split(":"),e=1<Y.length?ua:va),d.sort(e));d=Z(k,r,d);a.g&&a.g.set(b,d);return d}
O.prototype.search=function(a,b,c,d){if(z(b)){if(y(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&aa(b)?(c=b,b=1E3):b||0===b||(b=1E3);var f=[],g=a;if(z(a)&&!y(a)){c||(c=a.callback)&&(g.callback=null);var h=a.sort;var k=a.page;b=a.limit;var m=a.threshold;var q=a.suggest;a=a.query}if(this.a){m=this.a.index;var r=g.where,p=g.bool||"or",l=g.field,n=p,w,v;if(l)y(l)||(l=[l]);else if(y(g)){var x=g;l=[];n=[];for(var u=0;u<g.length;u++)d=g[u],e=d.bool||p,l[u]=d.field,n[u]=e,"not"===
e?w=!0:"and"===e&&(v=!0)}else l=this.a.keys;p=l.length;for(u=0;u<p;u++)x&&(g=x[u]),k&&!t(g)&&(g.page=null,g.limit=0),f[u]=m[l[u]].search(g,0);if(c)return c(sa(this,a,n,f,h,b,q,r,k,v,w));if(this.async){var A=this;return new Promise(function(da){Promise.all(f).then(function(za){da(sa(A,a,n,za,h,b,q,r,k,v,w))})})}return sa(this,a,n,f,h,b,q,r,k,v,w)}m||(m=this.threshold||0);if(!d){if(this.async&&"function"!==typeof importScripts){var B=this;m=new Promise(function(da){setTimeout(function(){da(B.search(g,
b,null,!0));B=null})});if(c)m.then(c);else return m;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!t(a))return f;g=a;if(this.g)if(this.b){if(c=this.g.get(a))return c}else this.g.clear(),this.b=!0;g=this.encode(g);if(!g.length)return f;c=g;x=c.length;d=!0;e=[];var M=F(),Q=0;1<x&&(this.depth?p=!0:c.sort(wa));if(!p||(u=this.i))for(var T=this.c;Q<x;Q++){var C=c[Q];if(C){if(p){if(!l)if(u[C])l=C,M[C]=1;else if(!q)return f;if(q&&Q===x-1&&!e.length)p=!1,C=l||C,M[C]=0;else if(!l)continue}if(!M[C]){var D=
[],N=!1,H=0,I=p?u[l]:this.j;if(I)for(var R=void 0,J=0;J<T-m;J++)if(R=I[J]&&I[J][C])D[H++]=R,N=!0;if(N)l=C,e[e.length]=1<H?D.concat.apply([],D):D[0];else if(!q){d=!1;break}M[C]=1}}}else d=!1;d&&(f=ta(e,b,k,q));this.g&&this.g.set(a,f);return f};O.prototype.info=function(){return{id:this.id,items:this.length,matcher:this.u.length,worker:this.v,threshold:this.threshold,depth:this.depth,resolution:this.c,contextual:this.depth&&"strict"===this.D}};O.prototype.clear=function(){return this.destroy().init()};
O.prototype.destroy=function(){this.g&&(this.g.clear(),this.g=null);this.j=this.i=this.f=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.l=null}return this};function oa(a,b,c){Object.defineProperty(a,b,{get:c})}function X(a,b,c,d,e,f,g,h){if(b[c])return b[c];e=e?(h-(g||h/1.5))*f+(g||h/1.5)*e:f;b[c]=e;e>=g&&(a=a[h-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}
function ra(a,b){if(a)for(var c=Object.keys(a),d=0,e=c.length;d<e;d++){var f=c[d],g=a[f];if(g)for(var h=0,k=g.length;h<k;h++)if(g[h]===b){1===k?delete a[f]:g.splice(h,1);break}else z(g[h])&&ra(g[h],b)}}function pa(a,b){for(var c=Object.keys(a),d=c.length,e=[],f="",g=0,h=0,k;h<d;h++){var m=c[h];(k=a[m])?(e[g++]=K(b?"(?!\\b)"+m+"(\\b|_)":m),e[g++]=k):f+=(f?"|":"")+m}f&&(e[g++]=K(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function wa(a,b){return b.length-a.length}
function va(a,b){a=a[Y];b=b[Y];return a<b?-1:a>b?1:0}function ua(a,b){for(var c=Y.length,d=0;d<c;d++)a=a[Y[d]],b=b[Y[d]];return a<b?-1:a>b?1:0}function Z(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}
function ta(a,b,c,d,e,f,g){var h=[];if(!0===c){c="0";var k=""}else k=c&&c.split(":");var m=a.length;if(1<m){var q=F(),r=[],p,l=0,n,w=!0,v=0,x;if(k)if(2===k.length){var u=k;k=!1}else k=x=parseInt(k[0],10);if(g){for(p=F();l<m;l++)if("not"===e[l]){var A=a[l];var B=A.length;for(n=0;n<B;n++)p["@"+A[n]]=1}else var M=l+1;if(E(M))return Z(c,J,h);l=0}else var Q=t(e)&&e;for(var T;l<m;l++){var C=l===(M||m)-1;if(!Q||!l)if((n=Q||e&&e[l])&&"and"!==n)if("or"===n)T=!1;else continue;else T=f=!0;A=a[l];if(B=A.length){if(w)if(H){var D=
H.length;for(n=0;n<D;n++){w=H[n];var N="@"+w;g&&p[N]||(q[N]=1,f||(h[v++]=w))}var H=null;w=!1}else{H=A;continue}N=!1;for(n=0;n<B;n++){D=A[n];var I="@"+D,R=f?q[I]||0:l;if(!(!R&&!d||g&&p[I]||!f&&q[I]))if(R===l){if(C){if(!x||--x<v)if(h[v++]=D,b&&v===b)return Z(c,v+(k||0),h)}else q[I]=l+1;N=!0}else d&&(I=r[R]||(r[R]=[]),I[I.length]=D)}if(T&&!N&&!d)break}else if(T&&!d)return Z(c,J,A)}if(H)if(l=H.length,g)for(n=k?parseInt(k,10):0;n<l;n++)a=H[n],p["@"+a]||(h[v++]=a);else h=H;if(d)for(v=h.length,u?(l=parseInt(u[0],
10)+1,n=parseInt(u[1],10)+1):(l=r.length,n=0);l--;)if(D=r[l]){for(B=D.length;n<B;n++)if(d=D[n],!g||!p["@"+d])if(h[v++]=d,b&&v===b)return Z(c,l+":"+n,h);n=0}}else!m||e&&"not"===e[0]||(h=a[0],k&&(k=parseInt(k[0],10)));if(b){g=h.length;k&&k>g&&(k=0);k=k||0;var J=k+b;J<g?h=h.slice(k,J):(J=0,k&&(h=h.slice(k)))}return Z(c,J,h)};var ya={encode:xa,h:!1},Aa=/[\W_]+/,Ba=[K("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",K("[\u00e8\u00e9\u00ea\u00eb]"),"e",K("[\u00ec\u00ed\u00ee\u00ef]"),"i",K("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",K("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",K("[\u00fd\u0177\u00ff]"),"y",K("\u00f1"),"n",K("[\u00e7c]"),"k",K("\u00df"),"s",K(" & ")," and "];function xa(a,b){return L(b||this,a.toLowerCase(),Ba,Aa)};var Ca=[K("ae"),"a",K("ai"),"ei",K("ay"),"ei",K("ey"),"ei",K("oe"),"o",K("ue"),"u",K("ie"),"i",K("sz"),"s",K("zs"),"s",K("sh"),"s",K("ck"),"k",K("cc"),"k",K("th"),"t",K("dt"),"t",K("ph"),"f",K("pf"),"f",K("ou"),"o",K("uo"),"u"];function Da(a,b,c){a&&(a=xa(a,b||this).join(" "),2<a.length&&(a=G(a,Ca)),c||(1<a.length&&(a=ca(a)),a&&(a=a.split(" "))));return a};var Fa={encode:Ea,h:!1},Ga=/[\W_]+/;function Ea(a){return L(this,a.toLowerCase(),!1,Ga)};var Ia={encode:Ha,h:!1},Ja=[K("(?!\\b)p"),"b",K("(?!\\b)z"),"s",K("(?!\\b)[cgq]"),"k",K("(?!\\b)n"),"m",K("(?!\\b)d"),"t",K("(?!\\b)[vw]"),"f",K("(?!\\b)[aeiouy]"),""];function Ha(a){a&&(a=Da(a,this,!0),1<a.length&&(a=G(a,Ja)),1<a.length&&(a=ca(a)),a&&(a=a.split(" ")));return a};var La={encode:Ka,h:!1,B:"strict"},Ma=/[^a-z]+/;function Ka(a){a=L(this,a.toLowerCase(),!1,!1);var b=[];if(a)for(var c=a.split(Ma),d=c.length,e=0,f=0;e<d;e++)if((a=c[e])&&2<a.length&&(!this.filter||!this.filter[a])){for(var g=a[0],h=Na(g),k=1;k<a.length;k++){var m=Na(a[k]);if(m!==h&&(g+=m,h=m,4===g.length))break}b[f++]=(g+"0000").substring(0,4)}return b}
function Na(a){switch(a){case "b":case "f":case "p":case "v":return 1;case "c":case "g":case "j":case "k":case "q":case "s":case "x":case "z":return 2;case "d":case "t":return 3;case "l":return 4;case "m":case "n":return 5;case "r":return 6}return""};var Pa={encode:Oa,h:!0},Qa=/[\x00-\x7F]+/g;function Oa(a){return L(this,a.replace(Qa," "),!1," ")};var Sa={encode:Ra,h:!1,B:"strict"},Ta=/[\x00-\x7F]+/g;function Ra(a){return L(this,a.replace(Ta,""),!1,"")};var Va={encode:Ua,h:!1},Wa=/[\x00-\x7F]+/g;function Ua(a){return L(this,a.replace(Wa," "),!1," ")};V["latin:advanced"]={encode:Da,h:!1};V["latin:balance"]=Fa;V["latin:default"]=ka;V["latin:extra"]=Ia;V["latin:simple"]=ya;V["latin:soundex"]=La;V["arabic:default"]=Pa;V["cjk:default"]=Sa;V["cyrillic:default"]=Va;(function(){var a=this||window,b;(b=a.define)&&b.amd?b([],function(){return O}):"object"===typeof a.exports?a.module.exports=O:a.FlexSearch=O})();}).call(this);

View File

@@ -1,18 +0,0 @@
/**!
* FlexSearch.js v0.7.0 (Light)
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(){'use strict';var u;Object.assign||(Object.assign=function(){for(var a=arguments,b=a.length,c=a[0],e=1,d,h,g;e<b;e++){d=a[e];h=Object.keys(d);g=h.length;for(var f=0,m;f<g;f++)m=h[f],c[m]=d[m]}return c});function v(a){return"string"===typeof a}function y(a){for(var b=Array(a),c=0;c<a;c++)b[c]=B();return b}function B(){return Object.create(null)}function C(a,b){for(var c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a};var F=/[\W_]+/;function G(a){if(a=a.toLowerCase())if(a&&this.g&&(a=C(a,this.g)),this.h&&1<a.length&&(a=C(a,this.h)),a&&(F||""===F)&&(a=a.split(F),this.filter)){for(var b=this.filter,c=a.length,e=[],d=0,h=0;d<c;d++){var g=a[d];g&&!b[g]&&(e[h++]=g)}a=e}return a};var H=0,I={},J={};function K(a){if(!(this instanceof K))return new K(a);var b=a&&a.id;this.id=b||0===b?b:H++;this.init(a);L(this,"index",function(){return Object.keys(this.a)});L(this,"length",function(){return this.index.length})}K.registerCharset=function(a,b){J[a]=b;return K};K.registerLanguage=function(a,b){I[a]=b;return K};u=K.prototype;
u.init=function(a){var b;a||(a={});var c=a.charset,e=a.lang;v(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=J[c]);v(e)&&(e=I[e]);this.j=b=c&&c.l||a.tokenize||"strict";this.depth="strict"===b&&a.depth||0;this.i=c&&c.i||a.rtl||!1;this.b=a.resolution||9;this.threshold=b=a.threshold||0;this.b<=b&&(this.b=b+1);this.encode=a.encode||c&&c.encode||G;this.g=(b=a.matcher||e&&e.g)&&M(b,!1);this.h=(b=a.stemmer||e&&e.h)&&M(b,!0);if(a=b=a.filter||e&&e.filter)for(a=B(),c=0,e=b.length;c<e;c++)a[b[c]]=1;this.filter=
a;this.f=y(this.b-this.threshold);this.c=B();this.a=B();return this};
u.add=function(a,b,c,e,d){if(b&&v(b)&&(a||0===a)){if(this.a[a]&&!e)return this.update(a,b);if(!d&&c)return this.add(a,b,null,e,!0),c(),this;b=this.encode(b);if(!b.length)return this;c=B();c._ctx=B();e=b.length;d=this.threshold;for(var h=this.depth,g=this.b,f=this.f,m=this.i,t,q=0;q<e;q++){var n=b[q];if(n){t=1;var p=n.length,r=(m?q+1:e-q)/e,l="";switch(this.j){case "reverse":case "both":for(var k=p;--k;)l=n[k]+l,N(f,c,l,a,m?1:(p-k)/p,r,d,g-1);l="";case "forward":for(k=0;k<p;k++)l+=n[k],N(f,c,l,a,m?
(k+1)/p:1,r,d,g-1);break;case "full":for(k=0;k<p;k++)for(var w=(m?k+1:p-k)/p,z=p;z>k;z--)l=n.substring(k,z),N(f,c,l,a,w,r,d,g-1);break;default:if(p=N(f,c,n,a,1,r,d,g-1),h&&1<e&&p>=d)for(p=c._ctx[n]||(c._ctx[n]=B()),n=this.c[n]||(this.c[n]=y(g-(d||0))),r=q-h,l=q+h+1,0>r&&(r=0),l>e&&(l=e);r<l;r++)r!==q&&N(n,p,b[r],a,0,g-(r<q?q-r:r-q),d,g-1)}}}t&&(this.a[a]=1)}return this};u.update=function(a,b,c){this.a[a]&&v(b)&&(this.remove(a),this.add(a,b,c,!0));return this};
u.remove=function(a,b,c){if(this.a[a]){if(!c&&b)return this.remove(a,null,!0),b(),this;for(b=0;b<this.b-(this.threshold||0);b++)Q(this.f[b],a);this.depth&&Q(this.c,a);delete this.a[a]}return this};
u.search=function(a,b,c,e){b&&"function"===typeof b?(c=b,b=1E3):b||0===b||(b=1E3);var d=[],h=a;if("object"===typeof a){var g=!1;b=a.limit;var f=a.threshold;var m=!1;a=a.query}f||(f=this.threshold||0);if(!e&&c)return c(this.search(h,b,null,!0)),this;if(!a||!v(a))return d;h=this.encode(a);if(!h.length)return d;c=h;e=c.length;h=!0;a=[];var t=B(),q,n=0;1<e&&(this.depth?q=!0:c.sort(R));var p;if(!q||(p=this.c))for(var r=this.b;n<e;n++){var l=c[n];if(l){if(q){if(!k)if(p[l]){var k=l;t[l]=1}else if(!m)return d;
if(m&&n===e-1&&!a.length)q=!1,l=k||l,t[l]=0;else if(!k)continue}if(!t[l]){var w=[],z=!1,O=0;if(k=q?p[k]:this.f)for(var P,E=0;E<r-f;E++)if(P=k[E]&&k[E][l])w[O++]=P,z=!0;if(z)k=l,a[a.length]=1<O?w.concat.apply([],w):w[0];else{h=!1;break}t[l]=1}}}else h=!1;if(h)a:{d=[];!0===g?(g="0",f=""):f=g&&g.split(":");m=a.length;if(1<m){q=B();k=0;r=!0;h=0;var A;for(f&&(2===f.length?f=!1:f=A=parseInt(f[0],10));k<m;k++)if(t=k===m-1,p=a[k],e=p.length){if(r)if(x){n=x.length;for(c=0;c<n;c++)q["@"+x[c]]=1;var x=null;
r=!1}else{x=p;continue}l=!1;for(c=0;c<e;c++)if(n=p[c],w="@"+n,(z=q[w]||0)&&z===k){if(t){if(!A||--A<h)if(d[h++]=n,b&&h===b){d=S(g,h+(f||0),d);break a}}else q[w]=k+1;l=!0}if(!l)break}else{d=S(g,D,p);break a}x&&(d=x)}else m&&(d=a[0],f&&(f=parseInt(f[0],10)));if(b){x=d.length;f&&f>x&&(f=0);A=f||0;var D=A+b;D<x?d=d.slice(A,D):(D=0,A&&(d=d.slice(A)))}d=S(g,D,d)}return d};u.clear=function(){return this.destroy().init()};u.destroy=function(){this.f=this.c=this.a=null;return this};
function L(a,b,c){Object.defineProperty(a,b,{get:c})}function N(a,b,c,e,d,h,g,f){if(b[c])return b[c];d=d?(f-(g||f/1.5))*h+(g||f/1.5)*d:h;b[c]=d;d>=g&&(a=a[f-(d+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=e);return d}function Q(a,b){if(a)for(var c=Object.keys(a),e=0,d=c.length;e<d;e++){var h=c[e],g=a[h];if(g)for(var f=0,m=g.length;f<m;f++)if(g[f]===b){1===m?delete a[h]:g.splice(f,1);break}else"object"===typeof g[f]&&Q(g[f],b)}}
function M(a,b){for(var c=Object.keys(a),e=c.length,d=[],h="",g=0,f=0,m;f<e;f++){var t=c[f];(m=a[t])?(d[g++]=new RegExp(b?"(?!\\b)"+t+"(\\b|_)":t,"g"),d[g++]=m):h+=(h?"|":"")+t}h&&(d[g++]=new RegExp(b?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),d[g]="");return d}function R(a,b){return b.length-a.length}function S(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c};(function(){var a=this||window,b;(b=a.define)&&b.amd?b([],function(){return K}):"object"===typeof a.exports?a.module.exports=K:a.FlexSearch=K})();}).call(this);

View File

@@ -5,33 +5,21 @@
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(){'use strict';Object.assign||(Object.assign=function(){for(var a=arguments,b=a.length,c=a[0],d=1,e,f,g;d<b;d++){e=a[d];f=Object.keys(e);g=f.length;for(var h=0,k;h<g;h++)k=f[h],c[k]=e[k]}return c});window.requestAnimationFrame||(window.requestAnimationFrame=window.setTimeout);window.cancelAnimationFrame||(window.cancelAnimationFrame=window.clearTimeout);window.Promise||(window.Promise=function(){function a(b){this.b=null;var c=this;b(function(d){c.b&&(c.b(d),c.b=null)})}a.prototype.then=function(b){this.b=b};return a}());function t(a){return"string"===typeof a}function y(a){return a.constructor===Array}function z(a){return"function"===typeof a}function E(a){return"object"===typeof a}function F(a){return"undefined"===typeof a}function aa(a){for(var b=Array(a),c=0;c<a;c++)b[c]=G();return b}function G(){return Object.create(null)}function K(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function L(a){return new RegExp(a,"g")}
function ba(a){for(var b="",c="",d=0,e=a.length,f=void 0;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b}function O(a,b,c,d){if(b&&(c&&b&&(b=K(b,c)),b&&a.u&&(b=K(b,a.u)),a.A&&1<b.length&&(b=K(b,a.A)),b&&(d||""===d)&&(b=b.split(d),a.filter))){a=a.filter;c=b.length;d=[];for(var e=0,f=0;e<c;e++){var g=b[e];g&&!a[g]&&(d[f++]=g)}b=d}return b};P.prototype.export=function(a){var b=!a||F(a.serialize)||a.serialize;if(this.a){var c=!a||F(a.doc)||a.doc,d=!a||F(a.index)||a.index;a=[];var e=0;if(d)for(d=this.a.keys;e<d.length;e++){var f=this.a.index[d[e]];a[e]=[f.j,f.i,Object.keys(f.f)]}c&&(a[e]=this.l)}else a=[this.j,this.i,Object.keys(this.f)];b&&(a=JSON.stringify(a));return a};
P.prototype.import=function(a,b){if(!b||F(b.serialize)||b.serialize)a=JSON.parse(a);var c={};if(this.a){var d=!b||F(b.doc)||b.doc,e=0;if(!b||F(b.index)||b.index){b=this.a.keys;for(var f=b.length,g=a[0][2];e<g.length;e++)c[g[e]]=1;for(e=0;e<f;e++){g=this.a.index[b[e]];var h=a[e];h&&(g.j=h[0],g.i=h[1],g.f=c)}}d&&(this.l=E(d)?d:a[e])}else{d=a[2];for(e=0;e<d.length;e++)c[d[e]]=1;this.j=a[0];this.i=a[1];this.f=c}};P.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};
P.prototype.where=function(a,b,c,d){var e=this.l,f=[],g=0,h;if(E(a)){c||(c=b);var k=Object.keys(a);var m=k.length;var q=!1;if(1===m&&"id"===k[0])return[e[a.id]];if((h=this.F)&&!d)for(var r=0;r<h.length;r++){var p=h[r],l=a[p];if(!F(l)){var n=this.w[p]["@"+l];if(0===--m)return n;k.splice(k.indexOf(p),1);delete a[p];break}}h=Array(m);for(r=0;r<m;r++)h[r]=k[r].split(":")}else{if(z(a)){b=d||Object.keys(e);c=b.length;for(k=0;k<c;k++)m=e[b[k]],a(m)&&(f[g++]=m);return f}if(F(b))return[e[a]];if("id"===a)return[e[b]];
k=[a];m=1;h=[a.split(":")];q=!0}d=n||d||Object.keys(e);r=d.length;for(p=0;p<r;p++){l=n?d[p]:e[d[p]];for(var w=!0,v=0;v<m;v++){q||(b=a[k[v]]);var x=h[v],u=x.length,A=l;if(1<u)for(var B=0;B<u;B++)A=A[x[B]];else A=A[x[0]];if(A!==b){w=!1;break}}if(w&&(f[g++]=l,c&&g===c))break}return f};function S(a){this.clear();this.m=!0!==a&&a}S.prototype.clear=function(){this.cache=G();this.count=G();this.index=G();this.b=[]};S.prototype.set=function(a,b){if(this.m&&F(this.cache[a])){var c=this.b.length;if(c===this.m){c--;var d=this.b[c];delete this.cache[d];delete this.count[d];delete this.index[d]}this.b[c]=a;this.index[a]=c;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};
S.prototype.get=function(a){var b=this.cache[a];if(this.m&&b){var c=++this.count[a],d=this.index,e=d[a];if(0<e){for(var f=this.b,g=e;this.count[f[--e]]<=c&&-1!==e;);e++;if(e!==g){for(c=g;c>e;c--)g=f[c-1],f[c]=g,d[g]=c;f[e]=a;d[a]=e}}}return b};var U={},da="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;function ea(a,b,c){var d=fa,e="flexsearch";d=da?URL.createObjectURL(new Blob(["("+d.toString()+")()"],{type:"text/javascript"})):e+".browser.js";e+="-"+a;U[e]||(U[e]=[]);U[e][c]=new Worker(d);U[e][c].onmessage=b;return U[e][c]}
function fa(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+
1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ha(a,b,c,d){a=ea("id"+a,function(f){(f=f.data)&&f.result&&d(f.id,f.content,f.result,f.limit,f.where,f.cursor,f.suggest)},b);var e=P.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}P.prototype.G=function(a,b,c,d){this.s!==this.v&&(this.o=this.o.concat(c),this.s++,d&&this.o.length>=d&&(this.s=this.v),this.s===this.v&&(this.cache&&this.g.set(b,this.o),this.C&&this.C(this.o)));return this};var ia={memory:{charset:"latin:extra",threshold:0,c:1},speed:{threshold:1,c:3,depth:2},match:{charset:"latin:extra",B:"full",threshold:1,c:3},score:{charset:"latin:extra",threshold:1,c:9,depth:4},balance:{charset:"latin:balance",threshold:0,c:3,depth:3},fast:{threshold:8,c:9,depth:1}};var ka={encode:ja,h:!1},la=/[\W_]+/;function ja(a){return O(this,a.toLowerCase(),!1,la)};var ma=0,na={},V={};function P(a){if(!(this instanceof P))return new P(a);var b=a&&a.id;this.id=b||0===b?b:ma++;this.init(a);oa(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});oa(this,"length",function(){return this.index.length})}P.registerCharset=function(a,b){V[a]=b;return P};P.registerLanguage=function(a,b){na[a]=b;return P};
P.prototype.init=function(a){var b,c;if(a)if(t(a))a=ia[a];else if(b=a.preset)a=Object.assign({},ia[b],a);a||(a={});if(b=a.worker){if("undefined"===typeof ea)a.worker=!1,this.m=null;else{var d=parseInt(b,10)||4;this.s=0;this.o=[];this.C=null;this.m=Array(d);for(var e=0;e<d;e++)this.m[e]=ha(this.id,e,a,this.G)}this.v=b}this.async=a.async;d=a.charset;e=a.lang;t(d)&&(-1===d.indexOf(":")&&(d+=":default"),d=V[d]);t(e)&&(e=na[e]);this.D=b=d&&d.B||a.tokenize||"strict";this.depth="strict"===b&&a.depth||0;
this.h=d&&d.h||a.rtl||!1;this.c=a.resolution||9;this.threshold=b=a.threshold||0;this.c<=b&&(this.c=b+1);this.encode=a.encode||d&&d.encode||ja;this.u=(b=a.matcher||e&&e.u)&&pa(b,!1);this.A=(b=a.stemmer||e&&e.A)&&pa(b,!0);if(d=b=a.filter||e&&e.filter){d=b;e=G();var f=0;for(c=d.length;f<c;f++)e[d[f]]=1;d=e}this.filter=d;(this.a=c=(b=a.doc)&&qa(b))&&(a.doc=null);this.j=aa(this.c-this.threshold);this.i=G();this.f=G();if(c){this.l=G();d=c.index={};e=c.keys=[];f=c.field;var g=c.tag,h=c.store;y(c.id)||(c.id=
c.id.split(":"));if(h){var k=G();if(t(h))k[h]=1;else if(y(h))for(var m=0;m<h.length;m++)k[h[m]]=1;else E(h)&&(k=h);c.store=k}if(g){this.w=G();h=G();if(f)if(t(f))h[f]=a;else if(y(f))for(k=0;k<f.length;k++)h[f[k]]=a;else E(f)&&(h=f);y(g)||(c.tag=g=[g]);for(f=0;f<g.length;f++)this.w[g[f]]=G();this.F=g;f=h}if(f){if(!y(f))if(E(f)){var q=f;c.field=f=Object.keys(f)}else c.field=f=[f];for(c=0;c<f.length;c++)g=f[c],y(g)||(q&&(a=q[g]),e[c]=g,f[c]=g.split(":")),d[g]=new P(a)}}this.b=!0;this.g=(b=a.cache)&&new S(b);
return this};function qa(a){var b=G(),c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];b[c]=y(d)?d.slice(0):E(d)?qa(d):d}return b}
P.prototype.add=function(a,b,c,d,e){if(this.a&&E(a))return W(this,"add",a,b);if(b&&t(b)&&(a||0===a)){if(this.f[a]&&!d)return this.update(a,b);if(!e){if(this.async&&"function"!==typeof importScripts){var f=this,g=new Promise(function(M){setTimeout(function(){f.add(a,b,null,d,!0);f=null;M()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=b;e=G();e._ctx=G();for(var h=c.length,k=this.threshold,m=this.depth,q=this.c,
r=this.j,p=this.h,l=0;l<h;l++){var n=c[l];if(n){g=1;var w=n.length,v=(p?l+1:h-l)/h,x="";switch(this.D){case "reverse":case "both":for(var u=w;--u;)x=n[u]+x,X(r,e,x,a,p?1:(w-u)/w,v,k,q-1);x="";case "forward":for(u=0;u<w;u++)x+=n[u],X(r,e,x,a,p?(u+1)/w:1,v,k,q-1);break;case "full":for(u=0;u<w;u++)for(var A=(p?u+1:w-u)/w,B=w;B>u;B--)x=n.substring(u,B),X(r,e,x,a,A,v,k,q-1);break;default:if(w=X(r,e,n,a,1,v,k,q-1),m&&1<h&&w>=k)for(w=e._ctx[n]||(e._ctx[n]=G()),n=this.i[n]||(this.i[n]=aa(q-(k||0))),v=l-m,
x=l+m+1,0>v&&(v=0),x>h&&(x=h);v<x;v++)v!==l&&X(n,w,c[v],a,0,q-(v<l?l-v:v-l),k,q-1)}}}g&&(this.f[a]=1);this.b=!1}return this};
function W(a,b,c,d){if(y(c)){var e=c.length;if(e)for(var f=0;f<e;f++)W(a,b,c[f],f===e-1&&d)}else{var g=a.a.index,h=a.a.keys,k=a.a.tag;f=a.a.store;var m;var q=a.a.id;e=c;for(var r=0;r<q.length;r++)e=e[q[r]];if("remove"===b){if(delete a.l[e],c=h.length)for(f=0;f<c;f++)g[h[f]].remove(e,f===c-1&&d)}else{if(k){for(m=0;m<k.length;m++){var p=k[m];var l=c;q=p.split(":");for(r=0;r<q.length;r++)l=l[q[r]];l="@"+l}m=a.w[p];m=m[l]||(m[l]=[])}q=a.a.field;k=0;for(p=q.length;k<p;k++){r=q[k];l=c;for(var n=0;n<r.length;n++)l=
l[r[n]];r=g[h[k]];"add"===b?r.add(e,l,k===p-1&&d):r.update(e,l,k===p-1&&d)}if(f){d=Object.keys(f);b=G();for(g=0;g<d.length;g++)if(h=d[g],f[h])for(h=h.split(":"),k=q=void 0,p=0;p<h.length;p++)l=h[p],q=(q||c)[l],k=(k||b)[l]=q;c=b}m&&(m[m.length]=c);a.l[e]=c}}return a}P.prototype.update=function(a,b,c){if(this.a&&E(a))return W(this,"update",a,b);this.f[a]&&t(b)&&(this.remove(a),this.add(a,b,c,!0));return this};
P.prototype.remove=function(a,b,c){if(this.a&&E(a))return W(this,"remove",a,b);if(this.f[a]){if(!c){if(this.async&&"function"!==typeof importScripts){var d=this;c=new Promise(function(e){setTimeout(function(){d.remove(a,null,!0);d=null;e()})});if(b)c.then(b);else return c;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.c-(this.threshold||0);b++)ra(this.j[b],a);this.depth&&ra(this.i,a);delete this.f[a];this.b=!1}return this};var Y;
function sa(a,b,c,d,e,f,g,h,k,m,q){d=ta(d,h?0:f,k,g,c,m,q);if(k){k=d.page;var r=d.next;d=d.result}if(h)d=a.where(h,null,f,d);else{c=d;d=a.l;f=c.length;g=Array(f);for(h=0;h<f;h++)g[h]=d[c[h]];d=g}e&&(z(e)||(Y=e.split(":"),e=1<Y.length?ua:va),d.sort(e));d=Z(k,r,d);a.g&&a.g.set(b,d);return d}
P.prototype.search=function(a,b,c,d){if(E(b)){if(y(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&z(b)?(c=b,b=1E3):b||0===b||(b=1E3);var f=[],g=a;if(E(a)&&!y(a)){c||(c=a.callback)&&(g.callback=null);var h=a.sort;var k=a.page;b=a.limit;var m=a.threshold;var q=a.suggest;a=a.query}if(this.a){m=this.a.index;var r=g.where,p=g.bool||"or",l=g.field,n=p,w,v;if(l)y(l)||(l=[l]);else if(y(g)){var x=g;l=[];n=[];for(var u=0;u<g.length;u++)d=g[u],e=d.bool||p,l[u]=d.field,n[u]=e,"not"===
e?w=!0:"and"===e&&(v=!0)}else l=this.a.keys;p=l.length;for(u=0;u<p;u++)x&&(g=x[u]),k&&!t(g)&&(g.page=null,g.limit=0),f[u]=m[l[u]].search(g,0);if(c)return c(sa(this,a,n,f,h,b,q,r,k,v,w));if(this.async){var A=this;return new Promise(function(ca){Promise.all(f).then(function(za){ca(sa(A,a,n,za,h,b,q,r,k,v,w))})})}return sa(this,a,n,f,h,b,q,r,k,v,w)}m||(m=this.threshold||0);if(!d){if(this.async&&"function"!==typeof importScripts){var B=this;m=new Promise(function(ca){setTimeout(function(){ca(B.search(g,
b,null,!0));B=null})});if(c)m.then(c);else return m;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!t(a))return f;g=a;if(this.g)if(this.b){if(c=this.g.get(a))return c}else this.g.clear(),this.b=!0;g=this.encode(g);if(!g.length)return f;c=g;x=c.length;d=!0;e=[];var M=G(),Q=0;1<x&&(this.depth?p=!0:c.sort(wa));if(!p||(u=this.i))for(var T=this.c;Q<x;Q++){var C=c[Q];if(C){if(p){if(!l)if(u[C])l=C,M[C]=1;else if(!q)return f;if(q&&Q===x-1&&!e.length)p=!1,C=l||C,M[C]=0;else if(!l)continue}if(!M[C]){var D=
[],N=!1,H=0,I=p?u[l]:this.j;if(I)for(var R=void 0,J=0;J<T-m;J++)if(R=I[J]&&I[J][C])D[H++]=R,N=!0;if(N)l=C,e[e.length]=1<H?D.concat.apply([],D):D[0];else if(!q){d=!1;break}M[C]=1}}}else d=!1;d&&(f=ta(e,b,k,q));this.g&&this.g.set(a,f);return f};P.prototype.info=function(){return{id:this.id,items:this.length,matcher:this.u.length,worker:this.v,threshold:this.threshold,depth:this.depth,resolution:this.c,contextual:this.depth&&"strict"===this.D}};P.prototype.clear=function(){return this.destroy().init()};
P.prototype.destroy=function(){this.g&&(this.g.clear(),this.g=null);this.j=this.i=this.f=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.l=null}return this};function oa(a,b,c){Object.defineProperty(a,b,{get:c})}function X(a,b,c,d,e,f,g,h){if(b[c])return b[c];e=e?(h-(g||h/1.5))*f+(g||h/1.5)*e:f;b[c]=e;e>=g&&(a=a[h-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}
function ra(a,b){if(a)for(var c=Object.keys(a),d=0,e=c.length;d<e;d++){var f=c[d],g=a[f];if(g)for(var h=0,k=g.length;h<k;h++)if(g[h]===b){1===k?delete a[f]:g.splice(h,1);break}else E(g[h])&&ra(g[h],b)}}function pa(a,b){for(var c=Object.keys(a),d=c.length,e=[],f="",g=0,h=0,k;h<d;h++){var m=c[h];(k=a[m])?(e[g++]=L(b?"(?!\\b)"+m+"(\\b|_)":m),e[g++]=k):f+=(f?"|":"")+m}f&&(e[g++]=L(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function wa(a,b){return b.length-a.length}
function va(a,b){a=a[Y];b=b[Y];return a<b?-1:a>b?1:0}function ua(a,b){for(var c=Y.length,d=0;d<c;d++)a=a[Y[d]],b=b[Y[d]];return a<b?-1:a>b?1:0}function Z(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}
function ta(a,b,c,d,e,f,g){var h=[];if(!0===c){c="0";var k=""}else k=c&&c.split(":");var m=a.length;if(1<m){var q=G(),r=[],p,l=0,n,w=!0,v=0,x;if(k)if(2===k.length){var u=k;k=!1}else k=x=parseInt(k[0],10);if(g){for(p=G();l<m;l++)if("not"===e[l]){var A=a[l];var B=A.length;for(n=0;n<B;n++)p["@"+A[n]]=1}else var M=l+1;if(F(M))return Z(c,J,h);l=0}else var Q=t(e)&&e;for(var T;l<m;l++){var C=l===(M||m)-1;if(!Q||!l)if((n=Q||e&&e[l])&&"and"!==n)if("or"===n)T=!1;else continue;else T=f=!0;A=a[l];if(B=A.length){if(w)if(H){var D=
H.length;for(n=0;n<D;n++){w=H[n];var N="@"+w;g&&p[N]||(q[N]=1,f||(h[v++]=w))}var H=null;w=!1}else{H=A;continue}N=!1;for(n=0;n<B;n++){D=A[n];var I="@"+D,R=f?q[I]||0:l;if(!(!R&&!d||g&&p[I]||!f&&q[I]))if(R===l){if(C){if(!x||--x<v)if(h[v++]=D,b&&v===b)return Z(c,v+(k||0),h)}else q[I]=l+1;N=!0}else d&&(I=r[R]||(r[R]=[]),I[I.length]=D)}if(T&&!N&&!d)break}else if(T&&!d)return Z(c,J,A)}if(H)if(l=H.length,g)for(n=k?parseInt(k,10):0;n<l;n++)a=H[n],p["@"+a]||(h[v++]=a);else h=H;if(d)for(v=h.length,u?(l=parseInt(u[0],
10)+1,n=parseInt(u[1],10)+1):(l=r.length,n=0);l--;)if(D=r[l]){for(B=D.length;n<B;n++)if(d=D[n],!g||!p["@"+d])if(h[v++]=d,b&&v===b)return Z(c,l+":"+n,h);n=0}}else!m||e&&"not"===e[0]||(h=a[0],k&&(k=parseInt(k[0],10)));if(b){g=h.length;k&&k>g&&(k=0);k=k||0;var J=k+b;J<g?h=h.slice(k,J):(J=0,k&&(h=h.slice(k)))}return Z(c,J,h)};var ya={encode:xa,h:!1},Aa=/[\W_]+/,Ba=[L("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",L("[\u00e8\u00e9\u00ea\u00eb]"),"e",L("[\u00ec\u00ed\u00ee\u00ef]"),"i",L("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",L("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",L("[\u00fd\u0177\u00ff]"),"y",L("\u00f1"),"n",L("[\u00e7c]"),"k",L("\u00df"),"s",L(" & ")," and "];function xa(a,b){return O(b||this,a.toLowerCase(),Ba,Aa)};var Ca=[L("ae"),"a",L("ai"),"ei",L("ay"),"ei",L("ey"),"ei",L("oe"),"o",L("ue"),"u",L("ie"),"i",L("sz"),"s",L("zs"),"s",L("sh"),"s",L("ck"),"k",L("cc"),"k",L("th"),"t",L("dt"),"t",L("ph"),"f",L("pf"),"f",L("ou"),"o",L("uo"),"u"];function Da(a,b,c){a&&(a=xa(a,b||this).join(" "),2<a.length&&(a=K(a,Ca)),c||(1<a.length&&(a=ba(a)),a&&(a=a.split(" "))));return a};var Fa={encode:Ea,h:!1},Ga=/[\W_]+/;function Ea(a){return O(this,a.toLowerCase(),!1,Ga)};var Ia={encode:Ha,h:!1},Ja=[L("(?!\\b)p"),"b",L("(?!\\b)z"),"s",L("(?!\\b)[cgq]"),"k",L("(?!\\b)n"),"m",L("(?!\\b)d"),"t",L("(?!\\b)[vw]"),"f",L("(?!\\b)[aeiouy]"),""];function Ha(a){a&&(a=Da(a,this,!0),1<a.length&&(a=K(a,Ja)),1<a.length&&(a=ba(a)),a&&(a=a.split(" ")));return a};var La={encode:Ka,h:!1,B:"strict"},Ma=/[^a-z]+/;function Ka(a){a=O(this,a.toLowerCase(),!1,!1);var b=[];if(a)for(var c=a.split(Ma),d=c.length,e=0,f=0;e<d;e++)if((a=c[e])&&2<a.length&&(!this.filter||!this.filter[a])){for(var g=a[0],h=Na(g),k=1;k<a.length;k++){var m=Na(a[k]);if(m!==h&&(g+=m,h=m,4===g.length))break}b[f++]=(g+"0000").substring(0,4)}return b}
function Na(a){switch(a){case "b":case "f":case "p":case "v":return 1;case "c":case "g":case "j":case "k":case "q":case "s":case "x":case "z":return 2;case "d":case "t":return 3;case "l":return 4;case "m":case "n":return 5;case "r":return 6}return""};var Pa={encode:Oa,h:!0},Qa=/[\x00-\x7F]+/g;function Oa(a){return O(this,a.replace(Qa," "),!1," ")};var Sa={encode:Ra,h:!1,B:"strict"},Ta=/[\x00-\x7F]+/g;function Ra(a){return O(this,a.replace(Ta,""),!1,"")};var Va={encode:Ua,h:!1},Wa=/[\x00-\x7F]+/g;function Ua(a){return O(this,a.replace(Wa," "),!1," ")};V["latin:advanced"]={encode:Da,h:!1};V["latin:balance"]=Fa;V["latin:default"]=ka;V["latin:extra"]=Ia;V["latin:simple"]=ya;V["latin:soundex"]=La;V["arabic:default"]=Pa;V["cjk:default"]=Sa;V["cyrillic:default"]=Va;(function(){var a=this||window,b;(b=a.define)&&b.amd?b([],function(){return P}):"object"===typeof a.exports?a.module.exports=P:a.FlexSearch=P})();}).call(this);
(function(){'use strict';var r;function t(a){for(var b=Array(a),c=0;c<a;c++)b[c]=x();return b}function x(){return Object.create(null)}function z(a,b){return b.length-a.length};var A=/[\W_]+/;function aa(a){if(a=a.toLowerCase())if(a&&this.A&&(a=B(a,this.A)),this.C&&1<a.length&&(a=B(a,this.C)),a&&(A||""===A)&&(a=a.split(A),this.filter)){for(var b=this.filter,c=a.length,d=[],e=0,h=0;e<c;e++){var f=a[e];f&&!b[f]&&(d[h++]=f)}a=d}return a};function ba(a){for(var b=x(),c=0,d=a.length;c<d;c++)b[a[c]]=1;return b}function C(a,b){for(var c=Object.keys(a),d=c.length,e=[],h="",f=0,g=0,k,l;g<d;g++)k=c[g],(l=a[k])?(e[f++]=new RegExp(b?"(?!\\b)"+k+"(\\b|_)":k,"g"),e[f++]=l):h+=(h?"|":"")+k;h&&(e[f++]=new RegExp(b?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),e[f]="");return e}function B(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a};var D={},E={};var F=Promise;Object.assign||(Object.assign=function(){for(var a=arguments,b=a.length,c=a[0],d=1,e,h,f;d<b;d++){e=a[d];h=Object.keys(e);f=h.length;for(var g=0,k;g<f;g++)k=h[g],c[k]=e[k]}return c});if(!F){var G=function(a){this.g=null;var b=this;a(function(c){b.g&&(b.g(c),b=b.g=null)})};G.prototype.then=function(a){this.g=a};F=G};function H(a,b,c){return I.call(this,this.add,arguments)}function J(a,b,c){return I.call(this,this.append,arguments)}function K(a,b,c){return I.call(this,this.search,arguments)}function L(a,b,c){return I.call(this,this.update,arguments)}function M(a,b){return I.call(this,this.remove,arguments)}function I(a,b){for(var c,d=0;d<b.length;d++)if("function"===typeof b[d]){c=b[d];delete b[d];break}var e=this;d=new F(function(h){setTimeout(function(){h(a.apply(e,b))})});return c?(d.then(c),this):d};function N(a){this.h=!0!==a&&a;this.cache=x();this.g=[]}function O(a,b,c){"object"===typeof a&&(a=a.query);var d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}N.prototype.set=function(a,b){if(!this.cache[a]){var c=this.g.length;c===this.h?delete this.cache[this.g[c-1]]:c++;for(--c;0<c;c--)this.g[c]=this.g[c-1];this.g[0]=a}this.cache[a]=b};
N.prototype.get=function(a){var b=this.cache[a];if(this.h&&b&&(a=this.g.indexOf(a))){var c=this.g[a-1];this.g[a-1]=this.g[a];this.g[a]=c}return b};var P={memory:{charset:"latin:extra",m:3,j:3,v:!1,l:"memory"},performance:{threshold:8,j:3,context:{depth:1,s:!0}},match:{charset:"latin:extra",F:"full",m:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,s:!0}},"default":{m:3,threshold:0,depth:3}};function ca(a){if("string"===typeof a)P[a]||console.warn("Preset not found: "+a),a=P[a];else{var b=a.preset;b&&(P[b]||console.warn("Preset not found: "+b),a=Object.assign({},P[b],a))}return a};function da(a,b,c){var d=a.length,e=[],h=x(),f=0;c&&(c=[]);for(var g=0;g<d;g++){for(var k=a[g],l=k.length,p=x(),m=!g,n=0;n<l;n++){var q=k[n],u=q.length;if(u){c&&(c[n]=[]);for(var v=0,y=0,w;v<u;v++)if(w=q[v],!g)p[w]=1;else if(h[w]){if(g===d-1){if(e[f++]=w,f===b)return e}else c&&y<b&&(c[n][y++]=w),p[w]=1;m=!0}}}if(!m&&!c)return[];h=p}if(c)for(a=c.length-1;0<=a;a--)if(h=(d=c[a])&&d.length){if(f+h>=b)return e.concat(d.slice(0,b-f));e=e.concat(d);f+=h}return e};function Q(a,b){if(!(this instanceof Q))return new Q(a);if(a){a=ca(a);var c=a.charset;var d=a.lang;"string"===typeof c&&(-1===c.indexOf(":")&&(c+=":default"),c=E[c]);"string"===typeof d&&(d=D[d])}else a={};var e,h=a.context||{};this.encode=a.encode||c&&c.encode||aa;this.register=b||x();var f=a.resolution||9;var g=a.threshold||0;g>=f&&(g=f-1);this.m=f;this.threshold=g;this.D=b=c&&c.F||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.s=R(h.bidirectional,!0);this.l=e="memory"===a.optimize;
this.v=R(a.fastupdate,!0);this.j=a.minlength||1;this.g=e?t(f-g):x();f=h.resolution||f;g=h.threshold||g;g>=f&&(g=f-1);this.h=f;this.o=g;this.i=e?t(f-g):x();this.B=c&&c.B||a.rtl;this.A=(b=a.matcher||d&&d.A)&&C(b,!1);this.C=(b=a.stemmer||d&&d.C)&&C(b,!0);this.filter=(b=a.filter||d&&d.filter)&&ba(b);this.cache=(b=a.cache)&&new N(b);this.u=(b=a.worker)&&new Worker("worker.js",{type:"module"});b&&(this.u.onmessage=function(k){console.log(k.data)},this.u.postMessage({G:"register",options:a}))}
function R(a,b){return"undefined"!==typeof a?a:b}r=Q.prototype;r.append=function(a,b){return this.add(a,b,!0)};
r.add=function(a,b,c){if(this.register[a]&&!c)return this.update(a,b);if(b&&(a||0===a)){b=this.encode(b);var d=b.length;if(d){for(var e=this.depth,h=this.m-this.threshold,f=x(),g=x(),k=0;k<d;k++){var l=b[this.B?d-1-k:k],p=l.length;if(l&&p>=this.j&&(e||!f[l])){var m=Math.min(this.m/d*k|0,k);if(m<h){var n="";switch(this.D){case "full":if(3<p){for(var q=0;q<p;q++){var u=q?Math.min(m/2+this.m/p*q/2|0,m+q):m;if(u<h)for(var v=p;v>q;v--)n=l.substring(q,v),n.length>=this.j&&S(this,f,n,u,a,c)}break}case "reverse":if(2<
p){for(q=p-1;0<q;q--)n=l[q]+n,n.length>=this.j&&S(this,f,n,m,a,c);n=""}case "forward":if(1<p)for(q=0;q<p;q++)n+=l[q],n.length>=this.j&&S(this,f,n,m,a,c);break;default:if(S(this,f,l,m,a,c),e&&1<d&&k<d-1)for(p=this.h-this.o,m=x(),n=l,q=Math.min(e+1,d-k),u=m[n]=1;u<q;u++)if((l=b[this.B?d-1-k-u:k+u])&&l.length>=this.j&&!m[l]){if(m[l]=1,v=Math.min((this.h-q)/d*k+u|0,k+(u-1)),v<p){var y=this.s&&l>n;S(this,g,y?n:l,v,a,c,y?l:n)}}else q=Math.min(q+1,d-k)}}}}this.v||(this.register[a]=1)}}return this};
function S(a,b,c,d,e,h,f){var g=f?a.i:a.g;if(!b[c]||f&&!b[c][f])a.l&&(g=g[d]),f?(b[c]||(b[c]=x()),b[c][f]=1,g=g[f]||(g[f]=x())):b[c]=1,g=g[c]||(g[c]=[]),a.l||(g=g[d]||(g[d]=[])),h&&-1!==g.indexOf(e)||(g[g.length]=e,a.v&&((b=a.register[e])?b[b.length]=g:a.register[e]=[g]))}
r.search=function(a,b,c){"object"===typeof a?(c=a,a=c.query):"object"===typeof b&&(c=b);var d=[],e=this.threshold;if(c){b=c.limit;e=R(c.threshold,e);var h=c.context;var f=c.suggest}if(a){a=this.encode(a);var g=a.length;if(1<g){c=x();for(var k=[],l=0,p=0,m;l<g;l++)if((m=a[l])&&m.length>=this.j&&!c[m])if(this.l||f||this.g[m])k[p++]=m,c[m]=1;else return d;a=k;g=a.length}}if(!g)return d;b||(b=100);c=this.m-e;e=this.h-e;h=this.depth&&1<g&&!1!==h;k=0;if(h){var n=a[0];k=1}else 1<g&&a.sort(z);for(;k<g;k++){p=
a[k];h?(l=T(this,d,f,e,b,2===g,p,n),f&&!1===l&&d.length||(n=p)):l=T(this,d,f,c,b,1===g,p);if(l)return l;if(f&&k===g-1){l=d.length;if(!l){if(h){h=0;k=-1;continue}return d}if(1===l)return d=d[0],d=1===d.length?d[0]:[].concat.apply([],d),d.length>b?d.slice(0,b):d}}return da(d,b,f)};function U(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}
function T(a,b,c,d,e,h,f,g){var k=[],l=g?a.i:a.g;a.l||(l=U(l,f,g,a.s));if(l){var p=0;d=Math.min(l.length,d);for(var m=0,n=0,q;m<d&&!(q=l[m],a.l&&(q=U(q,f,g,a.s)),q&&(k[p++]=q,h&&(n+=q.length,n>=e)));m++);if(p){if(h)return k=1===p?k[0]:[].concat.apply([],k),k.length>e?k.slice(0,e):k;b[b.length]=k;return}}return!c&&k}r.contain=function(a){return!!this.register[a]};r.update=function(a,b){return this.remove(a).add(a,b)};
r.remove=function(a,b){var c=this.register[a];if(c){if(this.v)for(var d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else V(this.g,a,this.m-this.threshold,this.l),this.depth&&V(this.i,a,this.h-this.o,this.l);b||delete this.register[a];if(this.cache)for(b=this.cache,c=0;c<b.g.length;c++)e=b.g[c],d=b.cache[e],-1!==d.indexOf(a)&&(b.g.splice(c--,1),delete b.cache[e])}return this};
function V(a,b,c,d,e){var h=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),h++):h++;else{e=Math.min(a.length,c);for(var f=0,g;f<e;f++)if(g=a[f])h=V(g,b,c,d,e),d||h||delete a[f]}else for(f in a)(h=V(a[f],b,c,d,e))||delete a[f];return h}r.searchCache=O;r.addAsync=H;r.appendAsync=J;r.searchAsync=K;r.updateAsync=L;r.removeAsync=M;function W(a){if(!(this instanceof W))return new W(a);var b;a||(a={});this.register=x();this.store=(b=a.store)&&x();this.h=b&&!0!==b&&[];this.i=[];this.key=(b=a.key)&&X(b,this.i)||"id";this.u=[];this.g=[];this.cache=(b=a.cache)&&new N(b);a.cache=!1;b=a;a=x();var c=b.doc;if("string"===typeof c)c=[c];else if(c.constructor!==Array){var d=c;c=Object.keys(c)}for(var e=0,h,f;e<c.length;e++)h=c[e],d?(f=d[h],f="object"===typeof f?Object.assign({},b,f):b):f=b,a[h]=new Q(f,this.register),this.u[e]=X(h,this.i),
this.g[e]=h;if(this.h)for(d=b.store,"string"===typeof d&&(d=[d]),b=0;b<d.length;b++)this.h[b]=X(d[b],this.i);this.o=a}function X(a,b){for(var c=a.split(":"),d=0,e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function Y(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)Y(a,b,c,d,e);else b=b[e]||(b[e]=x()),e=c[++d],Y(a,b,c,d,e)}
function Z(a,b,c,d,e,h,f,g){a=a[f];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(h,a[b],!0);return}a=a.join(" ")}e.add(h,a,g)}else if(a)if(a.constructor===Array)for(f=0;f<a.length;f++)Z(a,b,c,d,e,h,f,g);else f=b[++d],Z(a,b,c,d,e,h,f,g)}r=W.prototype;
r.add=function(a,b,c){if("object"===typeof a){a=b=a;var d=this.key;if("string"===typeof d)a=a[d];else for(var e=0;a&&e<d.length;e++)a=a[d[e]]}if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);d=0;for(var h;d<this.g.length;d++)h=this.g[d],e=this.u[d],"string"===typeof e&&(e=[e]),Z(b,e,this.i,0,this.o[h],a,e[0],c);if(this.store){if(this.h){var f=x();for(c=0;c<this.h.length;c++)d=this.h[c],"string"===typeof d?f[d]=b[d]:Y(b,f,d,0,d[0])}this.store[a]=f||b}}return this};
r.append=function(a,b){return this.add(a,b,!0)};r.update=function(a,b){return this.remove(a).add(a,b)};r.remove=function(a){"object"===typeof a&&(a=a[this.key]);if(this.register[a]){for(var b=0;b<this.g.length;b++)this.o[this.g[b]].remove(a,!0);this.store&&delete this.store[a];delete this.register[a]}return this};
r.search=function(a,b,c){"object"===typeof a?(c=a,a=c.query):"object"===typeof b&&(c=b);var d=[],e,h=0;if(c){var f=(e=c.pluck)||c.field;var g=c.enrich;var k="and"===c.bool;b=c.limit}if(f)if("string"===typeof f)f=[f];else{if(f.constructor!==Array){var l=f;f=Object.keys(f)}}else f=this.g;k=k&&1<f.length;for(var p=0,m,n;p<f.length;p++){m=f[p];n=l?l[m]:c;m=this.o[m].search(a,b,n);if(k&&!m.length)return[];h+=m.length;d[p]=m}if(!h)return[];if(e&&(!g||!this.store))return d[0];for(a=0;a<f.length;a++){b=f[a];
c=d[a];if(g&&this.store){l=Array(c.length);for(k=0;k<c.length;k++)h=c[k],l[k]={key:h,doc:this.store[h]};c=l}if(e)return c;d[a]={field:b,result:c}}return d};r.get=function(a){return this.store[a]};r.set=function(a,b){this.store[a]=b;return this};r.contain=function(a){return!!this.register[a]};r.searchCache=O;r.addAsync=H;r.appendAsync=J;r.searchAsync=K;r.updateAsync=L;r.removeAsync=M;window.FlexSearch={Index:Q,Document:W,registerCharset:function(a,b){E[a]=b},registerLanguage:function(a,b){D[a]=b}};}).call(this);

View File

@@ -1,34 +0,0 @@
/**!
* FlexSearch.js v0.7.0
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(){'use strict';function t(a){return"string"===typeof a}function y(a){return a.constructor===Array}function z(a){return"function"===typeof a}function E(a){return"object"===typeof a}function F(a){return"undefined"===typeof a}function aa(a){for(var b=Array(a),c=0;c<a;c++)b[c]=G();return b}function G(){return Object.create(null)}function K(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function L(a){return new RegExp(a,"g")}
function ca(a){for(var b="",c="",d=0,e=a.length,f=void 0;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b}function O(a,b,c,d){if(b&&(c&&b&&(b=K(b,c)),b&&a.m&&(b=K(b,a.m)),a.s&&1<b.length&&(b=K(b,a.s)),b&&(d||""===d)&&(b=b.split(d),a.filter))){a=a.filter;c=b.length;d=[];for(var e=0,f=0;e<c;e++){var g=b[e];g&&!a[g]&&(d[f++]=g)}b=d}return b};P.prototype.export=function(a){var b=!a||F(a.serialize)||a.serialize;if(this.a){var c=!a||F(a.doc)||a.doc,d=!a||F(a.index)||a.index;a=[];var e=0;if(d)for(d=this.a.keys;e<d.length;e++){var f=this.a.index[d[e]];a[e]=[f.i,f.h,Object.keys(f.f)]}c&&(a[e]=this.l)}else a=[this.i,this.h,Object.keys(this.f)];b&&(a=JSON.stringify(a));return a};
P.prototype.import=function(a,b){if(!b||F(b.serialize)||b.serialize)a=JSON.parse(a);var c={};if(this.a){var d=!b||F(b.doc)||b.doc,e=0;if(!b||F(b.index)||b.index){b=this.a.keys;for(var f=b.length,g=a[0][2];e<g.length;e++)c[g[e]]=1;for(e=0;e<f;e++){g=this.a.index[b[e]];var h=a[e];h&&(g.i=h[0],g.h=h[1],g.f=c)}}d&&(this.l=E(d)?d:a[e])}else{d=a[2];for(e=0;e<d.length;e++)c[d[e]]=1;this.i=a[0];this.h=a[1];this.f=c}};P.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};
P.prototype.where=function(a,b,c,d){var e=this.l,f=[],g=0,h;if(E(a)){c||(c=b);var k=Object.keys(a);var m=k.length;var q=!1;if(1===m&&"id"===k[0])return[e[a.id]];if((h=this.w)&&!d)for(var r=0;r<h.length;r++){var p=h[r],l=a[p];if(!F(l)){var n=this.o[p]["@"+l];if(0===--m)return n;k.splice(k.indexOf(p),1);delete a[p];break}}h=Array(m);for(r=0;r<m;r++)h[r]=k[r].split(":")}else{if(z(a)){b=d||Object.keys(e);c=b.length;for(k=0;k<c;k++)m=e[b[k]],a(m)&&(f[g++]=m);return f}if(F(b))return[e[a]];if("id"===a)return[e[b]];
k=[a];m=1;h=[a.split(":")];q=!0}d=n||d||Object.keys(e);r=d.length;for(p=0;p<r;p++){l=n?d[p]:e[d[p]];for(var w=!0,v=0;v<m;v++){q||(b=a[k[v]]);var x=h[v],u=x.length,A=l;if(1<u)for(var B=0;B<u;B++)A=A[x[B]];else A=A[x[0]];if(A!==b){w=!1;break}}if(w&&(f[g++]=l,c&&g===c))break}return f};function S(a){this.clear();this.j=!0!==a&&a}S.prototype.clear=function(){this.cache=G();this.count=G();this.index=G();this.b=[]};S.prototype.set=function(a,b){if(this.j&&F(this.cache[a])){var c=this.b.length;if(c===this.j){c--;var d=this.b[c];delete this.cache[d];delete this.count[d];delete this.index[d]}this.b[c]=a;this.index[a]=c;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};
S.prototype.get=function(a){var b=this.cache[a];if(this.j&&b){var c=++this.count[a],d=this.index,e=d[a];if(0<e){for(var f=this.b,g=e;this.count[f[--e]]<=c&&-1!==e;);e++;if(e!==g){for(c=g;c>e;c--)g=f[c-1],f[c]=g,d[g]=c;f[e]=a;d[a]=e}}}return b};var da={memory:{charset:"latin:extra",threshold:0,c:1},speed:{threshold:1,c:3,depth:2},match:{charset:"latin:extra",u:"full",threshold:1,c:3},score:{charset:"latin:extra",threshold:1,c:9,depth:4},balance:{charset:"latin:balance",threshold:0,c:3,depth:3},fast:{threshold:8,c:9,depth:1}};var fa={encode:ea,g:!1},ha=/[\W_]+/;function ea(a){return O(this,a.toLowerCase(),!1,ha)};var ia=0,ja={},U={};function P(a){if(!(this instanceof P))return new P(a);var b=a&&a.id;this.id=b||0===b?b:ia++;this.init(a);ka(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});ka(this,"length",function(){return this.index.length})}P.registerCharset=function(a,b){U[a]=b;return P};P.registerLanguage=function(a,b){ja[a]=b;return P};
P.prototype.init=function(a){var b,c;if(a)if(t(a))a=da[a];else if(b=a.preset)a=Object.assign({},da[b],a);a||(a={});this.async=a.async;var d=a.charset,e=a.lang;t(d)&&(-1===d.indexOf(":")&&(d+=":default"),d=U[d]);t(e)&&(e=ja[e]);this.v=b=d&&d.u||a.tokenize||"strict";this.depth="strict"===b&&a.depth||0;this.g=d&&d.g||a.rtl||!1;this.c=a.resolution||9;this.threshold=b=a.threshold||0;this.c<=b&&(this.c=b+1);this.encode=a.encode||d&&d.encode||ea;this.m=(b=a.matcher||e&&e.m)&&la(b,!1);this.s=(b=a.stemmer||
e&&e.s)&&la(b,!0);if(d=b=a.filter||e&&e.filter){d=b;e=G();var f=0;for(c=d.length;f<c;f++)e[d[f]]=1;d=e}this.filter=d;(this.a=c=(b=a.doc)&&ma(b))&&(a.doc=null);this.i=aa(this.c-this.threshold);this.h=G();this.f=G();if(c){this.l=G();d=c.index={};e=c.keys=[];f=c.field;var g=c.tag,h=c.store;y(c.id)||(c.id=c.id.split(":"));if(h){var k=G();if(t(h))k[h]=1;else if(y(h))for(var m=0;m<h.length;m++)k[h[m]]=1;else E(h)&&(k=h);c.store=k}if(g){this.o=G();h=G();if(f)if(t(f))h[f]=a;else if(y(f))for(k=0;k<f.length;k++)h[f[k]]=
a;else E(f)&&(h=f);y(g)||(c.tag=g=[g]);for(f=0;f<g.length;f++)this.o[g[f]]=G();this.w=g;f=h}if(f){if(!y(f))if(E(f)){var q=f;c.field=f=Object.keys(f)}else c.field=f=[f];for(c=0;c<f.length;c++)g=f[c],y(g)||(q&&(a=q[g]),e[c]=g,f[c]=g.split(":")),d[g]=new P(a)}}this.j=!0;this.b=(b=a.cache)&&new S(b);return this};function ma(a){var b=G(),c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];b[c]=y(d)?d.slice(0):E(d)?ma(d):d}return b}
P.prototype.add=function(a,b,c,d,e){if(this.a&&E(a))return V(this,"add",a,b);if(b&&t(b)&&(a||0===a)){if(this.f[a]&&!d)return this.update(a,b);if(!e){if(this.async){var f=this,g=new Promise(function(M){setTimeout(function(){f.add(a,b,null,d,!0);f=null;M()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=b;e=G();e._ctx=G();for(var h=c.length,k=this.threshold,m=this.depth,q=this.c,r=this.i,p=this.g,l=0;l<h;l++){var n=
c[l];if(n){g=1;var w=n.length,v=(p?l+1:h-l)/h,x="";switch(this.v){case "reverse":case "both":for(var u=w;--u;)x=n[u]+x,W(r,e,x,a,p?1:(w-u)/w,v,k,q-1);x="";case "forward":for(u=0;u<w;u++)x+=n[u],W(r,e,x,a,p?(u+1)/w:1,v,k,q-1);break;case "full":for(u=0;u<w;u++)for(var A=(p?u+1:w-u)/w,B=w;B>u;B--)x=n.substring(u,B),W(r,e,x,a,A,v,k,q-1);break;default:if(w=W(r,e,n,a,1,v,k,q-1),m&&1<h&&w>=k)for(w=e._ctx[n]||(e._ctx[n]=G()),n=this.h[n]||(this.h[n]=aa(q-(k||0))),v=l-m,x=l+m+1,0>v&&(v=0),x>h&&(x=h);v<x;v++)v!==
l&&W(n,w,c[v],a,0,q-(v<l?l-v:v-l),k,q-1)}}}g&&(this.f[a]=1);this.j=!1}return this};
function V(a,b,c,d){if(y(c)){var e=c.length;if(e)for(var f=0;f<e;f++)V(a,b,c[f],f===e-1&&d)}else{var g=a.a.index,h=a.a.keys,k=a.a.tag;f=a.a.store;var m;var q=a.a.id;e=c;for(var r=0;r<q.length;r++)e=e[q[r]];if("remove"===b){if(delete a.l[e],c=h.length)for(f=0;f<c;f++)g[h[f]].remove(e,f===c-1&&d)}else{if(k){for(m=0;m<k.length;m++){var p=k[m];var l=c;q=p.split(":");for(r=0;r<q.length;r++)l=l[q[r]];l="@"+l}m=a.o[p];m=m[l]||(m[l]=[])}q=a.a.field;k=0;for(p=q.length;k<p;k++){r=q[k];l=c;for(var n=0;n<r.length;n++)l=
l[r[n]];r=g[h[k]];"add"===b?r.add(e,l,k===p-1&&d):r.update(e,l,k===p-1&&d)}if(f){d=Object.keys(f);b=G();for(g=0;g<d.length;g++)if(h=d[g],f[h])for(h=h.split(":"),k=q=void 0,p=0;p<h.length;p++)l=h[p],q=(q||c)[l],k=(k||b)[l]=q;c=b}m&&(m[m.length]=c);a.l[e]=c}}return a}P.prototype.update=function(a,b,c){if(this.a&&E(a))return V(this,"update",a,b);this.f[a]&&t(b)&&(this.remove(a),this.add(a,b,c,!0));return this};
P.prototype.remove=function(a,b,c){if(this.a&&E(a))return V(this,"remove",a,b);if(this.f[a]){if(!c){if(this.async&&"function"!==typeof importScripts){var d=this;c=new Promise(function(e){setTimeout(function(){d.remove(a,null,!0);d=null;e()})});if(b)c.then(b);else return c;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.c-(this.threshold||0);b++)X(this.i[b],a);this.depth&&X(this.h,a);delete this.f[a];this.j=!1}return this};var Y;
function na(a,b,c,d,e,f,g,h,k,m,q){d=oa(d,h?0:f,k,g,c,m,q);if(k){k=d.page;var r=d.next;d=d.result}if(h)d=a.where(h,null,f,d);else{c=d;d=a.l;f=c.length;g=Array(f);for(h=0;h<f;h++)g[h]=d[c[h]];d=g}e&&(z(e)||(Y=e.split(":"),e=1<Y.length?pa:qa),d.sort(e));d=Z(k,r,d);a.b&&a.b.set(b,d);return d}
P.prototype.search=function(a,b,c,d){if(E(b)){if(y(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&z(b)?(c=b,b=1E3):b||0===b||(b=1E3);var f=[],g=a;if(E(a)&&!y(a)){c||(c=a.callback)&&(g.callback=null);var h=a.sort;var k=a.page;b=a.limit;var m=a.threshold;var q=a.suggest;a=a.query}if(this.a){m=this.a.index;var r=g.where,p=g.bool||"or",l=g.field,n=p,w,v;if(l)y(l)||(l=[l]);else if(y(g)){var x=g;l=[];n=[];for(var u=0;u<g.length;u++)d=g[u],e=d.bool||p,l[u]=d.field,n[u]=e,"not"===
e?w=!0:"and"===e&&(v=!0)}else l=this.a.keys;p=l.length;for(u=0;u<p;u++)x&&(g=x[u]),k&&!t(g)&&(g.page=null,g.limit=0),f[u]=m[l[u]].search(g,0);if(c)return c(na(this,a,n,f,h,b,q,r,k,v,w));if(this.async){var A=this;return new Promise(function(ba){Promise.all(f).then(function(ua){ba(na(A,a,n,ua,h,b,q,r,k,v,w))})})}return na(this,a,n,f,h,b,q,r,k,v,w)}m||(m=this.threshold||0);if(!d){if(this.async&&"function"!==typeof importScripts){var B=this;m=new Promise(function(ba){setTimeout(function(){ba(B.search(g,
b,null,!0));B=null})});if(c)m.then(c);else return m;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!t(a))return f;g=a;if(this.b)if(this.j){if(c=this.b.get(a))return c}else this.b.clear(),this.j=!0;g=this.encode(g);if(!g.length)return f;c=g;x=c.length;d=!0;e=[];var M=G(),Q=0;1<x&&(this.depth?p=!0:c.sort(ra));if(!p||(u=this.h))for(var T=this.c;Q<x;Q++){var C=c[Q];if(C){if(p){if(!l)if(u[C])l=C,M[C]=1;else if(!q)return f;if(q&&Q===x-1&&!e.length)p=!1,C=l||C,M[C]=0;else if(!l)continue}if(!M[C]){var D=
[],N=!1,H=0,I=p?u[l]:this.i;if(I)for(var R=void 0,J=0;J<T-m;J++)if(R=I[J]&&I[J][C])D[H++]=R,N=!0;if(N)l=C,e[e.length]=1<H?D.concat.apply([],D):D[0];else if(!q){d=!1;break}M[C]=1}}}else d=!1;d&&(f=oa(e,b,k,q));this.b&&this.b.set(a,f);return f};P.prototype.info=function(){return{id:this.id,items:this.length,matcher:this.m.length,worker:this.A,threshold:this.threshold,depth:this.depth,resolution:this.c,contextual:this.depth&&"strict"===this.v}};P.prototype.clear=function(){return this.destroy().init()};
P.prototype.destroy=function(){this.b&&(this.b.clear(),this.b=null);this.i=this.h=this.f=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.l=null}return this};function ka(a,b,c){Object.defineProperty(a,b,{get:c})}function W(a,b,c,d,e,f,g,h){if(b[c])return b[c];e=e?(h-(g||h/1.5))*f+(g||h/1.5)*e:f;b[c]=e;e>=g&&(a=a[h-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}
function X(a,b){if(a)for(var c=Object.keys(a),d=0,e=c.length;d<e;d++){var f=c[d],g=a[f];if(g)for(var h=0,k=g.length;h<k;h++)if(g[h]===b){1===k?delete a[f]:g.splice(h,1);break}else E(g[h])&&X(g[h],b)}}function la(a,b){for(var c=Object.keys(a),d=c.length,e=[],f="",g=0,h=0,k;h<d;h++){var m=c[h];(k=a[m])?(e[g++]=L(b?"(?!\\b)"+m+"(\\b|_)":m),e[g++]=k):f+=(f?"|":"")+m}f&&(e[g++]=L(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function ra(a,b){return b.length-a.length}
function qa(a,b){a=a[Y];b=b[Y];return a<b?-1:a>b?1:0}function pa(a,b){for(var c=Y.length,d=0;d<c;d++)a=a[Y[d]],b=b[Y[d]];return a<b?-1:a>b?1:0}function Z(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}
function oa(a,b,c,d,e,f,g){var h=[];if(!0===c){c="0";var k=""}else k=c&&c.split(":");var m=a.length;if(1<m){var q=G(),r=[],p,l=0,n,w=!0,v=0,x;if(k)if(2===k.length){var u=k;k=!1}else k=x=parseInt(k[0],10);if(g){for(p=G();l<m;l++)if("not"===e[l]){var A=a[l];var B=A.length;for(n=0;n<B;n++)p["@"+A[n]]=1}else var M=l+1;if(F(M))return Z(c,J,h);l=0}else var Q=t(e)&&e;for(var T;l<m;l++){var C=l===(M||m)-1;if(!Q||!l)if((n=Q||e&&e[l])&&"and"!==n)if("or"===n)T=!1;else continue;else T=f=!0;A=a[l];if(B=A.length){if(w)if(H){var D=
H.length;for(n=0;n<D;n++){w=H[n];var N="@"+w;g&&p[N]||(q[N]=1,f||(h[v++]=w))}var H=null;w=!1}else{H=A;continue}N=!1;for(n=0;n<B;n++){D=A[n];var I="@"+D,R=f?q[I]||0:l;if(!(!R&&!d||g&&p[I]||!f&&q[I]))if(R===l){if(C){if(!x||--x<v)if(h[v++]=D,b&&v===b)return Z(c,v+(k||0),h)}else q[I]=l+1;N=!0}else d&&(I=r[R]||(r[R]=[]),I[I.length]=D)}if(T&&!N&&!d)break}else if(T&&!d)return Z(c,J,A)}if(H)if(l=H.length,g)for(n=k?parseInt(k,10):0;n<l;n++)a=H[n],p["@"+a]||(h[v++]=a);else h=H;if(d)for(v=h.length,u?(l=parseInt(u[0],
10)+1,n=parseInt(u[1],10)+1):(l=r.length,n=0);l--;)if(D=r[l]){for(B=D.length;n<B;n++)if(d=D[n],!g||!p["@"+d])if(h[v++]=d,b&&v===b)return Z(c,l+":"+n,h);n=0}}else!m||e&&"not"===e[0]||(h=a[0],k&&(k=parseInt(k[0],10)));if(b){g=h.length;k&&k>g&&(k=0);k=k||0;var J=k+b;J<g?h=h.slice(k,J):(J=0,k&&(h=h.slice(k)))}return Z(c,J,h)};var ta={encode:sa,g:!1},va=/[\W_]+/,wa=[L("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",L("[\u00e8\u00e9\u00ea\u00eb]"),"e",L("[\u00ec\u00ed\u00ee\u00ef]"),"i",L("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",L("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",L("[\u00fd\u0177\u00ff]"),"y",L("\u00f1"),"n",L("[\u00e7c]"),"k",L("\u00df"),"s",L(" & ")," and "];function sa(a,b){return O(b||this,a.toLowerCase(),wa,va)};var xa=[L("ae"),"a",L("ai"),"ei",L("ay"),"ei",L("ey"),"ei",L("oe"),"o",L("ue"),"u",L("ie"),"i",L("sz"),"s",L("zs"),"s",L("sh"),"s",L("ck"),"k",L("cc"),"k",L("th"),"t",L("dt"),"t",L("ph"),"f",L("pf"),"f",L("ou"),"o",L("uo"),"u"];function ya(a,b,c){a&&(a=sa(a,b||this).join(" "),2<a.length&&(a=K(a,xa)),c||(1<a.length&&(a=ca(a)),a&&(a=a.split(" "))));return a};var Aa={encode:za,g:!1},Ba=/[\W_]+/;function za(a){return O(this,a.toLowerCase(),!1,Ba)};var Da={encode:Ca,g:!1},Ea=[L("(?!\\b)p"),"b",L("(?!\\b)z"),"s",L("(?!\\b)[cgq]"),"k",L("(?!\\b)n"),"m",L("(?!\\b)d"),"t",L("(?!\\b)[vw]"),"f",L("(?!\\b)[aeiouy]"),""];function Ca(a){a&&(a=ya(a,this,!0),1<a.length&&(a=K(a,Ea)),1<a.length&&(a=ca(a)),a&&(a=a.split(" ")));return a};var Ga={encode:Fa,g:!1,u:"strict"},Ha=/[^a-z]+/;function Fa(a){a=O(this,a.toLowerCase(),!1,!1);var b=[];if(a)for(var c=a.split(Ha),d=c.length,e=0,f=0;e<d;e++)if((a=c[e])&&2<a.length&&(!this.filter||!this.filter[a])){for(var g=a[0],h=Ia(g),k=1;k<a.length;k++){var m=Ia(a[k]);if(m!==h&&(g+=m,h=m,4===g.length))break}b[f++]=(g+"0000").substring(0,4)}return b}
function Ia(a){switch(a){case "b":case "f":case "p":case "v":return 1;case "c":case "g":case "j":case "k":case "q":case "s":case "x":case "z":return 2;case "d":case "t":return 3;case "l":return 4;case "m":case "n":return 5;case "r":return 6}return""};var Ka={encode:Ja,g:!0},La=/[\x00-\x7F]+/g;function Ja(a){return O(this,a.replace(La," "),!1," ")};var Na={encode:Ma,g:!1,u:"strict"},Oa=/[\x00-\x7F]+/g;function Ma(a){return O(this,a.replace(Oa,""),!1,"")};var Qa={encode:Pa,g:!1},Ra=/[\x00-\x7F]+/g;function Pa(a){return O(this,a.replace(Ra," "),!1," ")};U["latin:advanced"]={encode:ya,g:!1};U["latin:balance"]=Aa;U["latin:default"]=fa;U["latin:extra"]=Da;U["latin:simple"]=ta;U["latin:soundex"]=Ga;U["arabic:default"]=Ka;U["cjk:default"]=Na;U["cyrillic:default"]=Qa;(function(){var a=this||window,b;(b=a.define)&&b.amd?b([],function(){return P}):"object"===typeof a.exports?a.module.exports=P:a.FlexSearch=P})();}).call(this);

1057
dist/flexsearch.pre.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
(function(){'use strict';var a=/[\x00-\x7F]+/g;window.FlexSearch.registerCharset("arabic:default",{encode:function(b){return this.a(b.replace(a," "),!1," ",!1)},b:!0});}).call(this);

2
dist/lang/at.min.js vendored
View File

@@ -1,2 +0,0 @@
(function(){'use strict';window.FlexSearch.registerLanguage("at",{filter:"aber als am an auch auf aus bei bin bis bist da dadurch daher darum das da\u00df dass dein deine dem den der des dessen deshalb die dies dieser dieses doch dort du durch ein eine einem einen einer eines er es euer eure f\u00fcr hatte hatten hattest hattet hier hinter ich ihr ihre im in ist ja jede jedem jeden jeder jedes jener jenes jetzt kann kannst k\u00f6nnen k\u00f6nnt machen mein meine mit mu\u00df mu\u00dft musst m\u00fcssen m\u00fc\u00dft nach nachdem nein nicht nun oder seid sein seine sich sie sind soll sollen sollst sollt sonst soweit sowie und unser unsere unter vom von vor wann warum was weiter weitere wenn wer werde werden werdet weshalb wie wieder wieso wir wird wirst wo woher wohin zu zum zur \u00fcber".split(" "),
b:{niss:"",isch:"",lich:"",heit:"",keit:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""},a:{}});}).call(this);

View File

@@ -1 +0,0 @@
(function(){'use strict';var a=/[\x00-\x7F]+/g;window.FlexSearch.registerCharset("cjk:default",{encode:function(b){return this.a(b.replace(a,""),!1,"",!1)},b:!1,c:"strict"});}).call(this);

View File

@@ -1 +0,0 @@
(function(){'use strict';var a=/[\x00-\x7F]+/g;window.FlexSearch.registerCharset("cyrillic:default",{encode:function(b){return this.a(b.replace(a," "),!1," ",!1)},b:!1});}).call(this);

2
dist/lang/de.min.js vendored
View File

@@ -1,2 +0,0 @@
(function(){'use strict';window.FlexSearch.registerLanguage("de",{filter:"aber als am an auch auf aus bei bin bis bist da dadurch daher darum das da\u00df dass dein deine dem den der des dessen deshalb die dies dieser dieses doch dort du durch ein eine einem einen einer eines er es euer eure f\u00fcr hatte hatten hattest hattet hier hinter ich ihr ihre im in ist ja jede jedem jeden jeder jedes jener jenes jetzt kann kannst k\u00f6nnen k\u00f6nnt machen mein meine mit mu\u00df mu\u00dft musst m\u00fcssen m\u00fc\u00dft nach nachdem nein nicht nun oder seid sein seine sich sie sind soll sollen sollst sollt sonst soweit sowie und unser unsere unter vom von vor wann warum was weiter weitere wenn wer werde werden werdet weshalb wie wieder wieso wir wird wirst wo woher wohin zu zum zur \u00fcber".split(" "),
b:{niss:"",isch:"",lich:"",heit:"",keit:"",ell:"",bar:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""},a:{}});}).call(this);

2
dist/lang/en.min.js vendored
View File

@@ -1,2 +0,0 @@
(function(){'use strict';window.FlexSearch.registerLanguage("en",{filter:"a about above after again against all also am an and any are aren't as at be because been before being below both but by can cannot can't come could couldn't did didn't do does doesn't doing dont down during each even few first for from further get go had hadn't has hasn't have haven't having he hed her here here's hers herself hes him himself his how how's i id if ill im in into is isn't it it's itself i've just know let's like make me more most mustn't my myself new no nor not now of off on once only or other ought our our's ourselves out over own same say see shan't she she'd shell shes should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through time to too until up us very want was wasn't way we wed well were weren't we've what what's when when's where where's which while who whom who's why why's will with won't would wouldn't you you'd you'll your you're your's yourself yourselves you've".split(" "),
b:{ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""},a:{}});}).call(this);

View File

@@ -1 +0,0 @@
(function(){'use strict';function a(b){return new RegExp(b,"g")};var f=/[\W_]+/,h=[a("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",a("[\u00e8\u00e9\u00ea\u00eb]"),"e",a("[\u00ec\u00ed\u00ee\u00ef]"),"i",a("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",a("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",a("[\u00fd\u0177\u00ff]"),"y",a("\u00f1"),"n",a("[\u00e7c]"),"k",a("\u00df"),"s",a(" & ")," and "];function k(b,c){return(c||this).a(b.toLowerCase(),h,f,!1)};var l=[a("ae"),"a",a("ai"),"ei",a("ay"),"ei",a("ey"),"ei",a("oe"),"o",a("ue"),"u",a("ie"),"i",a("sz"),"s",a("zs"),"s",a("sh"),"s",a("ck"),"k",a("cc"),"k",a("th"),"t",a("dt"),"t",a("ph"),"f",a("pf"),"f",a("ou"),"o",a("uo"),"u"];window.FlexSearch.registerCharset("latin:advanced",{encode:function(b,c,e){if(b){b=k(b,c||this).join(" ");if(2<b.length){c=0;for(var d=l.length;c<d&&(b=b.replace(l[c],l[c+1]),b);c+=2);}if(!e){if(1<b.length){c=e="";d=0;for(var m=b.length,g=void 0;d<m;d++)(g=b[d])!==c&&(e+=c=g);b=e}b&&(b=b.split(" "))}}return b},b:!1});}).call(this);

View File

@@ -1 +0,0 @@
(function(){'use strict';var a=/[\W_]+/;window.FlexSearch.registerCharset("latin:balance",{encode:function(b){return this.a(b.toLowerCase(),!1,a,!1)},b:!1});}).call(this);

View File

@@ -1 +0,0 @@
(function(){'use strict';var a=/[\W_]+/;window.FlexSearch.registerCharset("latin:default",{encode:function(b){return this.a(b.toLowerCase(),!1,a,!1)},b:!1});}).call(this);

View File

@@ -1 +0,0 @@
(function(){'use strict';function a(b,c){for(var d=0,e=c.length;d<e&&(b=b.replace(c[d],c[d+1]),b);d+=2);return b}function f(b){return new RegExp(b,"g")};var h=/[\W_]+/,k=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("[\u00e7c]"),"k",f("\u00df"),"s",f(" & ")," and "];function l(b,c){return(c||this).a(b.toLowerCase(),k,h,!1)};var m=[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),"k",f("th"),"t",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];function n(b,c){b&&(b=l(b,c||this).join(" "),2<b.length&&(b=a(b,m)));return b};var p=[f("(?!\\b)p"),"b",f("(?!\\b)z"),"s",f("(?!\\b)[cgq]"),"k",f("(?!\\b)n"),"m",f("(?!\\b)d"),"t",f("(?!\\b)[vw]"),"f",f("(?!\\b)[aeiouy]"),""];window.FlexSearch.registerCharset("latin:extra",{encode:function(b){if(b){b=n(b,this);1<b.length&&(b=a(b,p));if(1<b.length){for(var c="",d="",e=0,q=b.length,g=void 0;e<q;e++)(g=b[e])!==d&&(c+=d=g);b=c}b&&(b=b.split(" "))}return b},b:!1});}).call(this);

View File

@@ -1 +0,0 @@
(function(){'use strict';function a(b){return new RegExp(b,"g")};var c=/[\W_]+/,d=[a("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",a("[\u00e8\u00e9\u00ea\u00eb]"),"e",a("[\u00ec\u00ed\u00ee\u00ef]"),"i",a("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",a("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",a("[\u00fd\u0177\u00ff]"),"y",a("\u00f1"),"n",a("[\u00e7c]"),"k",a("\u00df"),"s",a(" & ")," and "];window.FlexSearch.registerCharset("latin:simple",{encode:function(b,e){return(e||this).a(b.toLowerCase(),d,c,!1)},b:!1});}).call(this);

View File

@@ -1 +0,0 @@
(function(){'use strict';var f=/[^a-z]+/;function l(a){switch(a){case "b":case "f":case "p":case "v":return 1;case "c":case "g":case "j":case "k":case "q":case "s":case "x":case "z":return 2;case "d":case "t":return 3;case "l":return 4;case "m":case "n":return 5;case "r":return 6}return""};window.FlexSearch.registerCharset("latin:soundex",{encode:function(a){a=this.a(a.toLowerCase(),!1,!1,!1);var g=[];if(a)for(var h=a.split(f),m=h.length,c=0,n=0;c<m;c++)if((a=h[c])&&2<a.length&&(!this.filter||!this.filter[a])){for(var b=a[0],k=l(b),d=1;d<a.length;d++){var e=l(a[d]);if(e!==k&&(b+=e,k=e,4===b.length))break}g[n++]=(b+"0000").substring(0,4)}return g},b:!1,c:"strict"});}).call(this);

2
dist/lang/us.min.js vendored
View File

@@ -1,2 +0,0 @@
(function(){'use strict';window.FlexSearch.registerLanguage("us",{filter:"a about above after again against all also am an and any are aren't as at be because been before being below both but by can cannot can't come could couldn't did didn't do does doesn't doing dont down during each even few first for from further get go had hadn't has hasn't have haven't having he hed her here here's hers herself hes him himself his how how's i id if ill im in into is isn't it it's itself i've just know let's like make me more most mustn't my myself new no nor not now of off on once only or other ought our our's ourselves out over own same say see shan't she she'd shell shes should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through time to too until up us very want was wasn't way we wed well were weren't we've what what's when when's where where's which while who whom who's why why's will with won't would wouldn't you you'd you'll your you're your's yourself yourselves you've".split(" "),
b:{ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""},a:{}});}).call(this);

View File

@@ -1 +0,0 @@
import{is_undefined,create_object}from"./common.js";export default function CacheClass(a){this.clear(),this.limit=!0!==a&&a}CacheClass.prototype.clear=function(){this.cache=create_object(),this.count=create_object(),this.index=create_object(),this.ids=[]},CacheClass.prototype.set=function(a,b){if(this.limit&&is_undefined(this.cache[a])){let c=this.ids.length;if(c===this.limit){c--;const a=this.ids[c];delete this.cache[a],delete this.count[a],delete this.index[a]}this.ids[c]=a,this.index[a]=c,this.count[a]=-1,this.cache[a]=b,this.get(a)}else this.cache[a]=b},CacheClass.prototype.get=function(a){const b=this.cache[a];if(this.limit&&b){const b=++this.count[a],c=this.index;let d=c[a];if(0<d){const e=this.ids,f=d;for(;this.count[e[--d]]<=b&&-1!==d;);if(d++,d!==f){for(let a=f;a>d;a--){const b=e[a-1];e[a]=b,c[b]=a}e[d]=a,c[a]=d}}}return b};

View File

@@ -1 +0,0 @@
import FlexSearch from"./flexsearch.js";export function is_string(a){return"string"==typeof a}export function is_array(a){return a.constructor===Array}export function is_function(a){return"function"==typeof a}export function is_object(a){return"object"==typeof a}export function is_undefined(a){return"undefined"==typeof a}export function get_keys(a){return Object.keys(a)}export function create_object_array(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=create_object();return b}export function create_object(){return Object.create(null)}export function replace(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),!!a);c+=2);return a}export function regex(a){return new RegExp(a,"g")}export function collapse(a){let b="",c="";for(let d,e=0,f=a.length;e<f;e++)(d=a[e])!==c&&(b+=c=d);return b}export function filter(a,b){const c=a.length,d=[];for(let e=0,f=0;e<c;e++){const c=a[e];c&&!b[c]&&(d[f++]=c)}return d}FlexSearch.prototype.pipeline=function(a,b,c,d){if(a&&(b&&a&&(a=replace(a,b)),a&&this.matcher&&(a=replace(a,this.matcher)),this.stemmer&&1<a.length&&(a=replace(a,this.stemmer)),d&&1<a.length&&(a=collapse(a)),a&&(c||""===c))){const b=a.split(c);return this.filter?filter(b,this.filter):b}return a};

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";export const rtl=!0;export const tokenize="";export default{encode:encode,rtl:!0};const regex=/[\x00-\x7F]+/g;export function encode(a){return this.pipeline(a.replace(regex," "),!1," ",!1)}

View File

@@ -1 +0,0 @@
export const filter=["aber","als","am","an","auch","auf","aus","bei","bin","bis","bist","da","dadurch","daher","darum","das","da\xDF","dass","dein","deine","dem","den","der","des","dessen","deshalb","die","dies","dieser","dieses","doch","dort","du","durch","ein","eine","einem","einen","einer","eines","er","es","euer","eure","f\xFCr","hatte","hatten","hattest","hattet","hier","hinter","ich","ihr","ihre","im","in","ist","ja","jede","jedem","jeden","jeder","jedes","jener","jenes","jetzt","kann","kannst","k\xF6nnen","k\xF6nnt","machen","mein","meine","mit","mu\xDF","mu\xDFt","musst","m\xFCssen","m\xFC\xDFt","nach","nachdem","nein","nicht","nun","oder","seid","sein","seine","sich","sie","sind","soll","sollen","sollst","sollt","sonst","soweit","sowie","und","unser","unsere","unter","vom","von","vor","wann","warum","was","weiter","weitere","wenn","wer","werde","werden","werdet","weshalb","wie","wieder","wieso","wir","wird","wirst","wo","woher","wohin","zu","zum","zur","\xFCber"];export const stemmer={niss:"",isch:"",lich:"",heit:"",keit:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";export const rtl=!1;export const tokenize="strict";export default{encode:encode,rtl:!1,tokenize:"strict"};const regex=/[\x00-\x7F]+/g;export function encode(a){return this.pipeline(a.replace(regex,""),!1,"",!1)}

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1};const regex=/[\x00-\x7F]+/g;export function encode(a){return this.pipeline(a.replace(regex," "),!1," ",!1)}

View File

@@ -1 +0,0 @@
export const filter=["aber","als","am","an","auch","auf","aus","bei","bin","bis","bist","da","dadurch","daher","darum","das","da\xDF","dass","dein","deine","dem","den","der","des","dessen","deshalb","die","dies","dieser","dieses","doch","dort","du","durch","ein","eine","einem","einen","einer","eines","er","es","euer","eure","f\xFCr","hatte","hatten","hattest","hattet","hier","hinter","ich","ihr","ihre","im","in","ist","ja","jede","jedem","jeden","jeder","jedes","jener","jenes","jetzt","kann","kannst","k\xF6nnen","k\xF6nnt","machen","mein","meine","mit","mu\xDF","mu\xDFt","musst","m\xFCssen","m\xFC\xDFt","nach","nachdem","nein","nicht","nun","oder","seid","sein","seine","sich","sie","sind","soll","sollen","sollst","sollt","sonst","soweit","sowie","und","unser","unsere","unter","vom","von","vor","wann","warum","was","weiter","weitere","wenn","wer","werde","werden","werdet","weshalb","wie","wieder","wieso","wir","wird","wirst","wo","woher","wohin","zu","zum","zur","\xFCber"];export const stemmer={niss:"",isch:"",lich:"",heit:"",keit:"",ell:"",bar:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};

View File

@@ -1 +0,0 @@
export const filter=["a","about","above","after","again","against","all","also","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","both","but","by","can","cannot","can't","come","could","couldn't","did","didn't","do","does","doesn't","doing","dont","down","during","each","even","few","first","for","from","further","get","go","had","hadn't","has","hasn't","have","haven't","having","he","hed","her","here","here's","hers","herself","hes","him","himself","his","how","how's","i","id","if","ill","im","in","into","is","isn't","it","it's","itself","i've","just","know","let's","like","make","me","more","most","mustn't","my","myself","new","no","nor","not","now","of","off","on","once","only","or","other","ought","our","our's","ourselves","out","over","own","same","say","see","shan't","she","she'd","shell","shes","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","time","to","too","until","up","us","very","want","was","wasn't","way","we","wed","well","were","weren't","we've","what","what's","when","when's","where","where's","which","while","who","whom","who's","why","why's","will","with","won't","would","wouldn't","you","you'd","you'll","your","you're","your's","yourself","yourselves","you've"];export const stemmer={ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";import{regex,replace,collapse}from"../../common.js";import{encode as encode_simple}from"./simple.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1};const regex_ae=regex("ae"),regex_ai=regex("ai"),regex_ay=regex("ay"),regex_ey=regex("ey"),regex_oe=regex("oe"),regex_ue=regex("ue"),regex_ie=regex("ie"),regex_sz=regex("sz"),regex_zs=regex("zs"),regex_ck=regex("ck"),regex_cc=regex("cc"),regex_sh=regex("sh"),regex_th=regex("th"),regex_dt=regex("dt"),regex_ph=regex("ph"),regex_pf=regex("pf"),regex_ou=regex("ou"),regex_uo=regex("uo"),pairs=[regex_ae,"a",regex_ai,"ei",regex_ay,"ei",regex_ey,"ei",regex_oe,"o",regex_ue,"u",regex_ie,"i",regex_sz,"s",regex_zs,"s",regex_sh,"s",regex_ck,"k",regex_cc,"k",regex_th,"t",regex_dt,"t",regex_ph,"f",regex_pf,"f",regex_ou,"o",regex_uo,"u"];export function encode(a,b,c){return a&&(a=encode_simple(a,b||this).join(" "),2<a.length&&(a=replace(a,pairs)),!c&&(1<a.length&&(a=collapse(a)),a&&(a=a.split(" ")))),a}

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1};const regex_whitespace=/[\W_]+/;export function encode(a){return this.pipeline(a.toLowerCase(),!1,regex_whitespace,!1)}

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1};const regex_whitespace=/[\W_]+/;export function encode(a){return this.pipeline(a.toLowerCase(),!1,regex_whitespace,!1)}

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";import{regex,replace,collapse}from"../../common.js";import{encode as encode_advanced}from"./advanced.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1};const prefix="(?!\\b)",soundex_b=regex("(?!\\b)p"),soundex_s=regex("(?!\\b)z"),soundex_k=regex("(?!\\b)[cgq]"),soundex_m=regex("(?!\\b)n"),soundex_t=regex("(?!\\b)d"),soundex_f=regex("(?!\\b)[vw]"),regex_vowel=regex("(?!\\b)[aeiouy]"),pairs=[soundex_b,"b",soundex_s,"s",soundex_k,"k",soundex_m,"m",soundex_t,"t",soundex_f,"f",regex_vowel,""];export function encode(a){return a&&(a=encode_advanced(a,this,!0),1<a.length&&(a=replace(a,pairs)),1<a.length&&(a=collapse(a)),a&&(a=a.split(" "))),a}

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";import{regex}from"../../common.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1};const regex_whitespace=/[\W_]+/,regex_a=regex("[\xE0\xE1\xE2\xE3\xE4\xE5]"),regex_e=regex("[\xE8\xE9\xEA\xEB]"),regex_i=regex("[\xEC\xED\xEE\xEF]"),regex_o=regex("[\xF2\xF3\xF4\xF5\xF6\u0151]"),regex_u=regex("[\xF9\xFA\xFB\xFC\u0171]"),regex_y=regex("[\xFD\u0177\xFF]"),regex_n=regex("\xF1"),regex_c=regex("[\xE7c]"),regex_s=regex("\xDF"),regex_and=regex(" & "),pairs=[regex_a,"a",regex_e,"e",regex_i,"i",regex_o,"o",regex_u,"u",regex_y,"y",regex_n,"n",regex_c,"k",regex_s,"s",regex_and," and "];export function encode(a,b){return(b||this).pipeline(a.toLowerCase(),pairs,regex_whitespace,!1)}

View File

@@ -1 +0,0 @@
import FlexSearch from"../../flexsearch.js";export const rtl=!1;export const tokenize="strict";export default{encode:encode,rtl:!1,tokenize:"strict"};const regex_strip=/[^a-z]+/;export function encode(a){a=this.pipeline(a.toLowerCase(),!1,!1,!1);const b=[];if(a){const c=a.split(regex_strip),d=c.length;for(let e=0,f=0;e<d;e++)if((a=c[e])&&2<a.length&&(!this.filter||!this.filter[a])){let c=a[0],d=getCode(c);for(let b=1;b<a.length;b++){const e=getCode(a[b]);if(e!==d&&(c+=e,d=e,4===c.length))break}b[f++]=(c+"0000").substring(0,4)}}return b}function getCode(a){return"b"===a||"f"===a||"p"===a||"v"===a?1:"c"===a||"g"===a||"j"===a||"k"===a||"q"===a||"s"===a||"x"===a||"z"===a?2:"d"===a||"t"===a?3:"l"===a?4:"m"===a||"n"===a?5:"r"===a?6:""}

View File

@@ -1 +0,0 @@
export const filter=["a","about","above","after","again","against","all","also","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","both","but","by","can","cannot","can't","come","could","couldn't","did","didn't","do","does","doesn't","doing","dont","down","during","each","even","few","first","for","from","further","get","go","had","hadn't","has","hasn't","have","haven't","having","he","hed","her","here","here's","hers","herself","hes","him","himself","his","how","how's","i","id","if","ill","im","in","into","is","isn't","it","it's","itself","i've","just","know","let's","like","make","me","more","most","mustn't","my","myself","new","no","nor","not","now","of","off","on","once","only","or","other","ought","our","our's","ourselves","out","over","own","same","say","see","shan't","she","she'd","shell","shes","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","time","to","too","until","up","us","very","want","was","wasn't","way","we","wed","well","were","weren't","we've","what","what's","when","when's","where","where's","which","while","who","whom","who's","why","why's","will","with","won't","would","wouldn't","you","you'd","you'll","your","you're","your's","yourself","yourselves","you've"];export const stemmer={ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};

View File

@@ -1 +0,0 @@
Object.assign||(Object.assign=function(){const a=arguments,b=a.length,c=a[0];for(let d,e,f,g=1;g<b;g++){d=a[g],e=Object.keys(d),f=e.length;for(let a,b=0;b<f;b++)a=e[b],c[a]=d[a]}return c}),window.requestAnimationFrame||(window.requestAnimationFrame=window.setTimeout),window.cancelAnimationFrame||(window.cancelAnimationFrame=window.clearTimeout),window.Promise||(window.Promise=function(){function a(a){this.callback=null;const b=this;a(function(a){b.callback&&(b.callback(a),b.callback=null)})}return a.prototype.then=function(a){this.callback=a},a}());

View File

@@ -1 +0,0 @@
export default{memory:{charset:"latin:extra",threshold:0,resolution:1},speed:{threshold:1,resolution:3,depth:2},match:{charset:"latin:extra",tokenize:"full",threshold:1,resolution:3},score:{charset:"latin:extra",threshold:1,resolution:9,depth:4},balance:{charset:"latin:balance",threshold:0,resolution:3,depth:3},fast:{threshold:8,resolution:9,depth:1}};

View File

@@ -1 +0,0 @@
const profiles=[];let profile;export function profile_start(a){(profile[a]||(profile[a]={time:0,count:0,ops:0,nano:0})).ops=("undefined"==typeof performance?Date:performance).now()}export function profile_end(a){const b=profile[a];b.time+=("undefined"==typeof performance?Date:performance).now()-b.ops,b.count++,b.ops=1000/b.time*b.count,b.micro=1000*(b.time/b.count)}

View File

@@ -1 +0,0 @@
import FlexSearch from"./flexsearch.js";import{is_undefined,is_object,get_keys}from"./common.js";FlexSearch.prototype.export=function(a){const b=!a||is_undefined(a.serialize)||a.serialize;let c;if(this.doc){const b=!a||is_undefined(a.doc)||a.doc,d=!a||is_undefined(a.index)||a.index;c=[];let e=0;if(d)for(const a=this.doc.keys;e<a.length;e++){const b=this.doc.index[a[e]];c[e]=[b._map,b._ctx,get_keys(b._ids)]}b&&(c[e]=this._doc)}else c=[this._map,this._ctx,get_keys(this._ids)];return b&&(c=JSON.stringify(c)),c},FlexSearch.prototype.import=function(a,b){const c=!b||is_undefined(b.serialize)||b.serialize;c&&(a=JSON.parse(a));const d={};if(this.doc){const c=!b||is_undefined(b.doc)||b.doc,e=!b||is_undefined(b.index)||b.index;let f=0;if(e){const b=this.doc.keys,c=b.length,e=a[0][2];for(;f<e.length;f++)d[e[f]]=1;for(f=0;f<c;f++){const c=this.doc.index[b[f]],e=a[f];e&&(c._map=e[0],c._ctx=e[1],c._ids=d)}}c&&(this._doc=is_object(c)?c:a[f])}else{const b=a[2];for(let a=0;a<b.length;a++)d[b[a]]=1;this._map=a[0],this._ctx=a[1],this._ids=d}};

View File

@@ -1 +0,0 @@
import FlexSearch from"./flexsearch.js";import{get_keys,is_function,is_object,is_undefined}from"./common.js";FlexSearch.prototype.find=function(a,b){return this.where(a,b,1)[0]||null},FlexSearch.prototype.where=function(a,b,c,d){const e=this._doc,f=[];let g,h,j,k,l,m=0;if(is_object(a)){if(c||(c=b),g=get_keys(a),h=g.length,j=!1,1===h&&"id"===g[0])return[e[a.id]];const f=this._tags;if(f&&!d)for(let b=0;b<f.length;b++){const c=f[b],d=a[c];if(!is_undefined(d)){if(l=this._tag[c]["@"+d],0==--h)return l;g.splice(g.indexOf(c),1),delete a[c];break}}k=Array(h);for(let a=0;a<h;a++)k[a]=g[a].split(":")}else{if(is_function(a)){const b=d||get_keys(e),c=b.length;for(let d=0;d<c;d++){const c=e[b[d]];a(c)&&(f[m++]=c)}return f}if(is_undefined(b))return[e[a]];if("id"===a)return[e[b]];g=[a],h=1,k=[a.split(":")],j=!0}const n=l||d||get_keys(e),o=n.length;for(let i=0;i<o;i++){const d=l?n[i]:e[n[i]];let o=!0;for(let c=0;c<h;c++){j||(b=a[g[c]]);const e=k[c],f=e.length;let h=d;if(1<f)for(let a=0;a<f;a++)h=h[e[a]];else h=h[e[0]];if(h!==b){o=!1;break}}if(o&&(f[m++]=d,c&&m===c))break}return f};

View File

@@ -1 +0,0 @@
import FlexSearch from"./flexsearch.js";const worker_stack={},inline_supported="undefined"!=typeof Blob&&"undefined"!=typeof URL&&URL.createObjectURL;export default function init(a,b,c,d,e){let f=a;const g=inline_supported?URL.createObjectURL(new Blob([(RELEASE?"":"var RELEASE = '"+RELEASE+"';var DEBUG = false;var PROFILER = false;var SUPPORT_PRESET = true;var SUPPORT_SUGGESTION = true;var SUPPORT_ENCODER = true;var SUPPORT_CACHE = true;var SUPPORT_ASYNC = true;var SUPPORT_SERIALIZE = true;var SUPPORT_INFO = true;var SUPPORT_DOCUMENT = true;var SUPPORT_WHERE = true;var SUPPORT_PAGINATION = true;var SUPPORT_OPERATOR = true;var SUPPORT_CALLBACK = true;var SUPPORT_WORKER = true;")+"("+c.toString()+")()"],{type:"text/javascript"})):f+(RELEASE?"."+RELEASE:"")+".js";return f+="-"+b,worker_stack[f]||(worker_stack[f]=[]),worker_stack[f][e]=new Worker(g),worker_stack[f][e].onmessage=d,!1,worker_stack[f][e]}function worker_module(){let a,b;self.onmessage=function(c){const d=c.data;if(d)if(d.search){const c=b.search(d.content,d.threshold?{limit:d.limit,threshold:d.threshold,where:d.where}:d.limit);self.postMessage({id:a,content:d.content,limit:d.limit,result:c})}else if(d.add)b.add(d.id,d.content);else if(d.update)b.update(d.id,d.content);else if(d.remove)b.remove(d.id);else if(d.clear)b.clear();else if(d.info){const c=b.info();c.worker=a,console.log(c)}else d.register&&(a=d.id,d.options.cache=!1,d.options.async=!1,d.options.worker=!1,b=new Function(d.register.substring(d.register.indexOf("{")+1,d.register.lastIndexOf("}")))(),b=new b(d.options))}}export function addWorker(a,b,c,d){const e=init("flexsearch","id"+a,worker_module,function(a){const b=a.data;b&&b.result&&d(b.id,b.content,b.result,b.limit,b.where,b.cursor,b.suggest)},b),f=FlexSearch.toString();return c.id=b,e.postMessage({register:f,options:c,id:b}),e}FlexSearch.prototype.worker_handler=function(a,b,c,d){return this._task_completed!==this.worker&&(this._task_result=this._task_result.concat(c),this._task_completed++,d&&this._task_result.length>=d&&(this._task_completed=this.worker),this._task_completed===this.worker&&(this.cache&&this._cache.set(b,this._task_result),this._current_callback&&this._current_callback(this._task_result))),this};

View File

@@ -40,6 +40,27 @@ document.search(text, limit, options);
document.search(options);
```
## Source Code
Source Code v0.7.0-pre-alpha available here:<br>
<a href="https://github.com/nextapps-de/flexsearch/tree/0.7.0/src">https://github.com/nextapps-de/flexsearch/tree/0.7.0/src</a>
What is not included yet but comes soon?
- Worker (almost done)
- Pagination (not implemented yet)
- Export/Import (not implemented yet)
- Engines (almost done)
- Tags (almost done)
- Bundles: Light, Compact, Full (almost done)
- Test Automation (needs to be migrated)
- Benchmark Suite (almost done)
What will be dropped?
- Where-Clause
- Index Information `index.info()`
## Builtin Profiles
1. `memory` (primary optimize for memory)
@@ -425,11 +446,90 @@ index.search({
#### Complex Documents
You need to follow 2 rules for your documents:
1. The document cannot start with an Array at the root index. This will introduce sequential data and isn't supported yet. See below for a workaround for such data.
```js
[ // <-- not allowed as document start!
{
"id": 0,
"title": "title"
}
]
```
2. The id can't be nested inside an array (also none of the parent fields can't be an array). This will introduce sequential data and isn't supported yet. See below for a workaround for such data.
```js
{
"records": [ // <-- not allowed when id lives inside!
{
"id": 0,
"title": "title"
}
]
}
```
Here an example for a supported complex document:
```json
[
{
"meta": {
"tag": "cat",
"id": 0
},
"contents": [
{
"body": {
"title": "some title",
"footer": "some text"
},
"keywords": ["some", "key", "words"]
},
{
"body": {
"title": "some title",
"footer": "some text"
},
"keywords": ["some", "key", "words"]
}
]
}
```
The corresponding document descriptor (when all fields should be indexed) looks like:
```js
const index = new Document({
key: "meta:id",
tag: "meta:tag",
doc: [
"contents[]:body:title",
"contents[]:body:footer",
"contents[]:keywords"
]
});
```
Again, when searching you have to use the same colon-separated-string from your field definition.
```js
index.search(query, {
field: "contents[]:body:title"
});
```
#### Not Supported Documents (Sequential Data)
This example breaks both rules from above:
```js
[ // <-- not allowed as document start!
{
"tag": "cat",
"records": [
"records": [ // <-- not allowed when id lives inside!
{
"id": 0,
"body": {
@@ -451,33 +551,57 @@ index.search({
]
```
Please notice this complex structure has its records as nested array which also includes the `key`.
You need to apply some kind of structure normalization.
A workaround to such a data structure looks like this:
```js
const index = new Document({
key: "records[]:id",
key: "record:id",
tag: "tag",
doc: [
"records[]:body:title",
"records[]:body:footer",
"records[]:body:keywords"
"record:body:title",
"record:body:footer",
"record:body:keywords"
]
});
```
Again, when searching you have to use the same colon-separated-string from your field definition.
function add(sequential_data){
```js
index.search(query, {
field: "records[]:body:title"
for(let x = 0, data; x < sequential_data.length; x++){
data = sequential_data[x];
for(let y = 0, record; y < data.records.length; y++){
record = data.records[y];
index.add({
tag: data.tag,
id: record.id,
record: record
});
}
}
}
// now just use add() helper method as usual:
add([{
// sequential structured data
// take the data example above
}]);
```
You can skip the first loop when your document data has just one index as the outer array.
#### Join / Append Arrays
On the complex example above, the field `keywords` is an array but here the markup did not have brackets like `keywords[]`. That will also detect the array but instead of appending each entry to a new context, the array will be joined into on large string and added to the index.
The difference of both kinds of adding array contents is the relevance when searching. When adding each item from an array via append to its own context with the syntax `field[]`, then the relevance of the last entry concurrent with the first entry. When you left the brackets in the notation, it will join the array to one string. Here the first entry has the highest relevance, whereas the last entry has the lowest relevance.
The difference of both kinds of adding array contents is the relevance when searching. When adding each item of an array via `append()` to its own context by using the syntax `field[]`, then the relevance of the last entry concurrent with the first entry. When you left the brackets in the notation, it will join the array to one whitespace-separated string. Here the first entry has the highest relevance, whereas the last entry has the lowest relevance.
So assuming the keyword from the example above are pre-sorted by relevance to its popularity, then you want to keep this order (information of relevance). For this purpose do not add brackets to the notation. Otherwise, it would take the entries in a new scoring context (the old order is getting lost).
@@ -1108,21 +1232,21 @@ FlexSearch provides you many parameters you can use to adjust the optimal balanc
<td>+1 (per level)</td>
<td>+1 (per level)</td>
<td>0</td>
<td>+3 (per level)</td>
<td>+2 (per level)</td>
</tr>
<tr></tr>
<tr>
<td>threshold</td>
<td>-4 (per level)</td>
<td>+2 (per level)</td>
<td>-3 (per level)</td>
<td>+2 (per level)</td>
<td>0</td>
</tr>
<tr></tr>
<tr>
<td>depth</td>
<td>+4 (per level)</td>
<td>+2 (per level)</td>
<td>-1 (per level)</td>
<td>-10 + depth</td>
<td>+10</td>
</tr>
@@ -1132,15 +1256,15 @@ FlexSearch provides you many parameters you can use to adjust the optimal balanc
<td>-2 (per level)</td>
<td>+2 (per level)</td>
<td>-3 (per level)</td>
<td>+3 (per level)</td>
<td>+2 (per level)</td>
</tr>
<tr></tr>
<tr>
<td>bidirectional</td>
<td>-2</td>
<td>0</td>
<td>+3 (per level)</td>
<td>0</td>
<td>+3</td>
<td>-1</td>
</tr>
<tr></tr>
<tr>
@@ -1153,10 +1277,10 @@ FlexSearch provides you many parameters you can use to adjust the optimal balanc
<tr></tr>
<tr>
<td>optimize: "memory"</td>
<td>-5</td>
<td>-7</td>
<td>-1</td>
<td>0</td>
<td>-1</td>
<td>-3</td>
</tr>
<tr></tr>
<tr>
@@ -1241,7 +1365,7 @@ FlexSearch provides you many parameters you can use to adjust the optimal balanc
<tr></tr>
<tr>
<td>store: [fields]</td>
<td>+2 (per field)</td>
<td>+1 (per field)</td>
<td>0</td>
<td>0</td>
<td>0</td>

View File

@@ -21,7 +21,6 @@
"browser": "dist/flexsearch.min.js",
"types": "index.d.ts",
"preferGlobal": false,
"bin": {},
"repository": {
"type": "git",
"url": "https://github.com/nextapps-de/flexsearch.git"
@@ -53,7 +52,6 @@
"LICENSE"
],
"readme": "README.md",
"dependencies": {},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-conditional-compile": "0.0.5",
@@ -72,6 +70,6 @@
"babel-plugin-transform-property-literals": "^6.9.4",
"babel-plugin-transform-simplify-comparison-operators": "^6.9.4",
"babel-plugin-transform-undefined-to-void": "^6.9.4",
"google-closure-compiler": "^20191027.0.0"
"google-closure-compiler": "^20210505.0.0"
}
}

107
src/async.js Normal file
View File

@@ -0,0 +1,107 @@
import Index from "./index.js";
import Document from "./document.js";
import { promise as Promise } from "./polyfill.js";
/**
* @param {Function=} callback
*/
export function addAsync(id, content, callback){
return caller.call(
/** @type {Document|Index} */ (this),
/** @type {Document|Index} */ (this).add,
arguments
);
}
/**
* @param {Function=} callback
*/
export function appendAsync(id, content, callback){
return caller.call(
/** @type {Document|Index} */ (this),
/** @type {Document|Index} */ (this).append,
arguments
);
}
/**
* @param {!string} query
* @param {number|Object|Function=} options
* @param {Function=} callback
*/
export function searchAsync(query, options, callback){
return caller.call(
/** @type {Document|Index} */ (this),
/** @type {Document|Index} */ (this).search,
arguments
);
}
/**
* @param {Function=} callback
*/
export function updateAsync(id, content, callback){
return caller.call(
/** @type {Document|Index} */ (this),
/** @type {Document|Index} */ (this).update,
arguments
);
}
/**
* @param {Function=} callback
*/
export function removeAsync(id, callback){
return caller.call(
/** @type {Document|Index} */ (this),
/** @type {Document|Index} */ (this).remove,
arguments
);
}
function caller(method, args){
let callback;
for(let i = 0; i < args.length; i++){
if(typeof args[i] === "function"){
callback = args[i];
delete args[i];
break;
}
}
const self = /** @type {Document|Index} */ (this);
const promise = new Promise(function(resolve){
// Promises are bullshit, they will block the main thread
setTimeout(function(){
resolve(method.apply(self, args));
});
});
if(callback){
promise.then(callback);
return this;
}
else{
return promise;
}
}

View File

@@ -1,102 +0,0 @@
import { default as FlexSearch, global_charset, global_lang } from "./flexsearch.js";
import charset_latin_advanced from "./lang/latin/advanced.js";
import charset_latin_balance from "./lang/latin/balance.js";
import charset_latin_default from "./lang/latin/default.js";
import charset_latin_extra from "./lang/latin/extra.js";
import charset_latin_simple from "./lang/latin/simple.js";
import charset_latin_soundex from "./lang/latin/soundex.js";
import charset_arabic_default from "./lang/arabic/default.js";
import charset_cjk_default from "./lang/cjk/default.js";
import charset_cyrillic_default from "./lang/cyrillic/default.js";
import lang_de from "./lang/de.js";
import lang_en from "./lang/en.js";
import lang_at from "./lang/at.js";
import lang_us from "./lang/us.js";
import "./export.js";
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "latin") || (SUPPORT_ENCODER.indexOf("latin:advanced") !== -1)))){
global_charset["latin:advanced"] = charset_latin_advanced;
}
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "latin") || (SUPPORT_ENCODER.indexOf("latin:balance") !== -1)))){
global_charset["latin:balance"] = charset_latin_balance;
}
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "latin") || (SUPPORT_ENCODER.indexOf("latin:default") !== -1)))){
global_charset["latin:default"] = charset_latin_default;
}
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "latin") || (SUPPORT_ENCODER.indexOf("latin:extra") !== -1)))){
global_charset["latin:extra"] = charset_latin_extra;
}
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "latin") || (SUPPORT_ENCODER.indexOf("latin:simple") !== -1)))){
global_charset["latin:simple"] = charset_latin_simple;
}
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "latin") || (SUPPORT_ENCODER.indexOf("latin:soundex") !== -1)))){
global_charset["latin:soundex"] = charset_latin_soundex;
}
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "arabic") || (SUPPORT_ENCODER.indexOf("arabic:default") !== -1)))){
global_charset["arabic:default"] = charset_arabic_default;
}
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "cjk") || (SUPPORT_ENCODER.indexOf("cjk:default") !== -1)))){
global_charset["cjk:default"] = charset_cjk_default;
}
if(SUPPORT_ENCODER === true || (SUPPORT_ENCODER && ((SUPPORT_ENCODER === "cyrillic") || (SUPPORT_ENCODER.indexOf("cyrillic:default") !== -1)))){
global_charset["cyrillic:default"] = charset_cyrillic_default;
}
if(SUPPORT_LANG === true || (SUPPORT_LANG && SUPPORT_LANG.indexOf("de") !== -1)){
global_lang["de"] = lang_de;
}
if(SUPPORT_LANG === true || (SUPPORT_LANG && SUPPORT_LANG.indexOf("en") !== -1)){
global_lang["en"] = lang_en;
}
if(SUPPORT_LANG === true || (SUPPORT_LANG && SUPPORT_LANG.indexOf("at") !== -1)){
global_lang["at"] = lang_at;
}
if(SUPPORT_LANG === true || (SUPPORT_LANG && SUPPORT_LANG.indexOf("us") !== -1)){
global_lang["us"] = lang_us;
}
(function(){
const name = "FlexSearch";
const root = this || window;
let prop;
// AMD (RequireJS)
if((prop = root["define"]) && prop["amd"]){
prop([], function(){
return FlexSearch;
});
}
// CommonJS (Node.js)
// else if(typeof exports === "object"){
//
// /** @export */
// module.exports = factory;
// }
else if(typeof root["exports"] === "object"){
/** @export */
root["module"].exports = FlexSearch;
}
// Global (window)
else{
root[name] = FlexSearch;
}
}());

View File

@@ -1,66 +1,128 @@
import { is_undefined, create_object } from "./common.js";
import Index from "./index.js";
import Document from "./index.js";
import { create_object } from "./common.js";
/**
* @param {boolean|number=} limit
* @constructor
*/
export default function CacheClass(limit){
this.clear();
function CacheClass(limit){
/** @private */
this.limit = (limit !== true) && limit;
}
CacheClass.prototype.clear = function(){
/** @private */
this.cache = create_object();
/** @private */
this.count = create_object();
/** @private */
this.index = create_object();
/** @private */
this.ids = [];
};
this.queue = [];
//this.clear();
}
export default CacheClass;
/**
* @param {!string} query
* @param {number|Object=} limit
* @param {Object=} options
* @returns {Array<number|string>}
*/
export function searchCache(query, limit, options){
if(typeof query === "object"){
query = query["query"];
}
let cache = /** @type {Document|Index} */ (this).cache.get(query);
if(!cache){
cache = /** @type {Document|Index} */ (this).search(query, limit, options);
/** @type {Document|Index} */ (this).cache.set(query, cache);
}
return cache;
}
// CacheClass.prototype.clear = function(){
//
// /** @private */
// this.cache = create_object();
//
// /** @private */
// this.queue = [];
// };
CacheClass.prototype.set = function(key, value){
if(this.limit && is_undefined(this.cache[key])){
if(!this.cache[key]){
let length = this.ids.length;
// it is just a shame that native function array.shift() performs so bad
// const length = this.queue.length;
//
// this.queue[length] = key;
//
// if(length === this.limit){
//
// delete this.cache[this.queue.shift()];
// }
// the same bad performance
// this.queue.unshift(key);
//
// if(this.queue.length === this.limit){
//
// this.queue.pop();
// }
// fast implementation variant
// let length = this.queue.length;
//
// if(length === this.limit){
//
// length--;
//
// delete this.cache[this.queue[0]];
//
// for(let x = 0; x < length; x++){
//
// this.queue[x] = this.queue[x + 1];
// }
// }
//
// this.queue[length] = key;
// current fastest implementation variant
// theoretically that should not perform better compared to the example above
let length = this.queue.length;
if(length === this.limit){
length--;
const last_id = this.ids[length];
delete this.cache[last_id];
delete this.count[last_id];
delete this.index[last_id];
}
this.ids[length] = key;
this.index[key] = length;
this.count[key] = -1;
this.cache[key] = value;
// TODO: remove extra call
// shift up counter +1
this.get(key);
delete this.cache[this.queue[length - 1]];
}
else{
this.cache[key] = value;
length++;
}
};
/**
* Note: It is better to have the complexity when fetching the cache:
*/
for(let x = length - 1; x > 0; x--){
this.queue[x] = this.queue[x - 1];
}
this.queue[0] = key;
}
this.cache[key] = value;
};
CacheClass.prototype.get = function(key){
@@ -68,44 +130,40 @@ CacheClass.prototype.get = function(key){
if(this.limit && cache){
const count = ++this.count[key];
const index = this.index;
let current_index = index[key];
// probably the indexOf() method performs faster when matched content is on front (left-to-right)
// using lastIndexOf() does not help, it performs almost slower
if(current_index > 0){
const pos = this.queue.indexOf(key);
const ids = this.ids;
const old_index = current_index;
// if(pos < this.queue.length - 1){
//
// const tmp = this.queue[pos];
// this.queue[pos] = this.queue[pos + 1];
// this.queue[pos + 1] = tmp;
// }
// forward pointer
while(this.count[ids[--current_index]] <= count){
if(pos){
if(current_index === -1){
break;
}
}
// move pointer back
current_index++;
if(current_index !== old_index){
// copy values from predecessors
for(let i = old_index; i > current_index; i--) {
const tmp = ids[i - 1];
ids[i] = tmp;
index[tmp] = i;
}
// push new value on top
ids[current_index] = key;
index[key] = current_index;
}
const tmp = this.queue[pos - 1];
this.queue[pos - 1] = this.queue[pos];
this.queue[pos] = tmp;
}
}
return cache;
};
CacheClass.prototype.del = function(id){
for(let i = 0, item, key; i < this.queue.length; i++){
key = this.queue[i];
item = this.cache[key];
if(item.indexOf(id) !== -1){
this.queue.splice(i--, 1);
delete this.cache[key];
}
}
};

View File

@@ -1,54 +1,4 @@
import FlexSearch from "./flexsearch.js";
/**
* @param {*} val
* @returns {boolean}
*/
export function is_string(val){
return typeof val === "string";
}
/**
* @param {*} val
* @returns {boolean}
*/
export function is_array(val){
return val.constructor === Array;
}
/**
* @param {*} val
* @returns {boolean}
*/
export function is_function(val){
return typeof val === "function";
}
/**
* @param {*} val
* @returns {boolean}
*/
export function is_object(val){
return typeof val === "object";
}
/**
* @param {*} val
* @returns {boolean}
*/
export function is_undefined(val){
return typeof val === "undefined";
}
//import FlexSearch from "./flexsearch.js";
/**
* @param {!Object} obj
@@ -61,9 +11,8 @@ export function get_keys(obj){
}
/**
* https://jsperf.com/comparison-object-index-type
* @param {!number} count
* @returns {Object|Array<Object>}
* @returns {Array<Object>}
*/
export function create_object_array(count){
@@ -78,207 +27,29 @@ export function create_object_array(count){
return array;
}
export function create_arrays(count){
const array = new Array(count);
for(let i = 0; i < count; i++){
array[i] = [];
}
return array;
}
export function create_object(){
return Object.create(null);
}
/**
* @param {!string} str
* @param {Array} regexp
* @returns {string}
*/
export function concat(arrays){
export function replace(str, regexp){
for(let i = 0, len = regexp.length; i < len; i += 2){
str = str.replace(regexp[i], regexp[i + 1]);
if(!str){
break;
}
return [].concat.apply([], arrays);
}
return str;
export function sort_by_length_down(a, b){
return b.length - a.length;
}
/**
* @param {!string} str
* @returns {RegExp}
*/
export function regex(str){
return new RegExp(str, "g");
}
/**
* Regex: replace(/(?:(\w)(?:\1)*)/g, "$1")
* @param {!string} string
* @returns {string}
*/
export function collapse(string){
let final = "", prev = "";
for(let i = 0, len = string.length, char; i < len; i++){
if((char = string[i]) !== prev){
final += (prev = char);
}
}
return final;
}
// TODO using fast-swap
export function filter(words, map){
const length = words.length;
const filtered = [];
for(let i = 0, count = 0; i < length; i++){
const word = words[i];
if(word && !map[word]){
filtered[count++] = word;
}
}
return filtered;
}
/**
* @param {!string} str
* @param {boolean|Array<string|RegExp>=} normalize
* @param {boolean|string|RegExp=} split
* @param {boolean=} _collapse
* @returns {string|Array<string>}
*/
FlexSearch.prototype.pipeline = function(str, normalize, split, _collapse){
if(str){
if(normalize && str){
str = replace(str, /** @type {Array<string|RegExp>} */ (normalize));
}
if(str && this.matcher){
str = replace(str, this.matcher);
}
if(this.stemmer && str.length > 1){
str = replace(str, this.stemmer);
}
if(_collapse && str.length > 1){
str = collapse(str);
}
if(str){
if(split || (split === "")){
const words = str.split(/** @type {string|RegExp} */ (split));
return this.filter ? filter(words, this.filter) : words;
}
}
}
return str;
};
// export function pipeline(str, normalize, matcher, stemmer, split, _filter, _collapse){
//
// if(str){
//
// if(normalize && str){
//
// str = replace(str, normalize);
// }
//
// if(matcher && str){
//
// str = replace(str, matcher);
// }
//
// if(stemmer && str.length > 1){
//
// str = replace(str, stemmer);
// }
//
// if(_collapse && str.length > 1){
//
// str = collapse(str);
// }
//
// if(str){
//
// if(split !== false){
//
// str = str.split(split);
//
// if(_filter){
//
// str = filter(str, _filter);
// }
// }
// }
// }
//
// return str;
// }
// const chars = {a:1, e:1, i:1, o:1, u:1, y:1};
//
// function collapse_repeating_chars(string){
//
// let collapsed_string = "",
// char_prev = "",
// char_next = "";
//
// for(let i = 0; i < string.length; i++){
//
// const char = string[i];
//
// if(char !== char_prev){
//
// if(i && (char === "h")){
//
// if((chars[char_prev] && chars[char_next]) || (char_prev === " ")){
//
// collapsed_string += char;
// }
// }
// else{
//
// collapsed_string += char;
// }
// }
//
// char_next = (
//
// (i === (string.length - 1)) ?
//
// ""
// :
// string[i + 1]
// );
//
// char_prev = char;
// }
//
// return collapsed_string;
// }

View File

@@ -1,53 +1,53 @@
/** @define {string} */
const RELEASE = "browser";
export const RELEASE = "browser";
/** @define {boolean} */
const DEBUG = true;
export const DEBUG = true;
/** @define {boolean} */
const PROFILER = false;
export const PROFILER = false;
/** @define {boolean} */
const POLYFILL = true;
export const POLYFILL = true;
/** @define {boolean} */
const SUPPORT_WORKER = true;
export const SUPPORT_WORKER = true;
/** @define {boolean|string} */
const SUPPORT_ENCODER = true;
export const SUPPORT_ENCODER = true;
/** @define {boolean|string} */
const SUPPORT_LANG = true;
export const SUPPORT_LANG = true;
/** @define {boolean} */
const SUPPORT_CACHE = true;
export const SUPPORT_CACHE = true;
/** @define {boolean} */
const SUPPORT_ASYNC = true;
export const SUPPORT_ASYNC = true;
/** @define {boolean} */
const SUPPORT_PRESET = true;
export const SUPPORT_PRESET = true;
/** @define {boolean} */
const SUPPORT_SUGGESTION = true;
export const SUPPORT_SUGGESTION = true;
/** @define {boolean} */
const SUPPORT_SERIALIZE = true;
export const SUPPORT_SERIALIZE = true;
/** @define {boolean} */
const SUPPORT_INFO = true;
export const SUPPORT_INFO = true;
/** @define {boolean} */
const SUPPORT_DOCUMENT = true;
export const SUPPORT_DOCUMENT = true;
/** @define {boolean} */
const SUPPORT_WHERE = true;
export const SUPPORT_WHERE = true;
/** @define {boolean} */
const SUPPORT_PAGINATION = true;
export const SUPPORT_PAGINATION = true;
/** @define {boolean} */
const SUPPORT_OPERATOR = true;
export const SUPPORT_OPERATOR = true;
/** @define {boolean} */
const SUPPORT_CALLBACK = true;
export const SUPPORT_CALLBACK = true;

523
src/document.js Normal file
View File

@@ -0,0 +1,523 @@
/**!
* FlexSearch.js
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
import { SUPPORT_ASYNC, SUPPORT_CACHE } from "./config.js";
import { create_object } from "./common.js";
import Index from "./index.js";
import { addAsync, appendAsync, removeAsync, searchAsync, updateAsync } from "./async.js";
import Cache, { searchCache } from "./cache.js";
/**
* @param {Object=} options
* @return {Document}
* @constructor
*/
function Document(options){
if(!(this instanceof Document)) {
return new Document(options);
}
let opt;
options || (options = {});
this.register = create_object();
this.store = (opt = options["store"]) && create_object();
this.storetree = opt && (opt !== true) && [];
this.markup = [];
this.key = ((opt = options["key"]) && parse_tree(opt, this.markup)) || "id";
this.tree = [];
this.field = [];
if(SUPPORT_CACHE){
this.cache = (opt = options["cache"]) && new Cache(opt);
options["cache"] = false;
}
/** @private */
this.index = parse_descriptor.call(this, options);
}
export default Document;
/**
* @this Document
*/
function parse_descriptor(options){
const index = create_object();
let field = options["doc"]; // options["document"]
let field_options;
if(typeof field === "string"){
field = [field];
}
else if(field.constructor !== Array){
field_options = field;
field = Object.keys(field);
}
for(let i = 0, key, item; i < field.length; i++){
key = field[i];
if(field_options){
item = field_options[key];
item = typeof item === "object" ? Object.assign({}, options, item) : options;
}
else{
item = options;
}
index[key] = new Index(item, this.register);
this.tree[i] = parse_tree(key, this.markup);
this.field[i] = key;
}
if(this.storetree){
let store = options["store"];
if(typeof store === "string"){
store = [store];
}
for(let i = 0; i < store.length; i++){
this.storetree[i] = parse_tree(store[i], this.markup);
}
}
return index;
}
function parse_tree(key, markup){
const tree = key.split(":");
let count = 0;
for(let i = 0; i < tree.length; i++){
key = tree[i];
if(key.indexOf("[]") >= 0){
key = key.substring(0, key.length - 2);
if(key){
markup[count] = true;
}
}
if(key){
tree[count++] = key;
}
}
if(count < tree.length){
tree.length = count;
}
return count > 1 ? tree : tree[0];
}
function get_id(obj, tree){
if(typeof tree === "string"){
obj = obj[tree];
}
else{
for(let i = 0; obj && (i < tree.length); i++){
obj = obj[tree[i]];
}
}
return obj;
}
function store_value(obj, store, tree, pos, key){
obj = obj[key];
// reached target field
if(pos === (tree.length - 1)){
// store target value
store[key] = obj;
}
else if(obj){
if(obj.constructor === Array){
store = store[key] = new Array(obj.length);
for(let i = 0; i < obj.length; i++){
// do not increase pos (an array is not a field)
store_value(obj, store, tree, pos, i);
}
}
else{
store = store[key] || (store[key] = create_object());
key = tree[++pos];
store_value(obj, store, tree, pos, key);
}
}
}
function add_index(obj, tree, markup, pos, index, id, key, _append){
obj = obj[key];
// reached target field
if(pos === (tree.length - 1)){
// handle target value
if(obj.constructor === Array){
if(markup[pos]){
for(let i = 0; i < obj.length; i++){
index.add(id, obj[i], true);
}
return;
}
obj = obj.join(" ");
}
index.add(id, obj, _append);
}
else if(obj){
if(obj.constructor === Array){
for(let i = 0; i < obj.length; i++){
// do not increase index, an array is not a field
add_index(obj, tree, markup, pos, index, id, i, _append);
}
}
else{
key = tree[++pos];
add_index(obj, tree, markup, pos, index, id, key, _append);
}
}
}
/**
*
* @param id
* @param content
* @param {boolean=} _append
* @returns {Document}
*/
Document.prototype.add = function(id, content, _append){
if(typeof id === "object"){
content = id;
id = get_id(content, this.key);
}
if(content && (id || (id === 0))){
if(this.register[id]){
return this.update(id, content);
}
for(let i = 0, tree, field; i < this.field.length; i++){
field = this.field[i];
tree = this.tree[i];
if(typeof tree === "string"){
tree = [tree];
}
add_index(content, tree, this.markup, 0, this.index[field], id, tree[0], _append);
}
if(this.store){
let store;
if(this.storetree){
store = create_object();
for(let i = 0, tree; i < this.storetree.length; i++){
tree = this.storetree[i];
if(typeof tree === "string"){
store[tree] = content[tree];
}
else{
store_value(content, store, tree, 0, tree[0]);
}
}
}
this.store[id] = store || content;
}
}
return this;
};
Document.prototype.append = function(id, content){
return this.add(id, content, true);
};
Document.prototype.update = function(id, content){
return this.remove(id).add(id, content);
};
Document.prototype.remove = function(id){
if(typeof id === "object"){
id = id[this.key];
}
if(this.register[id]){
for(let i = 0; i < this.field.length; i++){
this.index[this.field[i]].remove(id, true);
}
if(this.store){
delete this.store[id];
}
delete this.register[id];
}
return this;
};
Document.prototype.search = function(query, limit, options){
if(typeof query === "object"){
options = query;
query = options["query"];
}
else if(typeof limit === "object"){
options = limit;
}
let result = [];
let pluck, enrich;
let field, field_options, bool, count = 0;
if(options){
pluck = options["pluck"];
field = pluck || options["field"];
enrich = options["enrich"];
bool = options["bool"] === "and";
limit = options["limit"];
}
if(field){
if(typeof field === "string"){
field = [field];
}
else if(field.constructor !== Array){
field_options = field;
field = Object.keys(field);
}
}
else{
field = this.field;
}
bool = bool && (field.length > 1);
for(let i = 0, res, key, item; i < field.length; i++){
key = field[i];
if(field_options){
item = field_options[key];
// inherit options?
//item = typeof item === "object" ? Object.assign({}, options, item) : options;
}
else{
item = options;
}
res = this.index[key].search(query, limit, item);
if(bool){
if(!res.length){
// fast path optimization
return [];
}
// add a pseudo relevance index for the intersection
// used when squash the results on boolean "and"
//res = [res];
}
count += res.length;
result[i] = res;
}
if(!count){
// fast path optimization
return [];
}
// squash the results on boolean "and"?
// if(bool){
//
// limit || (limit = 100);
//
// if(enrich && this.store){
//
// return apply_enrich.call(this, intersect(result, limit));
// }
//
// return intersect(result, limit);
// }
if(pluck && (!enrich || !this.store)){
// fast path optimization
return result[0];
}
for(let i = 0, res, key; i < field.length; i++){
key = field[i];
res = result[i];
if(enrich && this.store){
res = apply_enrich.call(this, res);
}
if(pluck){
return res;
}
result[i] = {
"field": key,
"result": res
};
}
return result;
};
/**
* @this Document
*/
function apply_enrich(res){
const arr = new Array(res.length);
for(let x = 0, id; x < res.length; x++){
id = res[x];
arr[x] = {
"key": id,
"doc": this.store[id]
};
}
return arr;
}
Document.prototype.get = function(id){
return this.store[id];
};
Document.prototype.set = function(id, data){
this.store[id] = data;
return this;
};
Document.prototype.contain = function(id){
return !!this.register[id];
};
if(SUPPORT_CACHE){
Document.prototype.searchCache = searchCache;
}
if(SUPPORT_ASYNC){
Document.prototype.addAsync = addAsync;
Document.prototype.appendAsync = appendAsync;
Document.prototype.searchAsync = searchAsync;
Document.prototype.updateAsync = updateAsync;
Document.prototype.removeAsync = removeAsync;
}

48
src/engine.js Normal file
View File

@@ -0,0 +1,48 @@
import { addAsync, appendAsync, removeAsync, searchAsync, updateAsync } from "./async.js";
import Document from "./document";
import { DEBUG, SUPPORT_ASYNC, SUPPORT_CACHE } from "./config";
import { searchCache } from "./cache";
/**
* @constructor
* @abstract
*/
function Engine(index){
if(DEBUG){
if(this.constructor === Engine){
throw new Error("Can't instantiate abstract class!");
}
}
if(SUPPORT_CACHE){
index.prototype.searchCache = searchCache;
}
if(SUPPORT_ASYNC){
index.prototype.addAsync = addAsync;
index.prototype.appendAsync = appendAsync;
index.prototype.searchAsync = searchAsync;
index.prototype.updateAsync = updateAsync;
index.prototype.removeAsync = removeAsync;
}
}
if(SUPPORT_CACHE){
Engine.prototype.searchCache = searchCache;
}
if(SUPPORT_ASYNC){
Engine.prototype.addAsync = addAsync;
Engine.prototype.appendAsync = appendAsync;
Engine.prototype.searchAsync = searchAsync;
Engine.prototype.updateAsync = updateAsync;
Engine.prototype.removeAsync = removeAsync;
}

View File

@@ -1,33 +0,0 @@
import FlexSearch from "./flexsearch.js";
/** @export */
FlexSearch.prototype.init;
/** @export */
FlexSearch.prototype.search;
/** @export */
FlexSearch.prototype.add;
/** @export */
FlexSearch.prototype.update;
/** @export */
FlexSearch.prototype.remove;
/** @export */
FlexSearch.prototype.find;
/** @export */
FlexSearch.prototype.where;
/** @export */
FlexSearch.prototype.info;
/** @export */
FlexSearch.prototype.clear;
/** @export */
FlexSearch.prototype.destroy;
/** @export */
FlexSearch.prototype.export;
/** @export */
FlexSearch.prototype.import;
/** @export */
//FlexSearch.encode;
/** @export */
//FlexSearch.prototype.addMatcher;
/** @export */
Promise.prototype.then;

File diff suppressed because it is too large Load Diff

22
src/global.js Normal file
View File

@@ -0,0 +1,22 @@
export const global_lang = {};
export const global_charset = {};
/**
* @param {!string} name
* @param {Object} charset
*/
export function registerCharset(name, charset){
global_charset[name] = charset;
}
/**
* @param {!string} name
* @param {Object} lang
*/
export function registerLanguage(name, lang){
global_lang[name] = lang;
}

800
src/index.js Normal file
View File

@@ -0,0 +1,800 @@
/**!
* FlexSearch.js
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
import { SUPPORT_PRESET, SUPPORT_CACHE, SUPPORT_ASYNC, SUPPORT_WORKER } from "./config.js";
import { encode as default_encoder } from "./lang/latin/default.js";
import { create_object, create_object_array, concat, sort_by_length_down } from "./common.js";
import { pipeline, init_stemmer_or_matcher, init_filter } from "./lang.js";
import { global_lang, global_charset } from "./global.js";
import { addAsync, appendAsync, removeAsync, searchAsync, updateAsync } from "./async.js";
import Cache, { searchCache } from "./cache.js";
import apply_preset from "./presets.js";
import intersect from "./intersect.js";
/**
* @param {Object=} options
* @param {Object=} _register
* @return {Index}
* @constructor
*/
function Index(options, _register){
if(!(this instanceof Index)) {
return new Index(options);
}
let charset, lang, tmp;
if(options){
if(SUPPORT_PRESET){
options = apply_preset(options);
}
charset = options["charset"];
lang = options["lang"];
if(typeof charset === "string"){
if(charset.indexOf(":") === -1){
charset += ":default";
}
charset = global_charset[charset];
}
if(typeof lang === "string"){
lang = global_lang[lang];
}
}
else{
options = {};
}
let resolution, threshold, optimize, context = options["context"] || {};
this.encode = options["encode"] || (charset && charset.encode) || default_encoder;
this.register = _register || create_object();
resolution = options["resolution"] || 9;
threshold = options["threshold"] || 0;
if(threshold >= resolution){
threshold = resolution - 1;
}
this.resolution = resolution;
this.threshold = threshold;
this.tokenizer = tmp = (charset && charset.tokenize) || options["tokenize"] || "strict";
this.depth = (tmp === "strict") && context["depth"];
this.bidirectional = parse_option(context["bidirectional"], true);
this.optimize = optimize = options["optimize"] === "memory";
this.fastupdate = parse_option(options["fastupdate"], true);
this.minlength = options["minlength"] || 1;
// when not using the memory strategy the score array should not pre-allocated to its full length
this.map = optimize ? create_object_array(resolution - threshold) : create_object();
resolution = context["resolution"] || resolution;
threshold = context["threshold"] || threshold;
if(threshold >= resolution){
threshold = resolution - 1;
}
this.resolution_ctx = resolution;
this.threshold_ctx = threshold;
this.ctx = optimize ? create_object_array(resolution - threshold) : create_object();
this.rtl = (charset && charset.rtl) || options["rtl"];
this.matcher = (tmp = options["matcher"] || (lang && lang.matcher)) && init_stemmer_or_matcher(tmp, false);
this.stemmer = (tmp = options["stemmer"] || (lang && lang.stemmer)) && init_stemmer_or_matcher(tmp, true);
this.filter = (tmp = options["filter"] || (lang && lang.filter)) && init_filter(tmp);
if(SUPPORT_CACHE){
this.cache = (tmp = options["cache"]) && new Cache(tmp);
}
if(SUPPORT_WORKER){
/** @private */
this.worker = (tmp = options["worker"]) && new Worker("worker.js", { type: "module" });
if(tmp){
this.worker.onmessage = function(e){ console.log(e.data) };
this.worker.postMessage({ task: "register", options: options });
}
}
}
export default Index;
function parse_option(value, default_value){
return typeof value !== "undefined" ? value : default_value;
}
Index.prototype.pipeline = pipeline;
/**
* @param {!number|string} id
* @param {!string} content
*/
Index.prototype.append = function(id, content){
return this.add(id, content, true);
};
/**
* @param {!number|string} id
* @param {!string} content
* @param {boolean=} _append
*/
Index.prototype.add = function(id, content, _append){
if(this.register[id] && !_append){
return this.update(id, content);
}
if(content && (id || (id === 0))){
content = this.encode(content);
const length = content.length;
if(length){
const depth = this.depth;
const resolution = this.resolution - this.threshold;
const dupes = create_object();
// check context dupes to skip all contextual redundancy in the whole document
const dupes_ctx = create_object();
for(let i = 0; i < length; i++){
let term = content[this.rtl ? length - 1 - i : i];
let term_length = term.length;
// skip dupes will break the context chain
if(term && (term_length >= this.minlength) && (depth || !dupes[term])){
const score = Math.min((this.resolution / length * i) | 0, i);
if(score < resolution){
let token = "";
switch(this.tokenizer){
case "full":
if(term_length > 3){
for(let x = 0; x < term_length; x++){
const partial_score = x ? Math.min((score / 2 + this.resolution / term_length * x / 2) | 0, score + x) : score;
if(partial_score < resolution){
for(let y = term_length; y > x; y--){
token = term.substring(x, y);
if(token.length >= this.minlength){
this.push_index(dupes, token, partial_score, id, _append);
}
}
}
}
break;
}
// fallthrough to next case when term length < 4
case "reverse":
// skip last round (this token exist already in "forward")
if(term_length > 2){
for(let a = term_length - 1; a > 0; a--){
token = term[a] + token;
if(token.length >= this.minlength){
this.push_index(dupes, token, score, id, _append);
}
}
token = "";
}
// fallthrough to next case to apply forward also
case "forward":
if(term_length > 1){
for(let a = 0; a < term_length; a++){
token += term[a];
if(token.length >= this.minlength){
this.push_index(dupes, token, score, id, _append);
}
}
}
break;
//case "strict":
default:
this.push_index(dupes, term, score, id, _append);
if(depth){
if((length > 1) && (i < (length - 1))){
const resolution = this.resolution_ctx - this.threshold_ctx;
// check inner dupes to skip repeating words in the current context
const dupes_inner = create_object();
const keyword = term;
let size = Math.min(depth + 1, length - i);
dupes_inner[keyword] = 1;
for(let x = 1; x < size; x++){
term = content[this.rtl ? length - 1 - i - x : i + x];
if(term && (term.length >= this.minlength) && !dupes_inner[term]){
dupes_inner[term] = 1;
const context_score = Math.min(((this.resolution_ctx - size /*+ 1*/) / length * i + x) | 0, i + (x - 1));
if(context_score < resolution){
const swap = this.bidirectional && (term > keyword);
this.push_index(dupes_ctx, swap ? keyword : term, context_score, id, _append, swap ? term : keyword);
}
}
else{
size = Math.min(size + 1, length - i);
}
}
}
}
}
}
}
}
this.fastupdate || (this.register[id] = 1);
}
}
return this;
};
/**
* @private
* @param dupes
* @param value
* @param score
* @param id
* @param {boolean=} append
* @param {string=} keyword
*/
Index.prototype.push_index = function(dupes, value, score, id, append, keyword){
let arr = keyword ? this.ctx : this.map;
if(!dupes[value] || (keyword && !dupes[value][keyword])){
if(this.optimize){
arr = arr[score];
}
if(keyword){
dupes[value] || (dupes[value] = create_object());
dupes[value][keyword] = 1;
arr = arr[keyword] || (arr[keyword] = create_object());
}
else{
dupes[value] = 1;
}
arr = arr[value] || (arr[value] = []);
if(!this.optimize){
arr = arr[score] || (arr[score] = []);
}
if(!append || (arr.indexOf(id) === -1)){
arr[arr.length] = id;
// add a reference to the register for fast updates
if(this.fastupdate){
const tmp = this.register[id];
if(tmp){
tmp[tmp.length] = arr;
}
else{
this.register[id] = [arr];
}
}
}
}
}
/**
* @param {!string|Object} query
* @param {number|Object=} limit
* @param {Object=} options
* @returns {Array<number|string>}
*/
Index.prototype.search = function(query, limit, options){
if(typeof query === "object"){
options = query;
query = options["query"];
}
else if(typeof limit === "object"){
options = limit;
}
let result = [];
let length;
let threshold = this.threshold, context, suggest;
if(options){
limit = options["limit"];
threshold = parse_option(options["threshold"], threshold);
context = options["context"];
suggest = options["suggest"];
}
if(query){
query = /** @type {Array} */ (this.encode(query));
length = query.length;
// TODO: solve this in one single loop below
if(length > 1){
const dupes = create_object();
const query_new = [];
for(let i = 0, count = 0, term; i < length; i++){
term = query[i];
if(term && (term.length >= this.minlength) && !dupes[term]){
// the fast path just could applied when not in memory-optimized mode
if(!this.optimize && !suggest && !this.map[term]){
// fast path "not found"
return result;
}
else{
query_new[count++] = term;
dupes[term] = 1;
}
}
}
query = query_new;
length = query.length;
}
}
if(!length){
return result;
}
limit || (limit = 100);
const resolution = this.resolution - threshold;
const resolution_ctx = this.resolution_ctx - threshold;
let depth = this.depth && (length > 1) && (context !== false);
let index = 0, keyword;
if(depth){
keyword = query[0];
index = 1;
}
else{
if(length > 1){
query.sort(sort_by_length_down);
}
}
for(let arr, term; index < length; index++){
term = query[index];
if(depth){
arr = this.add_result(result, suggest, resolution_ctx, limit, length === 2, term, keyword);
// when suggestion enabled just forward keyword if term was found
// as long as the result is empty forward the pointer also
if(!suggest || (arr !== false) || !result.length){
keyword = term;
}
}
else{
arr = this.add_result(result, suggest, resolution, limit, length === 1, term);
}
if(arr){
return /** @type {Array<number|string>} */ (arr);
}
// apply suggestions on last loop or fallback
if(suggest && (index === length - 1)){
let length = result.length;
if(!length){
if(depth){
// fallback to non-contextual search when no result was found
depth = 0;
index = -1;
continue;
}
return result;
}
else if(length === 1){
// fast path optimization
result = result[0];
if(result.length === 1){
result = result[0];
}
else{
result = concat(result);
}
return result.length > limit ? result.slice(0, limit) : result;
}
}
}
return intersect(result, limit, suggest);
};
function get_array(arr, term, keyword, bidirectional){
if(keyword){
const swap = bidirectional && (term > keyword);
arr = arr[swap ? term : keyword];
arr = arr && arr[swap ? keyword : term];
}
else{
arr = arr[term];
}
return arr;
}
/**
* Returns an array when the result is done (to stop the process immediately),
* returns false when suggestions is enabled and no result was found,
* or returns nothing when a set was pushed successfully to the results
*
* @private
* @param {Array} result
* @param {Array} suggest
* @param {number} resolution
* @param {number} limit
* @param {boolean} just_one_loop
* @param {string} term
* @param {string=} keyword
* @return {Array<Array<string|number>>|boolean|undefined}
*/
Index.prototype.add_result = function(result, suggest, resolution, limit, just_one_loop, term, keyword){
let word_arr = [];
let arr = keyword ? this.ctx : this.map;
if(!this.optimize){
arr = get_array(arr, term, keyword, this.bidirectional);
// if(keyword){
//
// const swap = this.bidirectional && (term > keyword);
//
// arr = arr[swap ? term : keyword];
// arr = arr && arr[swap ? keyword : term];
// }
// else{
//
// arr = arr[term];
// }
}
if(arr){
let count = 0;
const arr_len = Math.min(arr.length, resolution);
for(let x = 0, size = 0, tmp; x < arr_len; x++){
tmp = arr[x];
if(this.optimize){
tmp = get_array(tmp, term, keyword, this.bidirectional);
// if(keyword){
//
// const swap = this.bidirectional && (term > keyword);
//
// tmp = tmp[swap ? term : keyword];
// tmp = tmp && tmp[swap ? keyword : term];
// }
// else{
//
// tmp = tmp[term];
// }
}
if(tmp){
// keep score (sparse array):
//word_arr[x] = arr;
// simplified score order:
word_arr[count++] = tmp;
if(just_one_loop){
size += tmp.length;
if(size >= limit){
// fast path optimization
break;
}
}
}
}
if(count){
if(just_one_loop){
// fast path optimization
if(count === 1){
word_arr = word_arr[0];
}
else{
word_arr = concat(word_arr);
}
return word_arr.length > limit ? word_arr.slice(0, limit) : word_arr;
}
result[result.length] = word_arr;
return;
}
}
// return an empty array will stop the loop,
// to prevent stop when using suggestions return a false value
return !suggest && word_arr;
};
Index.prototype.contain = function(id){
return !!this.register[id];
};
Index.prototype.update = function(id, content){
return this.remove(id).add(id, content);
};
/**
* @param {boolean=} _skip_deletion
*/
Index.prototype.remove = function(id, _skip_deletion){
const refs = this.register[id];
if(refs){
if(this.fastupdate){
// fast updates performs really fast but did not cleanup the key entries
for(let i = 0, tmp; i < refs.length; i++){
tmp = refs[i];
tmp.splice(tmp.indexOf(id), 1);
}
}
else{
remove_index(this.map, id, this.resolution - this.threshold, this.optimize);
if(this.depth){
remove_index(this.ctx, id, this.resolution_ctx - this.threshold_ctx, this.optimize);
}
}
_skip_deletion || delete this.register[id];
if(SUPPORT_CACHE && this.cache){
this.cache.del(id);
}
}
return this;
};
/**
* @param map
* @param id
* @param res
* @param optimize
* @param {number=} resolution
* @return {number}
*/
function remove_index(map, id, res, optimize, resolution){
let count = 0;
if(map.constructor === Array){
// the first array is the score array in both strategies
if(!resolution){
resolution = Math.min(map.length, res);
for(let x = 0, arr; x < resolution; x++){
arr = map[x];
if(arr){
count = remove_index(arr, id, res, optimize, resolution);
if(!optimize && !count){
// when not memory optimized the score index should removed
delete map[x];
}
}
}
}
else{
const pos = map.indexOf(id);
if(pos !== -1){
// fast path, when length is 1 or lower then the whole field gets deleted
if(map.length > 1){
map.splice(pos, 1);
count++;
}
}
else{
count++;
}
}
}
else{
for(let key in map){
count = remove_index(map[key], id, res, optimize, resolution);
if(!count){
delete map[key];
}
}
}
return count;
}
if(SUPPORT_CACHE){
Index.prototype.searchCache = searchCache;
}
if(SUPPORT_ASYNC){
Index.prototype.addAsync = addAsync;
Index.prototype.appendAsync = appendAsync;
Index.prototype.searchAsync = searchAsync;
Index.prototype.updateAsync = updateAsync;
Index.prototype.removeAsync = removeAsync;
}

137
src/intersect.js Normal file
View File

@@ -0,0 +1,137 @@
import { create_object, concat } from "./common.js";
/**
* @param arrays
* @param limit
* @param {boolean|Array=} suggest
* @returns {Array}
*/
export default function(arrays, limit, suggest) {
const length = arrays.length;
let result = [];
// if(!length){
//
// return result;
// }
//
// if(length === 1){
//
// const tmp = arrays[0];
//
// if(tmp.length === 1){
//
// return tmp[0];
// }
//
// return concat(tmp);
// }
// arrays.sort(function(a, b){
//
// return a.length - b.length;
// });
let check = create_object();
let count = 0;
if(suggest){
suggest = [];
}
// terms
for(let x = 0; x < length; x++){
const word_arr = arrays[x];
const word_arr_len = word_arr.length;
const new_check = create_object();
let found = !x;
// relevance
for(let y = 0; y < word_arr_len; y++){
//const arr = [].concat.apply([], word_arr);
const arr = word_arr[y];
const arr_len = arr.length;
if(arr_len){
if(suggest){
suggest[y] = [];
}
// ids
for(let z = 0, count_suggest = 0, id; z < arr_len; z++){
id = arr[z];
if(!x){
new_check[id] = 1;
}
else if(check[id]){
if(x === (length - 1)){
result[count++] = id;
if(count === limit){
// fast path "end reached"
return result;
}
}
else{
if(suggest && (count_suggest < limit)){
suggest[y][count_suggest++] = id;
}
new_check[id] = 1;
}
found = true;
}
}
}
}
if(!found && !suggest){
return [];
}
check = new_check;
}
if(suggest){
for(let i = suggest.length - 1, res, len; i >= 0; i--){
res = suggest[i];
len = res && res.length;
if(len){
if(count + len >= limit){
return result.concat(res.slice(0, limit - count));
}
else{
result = result.concat(res);
count += len;
}
}
}
}
return result;
}

307
src/lang.js Normal file
View File

@@ -0,0 +1,307 @@
import Index from "./index.js";
import { create_object } from "./common.js";
/**
* @param {!string} str
* @param {boolean|Array<string|RegExp>=} normalize
* @param {boolean|string|RegExp=} split
* @param {boolean=} _collapse
* @returns {string|Array<string>}
* @this Index
*/
export function pipeline(str, normalize, split, _collapse){
if(str){
if(normalize && str){
str = replace(str, /** @type {Array<string|RegExp>} */ (normalize));
}
if(str && this.matcher){
str = replace(str, this.matcher);
}
if(this.stemmer && str.length > 1){
str = replace(str, this.stemmer);
}
if(_collapse && str.length > 1){
str = collapse(str);
}
if(str){
if(split || (split === "")){
const words = str.split(/** @type {string|RegExp} */ (split));
return this.filter ? filter(words, this.filter) : words;
}
}
}
return str;
}
/**
* @param {!string} str
* @param {boolean|Array<string|RegExp>=} normalize
* @param {boolean|string|RegExp=} split
* @param {boolean=} _collapse
* @returns {string|Array<string>}
*/
// FlexSearch.prototype.pipeline = function(str, normalize, split, _collapse){
//
// if(str){
//
// if(normalize && str){
//
// str = replace(str, /** @type {Array<string|RegExp>} */ (normalize));
// }
//
// if(str && this.matcher){
//
// str = replace(str, this.matcher);
// }
//
// if(this.stemmer && str.length > 1){
//
// str = replace(str, this.stemmer);
// }
//
// if(_collapse && str.length > 1){
//
// str = collapse(str);
// }
//
// if(str){
//
// if(split || (split === "")){
//
// const words = str.split(/** @type {string|RegExp} */ (split));
//
// return this.filter ? filter(words, this.filter) : words;
// }
// }
// }
//
// return str;
// };
// export function pipeline(str, normalize, matcher, stemmer, split, _filter, _collapse){
//
// if(str){
//
// if(normalize && str){
//
// str = replace(str, normalize);
// }
//
// if(matcher && str){
//
// str = replace(str, matcher);
// }
//
// if(stemmer && str.length > 1){
//
// str = replace(str, stemmer);
// }
//
// if(_collapse && str.length > 1){
//
// str = collapse(str);
// }
//
// if(str){
//
// if(split !== false){
//
// str = str.split(split);
//
// if(_filter){
//
// str = filter(str, _filter);
// }
// }
// }
// }
//
// return str;
// }
/**
* @param {Array<string>} words
* @returns {Object<string, string>}
*/
export function init_filter(words){
const filter = create_object();
for(let i = 0, length = words.length; i < length; i++){
filter[words[i]] = 1;
}
return filter;
}
/**
* @param {!Object<string, string>} obj
* @param {boolean} is_stemmer
* @returns {Array}
*/
export function init_stemmer_or_matcher(obj, is_stemmer){
const keys = Object.keys(obj);
const length = keys.length;
const final = [];
let removal = "", count = 0;
for(let i = 0, key, tmp; i < length; i++){
key = keys[i];
tmp = obj[key];
if(tmp){
final[count++] = regex(is_stemmer ? "(?!\\b)" + key + "(\\b|_)" : key);
final[count++] = tmp;
}
else{
removal += (removal ? "|" : "") + key;
}
}
if(removal){
final[count++] = regex(is_stemmer ? "(?!\\b)(" + removal + ")(\\b|_)" : "(" + removal + ")");
final[count] = "";
}
return final;
}
/**
* @param {!string} str
* @param {Array} regexp
* @returns {string}
*/
export function replace(str, regexp){
for(let i = 0, len = regexp.length; i < len; i += 2){
str = str.replace(regexp[i], regexp[i + 1]);
if(!str){
break;
}
}
return str;
}
/**
* @param {!string} str
* @returns {RegExp}
*/
export function regex(str){
return new RegExp(str, "g");
}
/**
* Regex: replace(/(?:(\w)(?:\1)*)/g, "$1")
* @param {!string} string
* @returns {string}
*/
export function collapse(string){
let final = "", prev = "";
for(let i = 0, len = string.length, char; i < len; i++){
if((char = string[i]) !== prev){
final += (prev = char);
}
}
return final;
}
// TODO using fast-swap
export function filter(words, map){
const length = words.length;
const filtered = [];
for(let i = 0, count = 0; i < length; i++){
const word = words[i];
if(word && !map[word]){
filtered[count++] = word;
}
}
return filtered;
}
// const chars = {a:1, e:1, i:1, o:1, u:1, y:1};
//
// function collapse_repeating_chars(string){
//
// let collapsed_string = "",
// char_prev = "",
// char_next = "";
//
// for(let i = 0; i < string.length; i++){
//
// const char = string[i];
//
// if(char !== char_prev){
//
// if(i && (char === "h")){
//
// if((chars[char_prev] && chars[char_next]) || (char_prev === " ")){
//
// collapsed_string += char;
// }
// }
// else{
//
// collapsed_string += char;
// }
// }
//
// char_next = (
//
// (i === (string.length - 1)) ?
//
// ""
// :
// string[i + 1]
// );
//
// char_prev = char;
// }
//
// return collapsed_string;
// }

View File

@@ -1,4 +1,4 @@
import FlexSearch from "../../flexsearch.js";
import Document from "../../flexsearch.js";
export const rtl = true;
export const tokenize = "";
@@ -10,7 +10,7 @@ export default {
const regex = /[\x00-\x7F]+/g;
/**
* @this FlexSearch
* @this Document
*/
export function encode(str){

View File

@@ -1,4 +1,4 @@
import FlexSearch from "../../flexsearch.js";
import Document from "../../flexsearch.js";
export const rtl = false;
export const tokenize = "strict";
@@ -11,7 +11,7 @@ export default {
const regex = /[\x00-\x7F]+/g;
/**
* @this FlexSearch
* @this Document
*/
export function encode(str){

View File

@@ -1,4 +1,4 @@
import FlexSearch from "../../flexsearch.js";
import Document from "../../flexsearch.js";
export const rtl = false;
export const tokenize = "";
@@ -10,7 +10,7 @@ export default {
const regex = /[\x00-\x7F]+/g;
/**
* @this FlexSearch
* @this Document
*/
export function encode(str){

View File

@@ -1,5 +1,4 @@
import FlexSearch from "../../flexsearch.js";
import { regex, replace, collapse } from "../../common.js";
import { regex, replace, collapse } from "../../lang.js";
import { encode as encode_simple } from "./simple.js";
export const rtl = false;
@@ -55,7 +54,7 @@ export function encode(str, self, _skip_postprocessing){
if(str){
str = encode_simple(str, /** @type {FlexSearch} */ (self || this)).join(" ");
str = encode_simple(str, /** @type {Document} */ (self || this)).join(" ");
if(str.length > 2){

View File

@@ -1,4 +1,4 @@
import FlexSearch from "../../flexsearch.js";
import Index from "../../index.js";
export const rtl = false;
export const tokenize = "";
@@ -16,7 +16,7 @@ const regex_whitespace = /[\W_]+/;
// ];
/**
* @this FlexSearch
* @this Index
*/
export function encode(str){

View File

@@ -1,4 +1,4 @@
import FlexSearch from "../../flexsearch.js";
import Index from "../../index.js";
export const rtl = false;
export const tokenize = "";
@@ -10,7 +10,7 @@ export default {
const regex_whitespace = /[\W_]+/;
/**
* @this FlexSearch
* @this Index
*/
export function encode(str){

View File

@@ -1,5 +1,4 @@
import FlexSearch from "../../flexsearch.js";
import { regex, replace, collapse } from "../../common.js";
import { regex, replace, collapse } from "../../lang.js";
import { encode as encode_advanced } from "./advanced.js";
export const rtl = false;
@@ -35,7 +34,7 @@ export function encode(str){
if(str){
str = encode_advanced(str, /** @type {FlexSearch} */ (this), /* skip post-processing: */ true);
str = encode_advanced(str, /** @type {Document} */ (this), /* skip post-processing: */ true);
if(str.length > 1){

View File

@@ -1,5 +1,5 @@
import FlexSearch from "../../flexsearch.js";
import { regex } from "../../common.js";
import Index from "../../index.js";
import { regex } from "../../lang.js";
export const rtl = false;
export const tokenize = "";
@@ -45,7 +45,7 @@ const pairs = [
export function encode(str, self){
return /** @type {FlexSearch} */ (self || this).pipeline(
return /** @type {Index} */ (self || this).pipeline(
/* string: */ str.toLowerCase(),
/* normalize: */ pairs,

View File

@@ -1,4 +1,4 @@
import FlexSearch from "../../flexsearch.js";
import Index from "../../index.js";
export const rtl = false;
export const tokenize = "strict";
@@ -16,8 +16,38 @@ const regex_strip = /[^a-z]+/;
// regex_strip, ""
// ];
// modified
const soundex = {
"b": 1,
"f": 1,
"p": 1,
"v": 1,
"c": 7,
"g": 7,
"j": 7,
"k": 7,
"q": 7,
"s": 2,
"x": 2,
"z": 2,
"d": 3,
"t": 3,
"l": 4,
"m": 5,
"n": 5,
"r": 6
};
/**
* @this FlexSearch
* @this Index
*/
export function encode(str){
@@ -46,9 +76,9 @@ export function encode(str){
for(let i = 1; i < str.length; i++){
const current = getCode(str[i]);
const current = soundex[str[i]];
if(current !== previous){
if(current && (current !== previous)){
code += current;
previous = current;
@@ -68,37 +98,38 @@ export function encode(str){
return result;
}
// https://www.rosettacode.org/wiki/Soundex
function getCode(char){
switch(char){
case 'b':
case 'f':
case 'p':
case 'v':
return 1;
case 'c':
case 'g':
case 'j':
case 'k':
case 'q':
case 's':
case 'x':
case 'z':
return 2;
case 'd':
case 't':
return 3;
case 'l':
return 4;
case 'm':
case 'n':
return 5;
case 'r':
return 6;
}
return "";
}
// function getCode(char){
//
// switch(char){
//
// case 'b':
// case 'f':
// case 'p':
// case 'v':
// return 1;
// case 'c':
// case 'g':
// case 'j':
// case 'k':
// case 'q':
// case 's':
// case 'x':
// case 'z':
// return 2;
// case 'd':
// case 't':
// return 3;
// case 'l':
// return 4;
// case 'm':
// case 'n':
// return 5;
// case 'r':
// return 6;
// }
//
// return "";
// }

View File

@@ -1,3 +1,7 @@
import { POLYFILL, SUPPORT_ASYNC } from "./config.js";
export let promise = Promise;
if(POLYFILL){
Object.assign || (Object.assign = function(){
@@ -36,23 +40,20 @@ if(POLYFILL){
// return values;
// });
if(SUPPORT_ASYNC){
window["requestAnimationFrame"] || (window["requestAnimationFrame"] = window.setTimeout);
window["cancelAnimationFrame"] || (window["cancelAnimationFrame"] = window.clearTimeout);
window["Promise"] || (window["Promise"] = function(){
if(SUPPORT_ASYNC && !promise){
/**
* @param {Function} fn
* @constructor
*/
function Promise(fn){
function SimplePromise(fn){
this.callback = null;
const self = this;
let self = this;
//setTimeout(function(){
fn(function(val){
@@ -60,20 +61,21 @@ if(POLYFILL){
self.callback(val);
self.callback = null;
self = null;
}
});
//});
}
/**
* @param {Function} callback
*/
Promise.prototype.then = function(callback){
SimplePromise.prototype.then = function(callback){
this.callback = callback;
};
return Promise;
}());
promise = SimplePromise;
}
}

View File

@@ -1,53 +1,95 @@
import { DEBUG } from "./config.js";
/**
* @enum {Object}
* @const
*/
export default {
const presets = {
"memory": {
charset: "latin:extra",
//tokenize: "strict",
threshold: 0,
resolution: 1
resolution: 3,
//threshold: 0,
minlength: 3,
fastupdate: false,
optimize: "memory"
},
"speed": {
"performance": {
//charset: "latin",
//tokenize: "strict",
threshold: 1,
resolution: 3,
depth: 2
//resolution: 9,
threshold: 8,
minlength: 3,
//fastupdate: true,
context: {
depth: 1,
bidirectional: true
}
},
"match": {
charset: "latin:extra",
tokenize: "full",
threshold: 1,
resolution: 3
resolution: 3,
//threshold: 0
},
"score": {
charset: "latin:extra",
charset: "latin:advanced",
//tokenize: "strict",
//resolution: 9,
threshold: 1,
resolution: 9,
depth: 4
context: {
depth: 3,
bidirectional: true
}
},
"balance": {
charset: "latin:balance",
"default": {
//charset: "latin:default",
//tokenize: "strict",
threshold: 0,
resolution: 3,
threshold: 0,
depth: 3
},
"fast": {
//charset: "latin",
//tokenize: "strict",
threshold: 8,
resolution: 9,
depth: 1
}
// "fast": {
// //charset: "latin",
// //tokenize: "strict",
// threshold: 8,
// resolution: 9,
// depth: 1
// }
};
export default function apply_preset(options){
if(typeof options === "string"){
if(DEBUG && !presets[options]){
console.warn("Preset not found: " + options);
}
options = presets[options];
}
else{
const preset = options["preset"];
if(preset){
if(DEBUG && !presets[preset]){
console.warn("Preset not found: " + preset);
}
options = Object.assign({}, presets[preset], /** @type {Object} */ (options));
}
}
return options;
}

View File

@@ -1,33 +0,0 @@
const profiles = [];
let profile;
export function profile_start(key){
(profile[key] || (profile[key] = {
/** @export */ time: 0,
/** @export */ count: 0,
/** @export */ ops: 0,
/** @export */ nano: 0
})).ops = (typeof performance === "undefined" ? Date : performance).now();
}
export function profile_end(key){
const current = profile[key];
current.time += (typeof performance === "undefined" ? Date : performance).now() - current.ops;
current.count++;
current.ops = 1000 / current.time * current.count;
current.micro = current.time / current.count * 1000;
}
if(PROFILER){
if(typeof window !== "undefined") {
/** @export */
window.stats = profiles;
}
}

View File

@@ -1,127 +0,0 @@
import FlexSearch from "./flexsearch.js";
import { is_undefined, is_object, get_keys } from "./common.js";
if(SUPPORT_SERIALIZE){
/**
* TODO: also export settings?
* @param {Object<string, boolean>=} config
*/
FlexSearch.prototype.export = function(config){
const serialize = !config || is_undefined(config["serialize"]) || config["serialize"];
let payload;
if(SUPPORT_DOCUMENT && this.doc){
const export_doc = !config || is_undefined(config["doc"]) || config["doc"];
const export_index = !config || is_undefined(config["index"]) || config["index"];
payload = [];
let i = 0;
if(export_index){
const keys = this.doc.keys;
for(; i < keys.length; i++){
const idx = this.doc.index[keys[i]];
payload[i] = [
idx._map, idx._ctx, get_keys(idx._ids)
];
}
}
if(export_doc){
payload[i] = this._doc;
}
}
else{
payload = [
this._map,
this._ctx,
get_keys(this._ids)
];
}
if(serialize){
payload = JSON.stringify(payload);
}
return payload;
};
FlexSearch.prototype.import = function(payload, config){
const serialize = !config || is_undefined(config["serialize"]) || config["serialize"];
if(serialize){
payload = JSON.parse(payload);
}
const ids = {};
if(SUPPORT_DOCUMENT && this.doc){
const import_doc = !config || is_undefined(config["doc"]) || config["doc"];
const import_index = !config || is_undefined(config["index"]) || config["index"];
let i = 0;
if(import_index){
const keys = this.doc.keys;
const length = keys.length;
const current = payload[0][2];
for(; i < current.length; i++){
ids[current[i]] = 1;
}
for(i = 0; i < length; i++){
const idx = this.doc.index[keys[i]];
const item = payload[i];
if(item){
idx._map = item[0];
idx._ctx = item[1];
idx._ids = ids;
// idx._doc = payload[length];
}
}
}
if(import_doc){
this._doc = is_object(import_doc) ? import_doc : payload[i];
}
}
else{
const current = payload[2];
for(let i = 0; i < current.length; i++){
ids[current[i]] = 1;
}
this._map = payload[0];
this._ctx = payload[1];
this._ids = ids;
}
};
}

49
src/webpack.js Normal file
View File

@@ -0,0 +1,49 @@
import { SUPPORT_ASYNC, SUPPORT_DOCUMENT, SUPPORT_CACHE } from "./config.js";
import Document from "./document.js";
import Index from "./index.js";
import { registerCharset, registerLanguage } from "./global.js";
/** @export */ Document.prototype.add;
/** @export */ Document.prototype.append;
/** @export */ Document.prototype.search;
/** @export */ Document.prototype.update;
/** @export */ Document.prototype.remove;
/** @export */ Document.prototype.contain;
/** @export */ Document.prototype.get;
/** @export */ Document.prototype.set;
/** @export */ Index.prototype.add;
/** @export */ Index.prototype.append;
/** @export */ Index.prototype.search;
/** @export */ Index.prototype.update;
/** @export */ Index.prototype.remove;
/** @export */ Index.prototype.contain;
if(SUPPORT_CACHE){
/** @export */ Index.prototype.searchCache;
/** @export */ Document.prototype.searchCache;
}
if(SUPPORT_ASYNC){
/** @export */ Document.prototype.addAsync;
/** @export */ Document.prototype.appendAsync;
/** @export */ Document.prototype.searchAsync;
/** @export */ Document.prototype.updateAsync;
/** @export */ Document.prototype.removeAsync;
/** @export */ Index.prototype.addAsync;
/** @export */ Index.prototype.appendAsync;
/** @export */ Index.prototype.searchAsync;
/** @export */ Index.prototype.updateAsync;
/** @export */ Index.prototype.removeAsync;
}
window["FlexSearch"] = {
"Index": Index,
"Document": SUPPORT_DOCUMENT ? Document : null,
"registerCharset": registerCharset,
"registerLanguage": registerLanguage
}

View File

@@ -1,162 +0,0 @@
import FlexSearch from "./flexsearch.js";
import { get_keys, is_function, is_object, is_undefined } from "./common.js";
if(SUPPORT_DOCUMENT && SUPPORT_WHERE){
FlexSearch.prototype.find = function(key, value){
return this.where(key, value, 1)[0] || null;
};
/**
* @param key
* @param value
* @param limit
* @param {Array<Object>=} result
* @returns {Array<Object>}
*/
FlexSearch.prototype.where = function(key, value, limit, result){
const doc = this._doc;
const results = [];
let count = 0;
let keys;
let keys_len;
let has_value;
let tree;
let tag_results;
if(is_object(key)){
limit || (limit = value);
keys = get_keys(key);
keys_len = keys.length;
has_value = false;
if((keys_len === 1) && (keys[0] === "id")){
return [doc[key["id"]]];
}
const tags = this._tags;
if(tags && !result){
for(let i = 0; i < tags.length; i++){
const current_tag = tags[i];
const current_where = key[current_tag];
if(!is_undefined(current_where)){
tag_results = this._tag[current_tag]["@" + current_where];
//result = result.slice(0, limit && (limit < result.length) ? limit : result.length);
if(--keys_len === 0){
return tag_results;
}
keys.splice(keys.indexOf(current_tag), 1);
// TODO: delete from original reference?
delete key[current_tag];
break;
}
}
}
tree = new Array(keys_len);
for(let i = 0; i < keys_len; i++){
tree[i] = keys[i].split(":");
}
}
else if(is_function(key)){
const ids = result || get_keys(doc);
const length = ids.length;
for(let x = 0; x < length; x++){
const obj = doc[ids[x]];
if(key(obj)){
results[count++] = obj;
}
}
return results;
}
else{
if(is_undefined(value)){
return [doc[key]];
}
if(key === "id"){
return [doc[value]];
}
keys = [key];
keys_len = 1;
tree = [key.split(":")];
has_value = true;
}
const ids = tag_results || result || get_keys(doc); // this._ids;
const length = ids.length;
for(let x = 0; x < length; x++){
const obj = tag_results ? ids[x] : doc[ids[x]];
let found = true;
for(let i = 0; i < keys_len; i++){
has_value || (value = key[keys[i]]);
const tree_cur = tree[i];
const tree_len = tree_cur.length;
let ref = obj;
if(tree_len > 1){
for(let z = 0; z < tree_len; z++){
ref = ref[tree_cur[z]];
}
}
else{
ref = ref[tree_cur[0]];
}
if(ref !== value){
found = false;
break;
}
}
if(found){
results[count++] = obj;
if(limit && (count === limit)){
break;
}
}
}
return results;
};
}

View File

@@ -1,248 +1,50 @@
import FlexSearch from "./flexsearch.js";
const worker_stack = {};
const inline_supported = (typeof Blob !== "undefined") && (typeof URL !== "undefined") && URL.createObjectURL;
import Index from "./index.js";
/**
* @param {!string} _name
* @param {!number|string} _id
* @param {!Function} _worker
* @param {!Function} _callback
* @param {number=} _core
*/
let index, id;
export default function init(_name, _id, _worker, _callback, _core){
onmessage = function(event) {
let name = _name;
const worker_payload = (
const data = event.data;
inline_supported ?
switch(data["task"]){
// Load Inline Worker
case "register":
URL.createObjectURL(
const options = data["options"] || {};
new Blob([
(RELEASE ?
""
:
"var RELEASE = '" + RELEASE + "';" +
"var DEBUG = " + (DEBUG ? "true" : "false") + ";" +
"var PROFILER = " + (PROFILER ? "true" : "false") + ";" +
"var SUPPORT_PRESET = " + (SUPPORT_PRESET ? "true" : "false") + ";" +
"var SUPPORT_SUGGESTION = " + (SUPPORT_SUGGESTION ? "true" : "false") + ";" +
"var SUPPORT_ENCODER = " + (SUPPORT_ENCODER ? "true" : "false") + ";" +
"var SUPPORT_CACHE = " + (SUPPORT_CACHE ? "true" : "false") + ";" +
"var SUPPORT_ASYNC = " + (SUPPORT_ASYNC ? "true" : "false") + ";" +
"var SUPPORT_SERIALIZE = " + (SUPPORT_SERIALIZE ? "true" : "false") + ";" +
"var SUPPORT_INFO = " + (SUPPORT_INFO ? "true" : "false") + ";" +
"var SUPPORT_DOCUMENT = " + (SUPPORT_DOCUMENT ? "true" : "false") + ";" +
"var SUPPORT_WHERE = " + (SUPPORT_WHERE ? "true" : "false") + ";" +
"var SUPPORT_PAGINATION = " + (SUPPORT_PAGINATION ? "true" : "false") + ";" +
"var SUPPORT_OPERATOR = " + (SUPPORT_OPERATOR ? "true" : "false") + ";" +
"var SUPPORT_CALLBACK = " + (SUPPORT_CALLBACK ? "true" : "false") + ";" +
"var SUPPORT_WORKER = true;"
) + "(" + _worker.toString() + ")()"
],{
"type": "text/javascript"
})
)
:
// Load Extern Worker (but also requires CORS)
name + (RELEASE ? "." + RELEASE : "") + ".js"
);
name += "-" + _id;
worker_stack[name] || (worker_stack[name] = []);
worker_stack[name][_core] = new Worker(worker_payload);
worker_stack[name][_core]["onmessage"] = _callback;
if(DEBUG){
console.log("Register Worker: " + name + "@" + _core);
}
return worker_stack[name][_core];
}
function worker_module(){
let id;
/** @type {FlexSearch} */
let FlexSearchWorker;
/** @lends {Worker} */
self.onmessage = function(event){
const data = event["data"];
if(data){
if(data["search"]){
const results = FlexSearchWorker["search"](data["content"],
data["threshold"] ?
{
"limit": data["limit"],
"threshold": data["threshold"],
"where": data["where"]
}
:
data["limit"]
);
/** @lends {Worker} */
self.postMessage({
"id": id,
"content": data["content"],
"limit": data["limit"],
"result": results
});
}
else if(data["add"]){
FlexSearchWorker["add"](data["id"], data["content"]);
}
else if(data["update"]){
FlexSearchWorker["update"](data["id"], data["content"]);
}
else if(data["remove"]){
FlexSearchWorker["remove"](data["id"]);
}
else if(data["clear"]){
FlexSearchWorker["clear"]();
}
else if(SUPPORT_INFO && data["info"]){
const info = FlexSearchWorker["info"]();
info["worker"] = id;
console.log(info);
/** @lends {Worker} */
//self.postMessage(info);
}
else if(data["register"]){
options["cache"] = false;
// options["async"] = false;
// options["worker"] = false;
id = data["id"];
index = new Index(options);
break;
data["options"]["cache"] = false;
data["options"]["async"] = false;
data["options"]["worker"] = false;
case "search":
FlexSearchWorker = new Function(
const results = index.search(data["query"], data);
data["register"].substring(
postMessage({ id, results });
break;
data["register"].indexOf("{") + 1,
data["register"].lastIndexOf("}")
)
)();
case "add":
FlexSearchWorker = new FlexSearchWorker(data["options"]);
}
index.add(data["id"], data["content"]);
break;
case "update":
index.update(data["id"], data["content"]);
break;
case "remove":
index.remove(data["id"]);
break;
// case "clear":
//
// index.clear();
// break;
}
};
}
export function addWorker(id, core, options, callback){
const thread = init(
// name:
"flexsearch",
// id:
"id" + id,
// worker:
worker_module,
// callback:
function(event){
const data = event["data"];
if(data && data["result"]){
callback(
data["id"],
data["content"],
data["result"],
data["limit"],
data["where"],
data["cursor"],
data["suggest"]
);
}
},
// cores:
core
);
const fnStr = FlexSearch.toString();
options["id"] = core;
thread.postMessage({
"register": fnStr,
"options": options,
"id": core
});
return thread;
}
if(SUPPORT_WORKER){
FlexSearch.prototype.worker_handler = function(id, query, result, limit, where, cursor, suggest){
if(this._task_completed !== this.worker){
this._task_result = this._task_result.concat(result);
this._task_completed++;
// TODO: sort results, return array of relevance [0...9] and apply in main thread
if(limit && (this._task_result.length >= limit)){
this._task_completed = this.worker;
}
if(this._task_completed === this.worker){
// this._task_result = intersect(this._task_result, where ? 0 : limit, cursor, suggest);
if(this.cache){
this._cache.set(query, this._task_result);
}
if(this._current_callback){
this._current_callback(this._task_result);
}
//this._task_completed = 0;
//this._task_result = [];
}
}
return this;
};
}

View File

@@ -106,9 +106,9 @@ let parameter = (function(opt){
compilation_level: compilation_level || (release === "pre" ? "SIMPLE" : (release === "debug" ? "WHITESPACE" : "ADVANCED_OPTIMIZATIONS")), //"SIMPLE"
use_types_for_optimization: true,
//new_type_inf: true,
jscomp_warning: "newCheckTypes",
//jscomp_warning: "newCheckTypes",
//jscomp_error: "strictCheckTypes",
jscomp_error: "newCheckTypesExtraChecks",
//jscomp_error: "newCheckTypesExtraChecks",
generate_exports: true,
export_local_property_definitions: true,
language_in: "ECMASCRIPT6_STRICT",
@@ -119,19 +119,19 @@ let parameter = (function(opt){
emit_use_strict: true,
output_manifest: "log/manifest.log",
output_module_dependencies: "log/module_dependencies.log",
//output_module_dependencies: "log/module_dependencies.log",
property_renaming_report: "log/property_renaming.log",
create_source_map: "log/source_map.log",
variable_renaming_report: "log/variable_renaming.log",
strict_mode_input: true,
assume_function_wrapper: true,
transform_amd_modules: true,
//transform_amd_modules: true,
process_common_js_modules: true,
module_resolution: "BROWSER",
//dependency_mode: "SORT_ONLY",
//js_module_root: "./",
entry_point: "./src/bundle.js",
entry_point: "./src/webpack.js",
//manage_closure_dependencies: true,
dependency_mode: "PRUNE_LEGACY",
rewrite_polyfills: use_polyfill || false,
@@ -216,10 +216,16 @@ else{
var filename = "dist/flexsearch." + (release || "custom") + ".js";
exec("java -jar node_modules/google-closure-compiler-java/compiler.jar" + parameter + " --js='src/**.js'" + flag_str + " --js_output_file='" + filename + "' && exit 0", function(){
exec((/^win/.test(process.platform) ?
"\"node_modules/google-closure-compiler-windows/compiler.exe\""
:
"java -jar node_modules/google-closure-compiler-java/compiler.jar"
) + parameter + " --js='src/**.js'" + flag_str + " --js_output_file='" + filename + "' && exit 0", function(){
let build = fs.readFileSync(filename);
let preserve = fs.readFileSync("src/flexsearch.js", "utf8");
let preserve = fs.readFileSync("src/index.js", "utf8");
const package_json = require("../package.json");