Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flexsearch

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flexsearch - npm Package Compare versions

Comparing version 0.3.4 to 0.3.5

1

compile.js

@@ -75,2 +75,3 @@ var child_process = require('child_process');

language_out: language_out || "ECMASCRIPT6_STRICT",
//rewrite_polyfills: false,
process_closure_primitives: true,

@@ -77,0 +78,0 @@ summary_detail_level: 3,

49

flexsearch.min.js
/*
FlexSearch v0.3.3
FlexSearch v0.3.5
Copyright 2019 Nextapps GmbH

@@ -8,24 +8,25 @@ Author: Thomas Wilkerling

*/
'use strict';(function(t,A,g){let v;(v=g.define)&&v.amd?v([],function(){return A}):(v=g.modules)?v[t.toLowerCase()]=A:"object"===typeof exports?module.exports=A:g[t]=A})("FlexSearch",function P(t){function g(a){C(a)&&(a=I[a]);a||(a=w);this.id=a.id||Q++;this.init(a);v(this,"index",function(){return this.a});v(this,"length",function(){return Object.keys(this.a).length})}function v(a,b,d){Object.defineProperty(a,b,{get:d})}function e(a){return new RegExp(a,"g")}function x(a,b){for(let d=0;d<b.length;d+=
2)a=a.replace(b[d],b[d+1]);return a}function y(a,b,d,c,f,k,h){if(b[d])return b[d];f=f?(9-(h||6))*k+(h||6)*f:k;b[d]=f;f>=h&&(a=a[9-(f+.5>>0)],a=a[d]||(a[d]=[]),a[a.length]=c);return f}function q(a,b){if(a){const d=Object.keys(a);for(let c=0,f=d.length;c<f;c++){const f=d[c],h=a[f];if(h)for(let c=0,d=h.length;c<d;c++)if(h[c]===b){1===d?delete a[f]:h.splice(c,1);break}else"object"===typeof h[c]&&q(h[c],b)}}}function F(a){let b="",d="";var c="";for(let f=0;f<a.length;f++){const k=a[f];if(k!==d)if(f&&"h"===
k){if(c="a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c,("a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d)&&c||" "===d)b+=k}else b+=k;c=f===a.length-1?"":a[f+1];d=k}return b}function R(a,b){const d=n();if(a)for(let c=0;c<a.length;c++){const f=b?b(a[c]):a[c];d[f]=String.fromCharCode(65E3-a.length+c)}return d}function S(a,b){const d=[];if(a)for(const c in a)if(a.hasOwnProperty(c)){const f=b?b(c):c;d.push(e("(?=.{"+(f.length+3)+",})"+f+"$"),b?b(a[c]):a[c])}return d}function T(a,b){a=a.length-
b.length;return 0>a?1:a?-1:0}function U(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function V(a,b,d){let c=[],f;const k=a.length;if(1<k){a.sort(U);const u=n();let e=a[0],g=e.length,p=0;for(;p<g;)u["@"+e[p++]]=1;let r,l=0,m=0;for(;++m<k;){let J=!1;const n=m===k-1;f=[];e=a[m];g=e.length;for(p=0;p<g;){r=e[p++];var h="@"+r;if(u[h]){const a=u[h];if(a===m){if(n){if(c[l++]=r,b&&l===b)return c}else u[h]=m+1;J=!0}else d&&(h=f[a]||(f[a]=[]),h[h.length]=r)}}if(!J&&!d)break}if(d&&(l=c.length,(m=f.length)&&
(!b||l<b)))for(;m--;)if(r=f[m])for(let a=0,d=r.length;a<d;a++)if(c[l++]=r[a],b&&l===b)return c}else k&&(c=a[0],b&&c.length>b&&(c=c.slice(0,b)));return c}function C(a){return"string"===typeof a}function D(a){return"function"===typeof a}function z(a){return"undefined"===typeof a}function G(a){a.D||(a.D=K(function(){a.D=0;{const b=a.async;let d;b&&(a.async=!1);if(a.f.length){const b=Date.now();let f;for(;(f=a.f.shift())||0===f;){d=a.h[f];switch(d[0]){case E.add:a.add(d[1],d[2]);break;case E.remove:a.remove(d[1])}delete a.h[f];
if(100<Date.now()-b)break}a.f.length&&G(a)}b&&(a.async=b)}},1,"@"+a.id))}function L(a){const b=Array(a);for(let d=0;d<a;d++)b[d]=n();return b}function n(){return Object.create(null)}function W(a,b,d,c){a=t("flexsearch","id"+a,function(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}: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.register&&(a=c.id,c.options.cache=!1,c.options.async=!0,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}},function(a){(a=a.data)&&a.result&&c(a.id,a.content,a.result,a.limit)},b);const f=P.toString();d.id=b;a.postMessage(b,{register:f,options:d,id:b});return a}const w={encode:"icase",b:"forward",v:!1,cache:!1,async:!1,c:!1,threshold:0,depth:0},I={memory:{encode:"extra",
b:"strict",threshold:7},speed:{encode:"icase",b:"strict",threshold:7,depth:2},match:{encode:"extra",b:"full"},score:{encode:"extra",b:"strict",threshold:5,depth:4},balance:{encode:"balance",b:"strict",threshold:6,depth:3},fastest:{encode:"icase",b:"strict",threshold:9,depth:1}},H=[];let Q=0;const E={add:0,update:1,remove:2},M=e("\\W+"),N={},O={};(function(){const a=Object.getOwnPropertyNames({}.__proto__),b=n();for(let d=0;d<a.length;d++)b[a[d]]=1;return b})();g.create=function(a){return new g(a)};
g.registerMatcher=function(a){for(let b in a)a.hasOwnProperty(b)&&H.push(e(b),a[b]);return this};g.registerEncoder=function(a,b){B[a]=b.bind(B);return this};g.registerLanguage=function(a,b){N[a]=b.filter;O[a]=b.stemmer;return this};g.encode=function(a,b){return B[a](b)};g.prototype.init=function(a){this.C=[];a||(a=w);let b=a.profile;const d=b?I[b]:{};if(b=a.worker)if(Worker){const c=this,d=parseInt(b,10)||4;c.o=-1;c.s=0;c.i=[];c.B=null;c.m=Array(d);for(let b=0;b<d;b++)c.m[b]=W(c.id,b,a,function(a,
b,d,f){if(c.s!==c.c)return c.i=c.i.concat(d),c.s++,f&&c.i.length>=f&&(c.s=c.c),c.B&&c.s===c.c&&(c.cache&&c.j.set(b,c.i),c.B(c.i),c.i=[]),c})}else a.worker=!1,this.m=null;this.b=a.tokenize||d.b||this.b||w.b;this.async=z(b=a.async)?this.async||w.async:b;this.c=z(b=a.worker)?this.c||w.c:b;this.threshold=z(b=a.threshold)?d.threshold||this.threshold||w.threshold:b;this.depth=z(b=a.depth)?d.depth||this.depth||w.depth:b;this.v=z(b=a.suggest)?this.v||w.v:b;this.u=(b=z(b=a.encode)?d.encode:b)&&B[b]&&B[b].bind(B)||
(D(b)?b:this.u||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.filter=R(N[b]||b,this.u);if(b=a.stemmer)this.stemmer=S(O[b]||b,this.u);this.l=L(10-(this.threshold||0));this.g=n();this.a=n();this.h=n();this.f=[];this.D=0;this.w=!0;this.j=(this.cache=b=z(b=a.cache)?this.cache||w.cache:b)?new X(b):!1;return this};g.prototype.encode=function(a){a&&H.length&&(a=x(a,H));a&&this.C.length&&(a=x(a,this.C));a&&this.u&&(a=this.u(a));a&&this.stemmer&&(a=x(a,this.stemmer));return a};g.prototype.addMatcher=
function(a){const b=this.C;for(const d in a)a.hasOwnProperty(d)&&b.push(e(d),a[d]);return this};g.prototype.add=function(a,b,d){if(b&&C(b)&&(a||0===a)){const k="@"+a;if(this.a[k]&&!d)this.update(a,b);else{if(this.c)return++this.o>=this.m.length&&(this.o=0),this.m[this.o].postMessage(this.o,{add:!0,id:a,content:b}),this.a[k]=""+this.o,this;if(this.async)return this.h[k]||(this.f[this.f.length]=k),this.h[k]=[E.add,a,b],G(this),this;b=this.encode(b);if(!b.length)return this;d=this.b;b=D(d)?d(b):b.split(M);
const u=n();u._ctx=n();const p=this.threshold,r=this.depth,l=this.l,m=b.length;for(let k=0;k<m;k++){var c=b[k];if(c){var f=c.length,e=(m-k)/m,h="";switch(d){case "reverse":case "both":for(var g=f-1;1<=g;g--)h=c[g]+h,y(l,u,h,a,(f-g)/f,e,p);h="";case "forward":for(g=0;g<f;g++)h+=c[g],y(l,u,h,a,1,e,p);break;case "full":for(g=0;g<f;g++){const b=(f-g)/f;for(let d=f;d>g;d--)h=c.substring(g,d),y(l,u,h,a,b,e,p)}break;default:if(f=y(l,u,c,a,1,e,p),r&&1<m&&f>=p)for(f=u._ctx[c]||(u._ctx[c]=n()),c=this.g[c]||
(this.g[c]=L(10-(p||0))),e=k-r,h=k+r+1,0>e&&(e=0),h>m&&(h=m);e<h;e++)e!==k&&y(c,f,b[e],a,0,10-(e<k?k-e:e-k),p)}}}this.a[k]=1;this.w=!1}}return this};g.prototype.update=function(a,b){this.a["@"+a]&&C(b)&&(this.remove(a),this.add(a,b,!0));return this};g.prototype.remove=function(a){const b="@"+a;if(this.a[b]){if(this.c){var d=this.a[b];this.m[d].postMessage(d,{remove:!0,id:a});delete this.a[b];return this}if(this.async)return this.h[b]||(this.f[this.f.length]=b),this.h[b]=[E.remove,a],G(this),this;
for(d=0;d<10-(this.threshold||0);d++)q(this.l[d],a);this.depth&&q(this.g,a);delete this.a[b];this.w=!1}return this};g.prototype.search=function(a,b,d,c){let f=a,e;var h=[];"object"===typeof a&&((d=a.callback||b)&&(f.callback=null),b=a.limit,e=a.threshold,a=a.query);e||(e=this.threshold||0);D(b)?(d=b,b=1E3):b||0===b||(b=1E3);if(this.c)for(this.B=d,this.s=0,this.i=[],h=0;h<this.c;h++)this.m[h].postMessage(h,{search:!0,limit:b,threshold:e,content:a});else if(d){{let a=this;K(function(){d(a.search(f,
b,null,!0));a=null},1,"search-"+this.id)}}else{if(!c&&this.async&&"function"!==typeof importScripts){let a=this;return new Promise(function(c){c(a.search(f,b,null,!0));a=null})}if(!a||!C(a))return h;f=a;if(this.cache)if(this.w){if(c=this.j.get(a))return c}else this.j.clear(),this.w=!0;f=this.encode(f);if(!f.length)return h;c=this.b;c=D(c)?c(f):f.split(M);var g=c.length,q=!0,t=[],p=n();if(1<g)if(this.depth){var r=!0;var l=c[0];p[l]=1}else c.sort(T);var m;if(!r||(m=this.g)[l])for(let a=r?1:0;a<g;a++){const b=
c[a];if(b){if(!p[b]){const a=[];let c=!1,d=0;if(l=r?m[l]:this.l){let f;for(let h=0;h<10-e;h++)if(f=l[h][b])a[d++]=f,c=!0}if(c)t[t.length]=1<d?a.concat.apply([],a):a[0];else if(!this.v){q=!1;break}p[b]=1}l=b}}else q=!1;q&&(h=V(t,b,this.v));this.cache&&this.j.set(a,h);return h}};g.prototype.clear=function(){this.destroy();return this.init()};g.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.filter=this.stemmer=this.l=this.g=this.a=this.h=this.f=null;return this};g.prototype.export=
function(){return JSON.stringify([this.l,this.g,this.a])};g.prototype.import=function(a){a=JSON.parse(a);this.l=a[0];this.g=a[1];this.a=a[2]};const B={icase:function(a){return a.toLowerCase()},simple:function(){const a=[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),"c",e("\u00df"),
"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=x(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){const a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,d){if(!b)return b;b=this.simple(b);2<b.length&&(b=x(b,a));d||1<b.length&&(b=F(b));return b}}(),extra:function(){const a=
[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let d=0;d<b.length;d++){const c=b[d];1<c.length&&(b[d]=c[0]+x(c.substring(1),a))}b=b.join(" ");b=F(b)}return b}}(),balance:function(){const a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return F(x(b.toLowerCase(),a))}}()},K=function(){const a=n();return function(b,d,c){const f=a[c];f&&clearTimeout(f);
return a[c]=setTimeout(b,d)}}(),X=function(){function a(a){this.clear();this.A=!0!==a&&a}a.prototype.clear=function(){this.cache=n();this.count=n();this.index=n();this.a=[]};a.prototype.set=function(a,d){if(this.A&&z(this.cache[a])){let b=this.a.length;if(b===this.A){b--;const a=this.a[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.a[b]=a;this.count[a]=-1;this.cache[a]=d;this.get(a)}else this.cache[a]=d};a.prototype.get=function(a){const b=this.cache[a];if(this.A&&
b){var c=++this.count[a];const b=this.index;let d=b[a];if(0<d){const e=this.a;for(var f=d;this.count[e[--d]]<=c&&-1!==d;);d++;if(d!==f){for(c=f;c>d;c--)f=e[c-1],e[c]=f,b[f]=c;e[d]=a;b[a]=d}}}return b};return a}();return g}(function(){const t={},A="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(g,v,e,x,y){let q=g;g=A?URL.createObjectURL(new Blob(["("+e.toString()+")()"],{type:"text/javascript"})):q+".min.js";q+="-"+v;t[q]||(t[q]=[]);t[q][y]=new Worker(g);t[q][y].onmessage=
x;return{postMessage:function(e,g){t[q][e].postMessage(g)}}}}()),this);
'use strict';(function(u,B,g){let v;(v=g.define)&&v.amd?v([],function(){return B}):(v=g.modules)?v[u.toLowerCase()]=B:"object"===typeof exports?module.exports=B:g[u]=B})("FlexSearch",function O(u){function g(a){E(a)&&(a=J[a]);a||(a=w);this.id=a.id||P++;this.init(a);v(this,"index",function(){return this.a});v(this,"length",function(){return Object.keys(this.a).length})}function v(a,b,c){Object.defineProperty(a,b,{get:c})}function e(a){return new RegExp(a,"g")}function x(a,b){for(let c=0;c<b.length;c+=
2)a=a.replace(b[c],b[c+1]);return a}function y(a,b,c,d,f,l,h){if(b[c])return b[c];f=f?(9-(h||6))*l+(h||6)*f:l;b[c]=f;f>=h&&(a=a[9-(f+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return f}function H(a,b){if(a){const c=Object.keys(a);for(let d=0,f=c.length;d<f;d++){const f=c[d],h=a[f];if(h)for(let c=0,d=h.length;c<d;c++)if(h[c]===b){1===d?delete a[f]:h.splice(c,1);break}else"object"===typeof h[c]&&H(h[c],b)}}}function I(a){let b="",c="";var d="";for(let f=0;f<a.length;f++){const l=a[f];if(l!==c)if(f&&"h"===
l){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=l}else b+=l;d=f===a.length-1?"":a[f+1];c=l}return b}function Q(a,b){const c=r();if(a)for(let d=0;d<a.length;d++){const f=b?b(a[d]):a[d];c[f]=String.fromCharCode(65E3-a.length+d)}return c}function R(a,b){const c=[];if(a)for(const d in a)if(a.hasOwnProperty(d)){const f=b?b(d):d;c.push(e("(?=.{"+(f.length+3)+",})"+f+"$"),b?b(a[d]):a[d])}return c}function S(a,b){a=a.length-
b.length;return 0>a?1:a?-1:0}function T(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function U(a,b,c){let d=[],f;const l=a.length;if(1<l){a.sort(T);const z=r();let e=a[0],g=e.length,k=0;for(;k<g;)z["@"+e[k++]]=1;let q,p=0,t=0;for(;++t<l;){let m=!1;const n=t===l-1;f=[];e=a[t];g=e.length;for(k=0;k<g;){q=e[k++];var h="@"+q;if(z[h]){const a=z[h];if(a===t){if(n){if(d[p++]=q,b&&p===b)return d}else z[h]=t+1;m=!0}else c&&(h=f[a]||(f[a]=[]),h[h.length]=q)}}if(!m&&!c)break}if(c&&(p=d.length,(t=f.length)&&
(!b||p<b)))for(;t--;)if(q=f[t])for(let a=0,c=q.length;a<c;a++)if(d[p++]=q[a],b&&p===b)return d}else l&&(d=a[0],b&&d.length>b&&(d=d.slice(0,b)));return d}function E(a){return"string"===typeof a}function F(a){return"function"===typeof a}function A(a){return"undefined"===typeof a}function K(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=r();return b}function r(){return Object.create(null)}function V(a,b,c,d){a=u("flexsearch","id"+a,function(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=
b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}: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(a){(a=
a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},b);const f=O.toString();c.id=b;a.postMessage({register:f,options:c,id:b});return a}const w={encode:"icase",b:"forward",u:!1,cache:!1,async:!1,c:!1,threshold:0,depth:0},J={memory:{encode:"extra",b:"strict",threshold:7},speed:{encode:"icase",b:"strict",threshold:7,depth:2},match:{encode:"extra",b:"full"},score:{encode:"extra",b:"strict",threshold:5,depth:4},balance:{encode:"balance",b:"strict",threshold:6,depth:3},fastest:{encode:"icase",b:"strict",
threshold:9,depth:1}},G=[];let P=0;const L=e("\\W+"),M={},N={};(function(){const a=Object.getOwnPropertyNames({}.__proto__),b=r();for(let c=0;c<a.length;c++)b[a[c]]=1;return b})();g.create=function(a){return new g(a)};g.registerMatcher=function(a){for(let b in a)a.hasOwnProperty(b)&&G.push(e(b),a[b]);return this};g.registerEncoder=function(a,b){D[a]=b.bind(D);return this};g.registerLanguage=function(a,b){M[a]=b.filter;N[a]=b.stemmer;return this};g.encode=function(a,b){return D[a](b)};g.prototype.init=
function(a){this.m=[];a||(a=w);let b=a.profile;const c=b?J[b]:{};if(b=a.worker)if("undefined"!==typeof Worker){const c=this,f=parseInt(b,10)||4;c.w=-1;c.o=0;c.h=[];c.B=null;c.i=Array(f);for(let b=0;b<f;b++)c.i[b]=V(c.id,b,a,function(a,b,d,f){if(c.o!==c.c)return c.h=c.h.concat(d),c.o++,f&&c.h.length>=f&&(c.o=c.c),c.B&&c.o===c.c&&(c.cache&&c.j.set(b,c.h),c.B(c.h),c.h=[]),c})}else a.worker=!1,this.i=null;this.b=a.tokenize||c.b||this.b||w.b;this.async="undefined"===typeof Promise||A(b=a.async)?this.async||
w.async:b;this.c=A(b=a.worker)?this.c||w.c:b;this.threshold=A(b=a.threshold)?c.threshold||this.threshold||w.threshold:b;this.depth=A(b=a.depth)?c.depth||this.depth||w.depth:b;this.u=A(b=a.suggest)?this.u||w.u:b;this.s=(b=A(b=a.encode)?c.encode:b)&&D[b]&&D[b].bind(D)||(F(b)?b:this.s||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.filter=Q(M[b]||b,this.s);if(b=a.stemmer)this.stemmer=R(N[b]||b,this.s);this.f=K(10-(this.threshold||0));this.g=r();this.a=r();this.v=!0;this.j=(this.cache=b=A(b=
a.cache)?this.cache||w.cache:b)?new W(b):!1;return this};g.prototype.encode=function(a){a&&G.length&&(a=x(a,G));a&&this.m.length&&(a=x(a,this.m));a&&this.s&&(a=this.s(a));a&&this.stemmer&&(a=x(a,this.stemmer));return a};g.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(e(c),a[c]);return this};g.prototype.add=function(a,b,c,d,f){if(b&&E(b)&&(a||0===a)){var e="@"+a;if(this.a[e]&&!d)return this.update(a,b);if(this.c)return++this.w>=this.i.length&&(this.w=
0),this.i[this.w].postMessage({add:!0,id:a,content:b}),this.a[e]=""+this.w,c&&c(),this;if(!f){if(this.async&&"function"!==typeof importScripts){let f=this;e=new Promise(function(c){setTimeout(function(){f.add(a,b,null,d,!0);f=null;c()})});if(c)e.then(c);else return e;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.b;f=F(c)?c(b):b.split(L);const l=r();l._ctx=r();const p=this.threshold,t=this.depth,z=this.f,C=f.length;for(let b=0;b<C;b++){var h=
f[b];if(h){var g=h.length,m=(C-b)/C,n="";switch(c){case "reverse":case "both":for(var k=g-1;1<=k;k--)n=h[k]+n,y(z,l,n,a,(g-k)/g,m,p);n="";case "forward":for(k=0;k<g;k++)n+=h[k],y(z,l,n,a,1,m,p);break;case "full":for(k=0;k<g;k++){const b=(g-k)/g;for(let c=g;c>k;c--)n=h.substring(k,c),y(z,l,n,a,b,m,p)}break;default:if(g=y(z,l,h,a,1,m,p),t&&1<C&&g>=p)for(g=l._ctx[h]||(l._ctx[h]=r()),h=this.g[h]||(this.g[h]=K(10-(p||0))),m=b-t,n=b+t+1,0>m&&(m=0),n>C&&(n=C);m<n;m++)m!==b&&y(h,g,f[m],a,0,10-(m<b?b-m:m-
b),p)}}}this.a[e]=1;this.v=!1}return this};g.prototype.update=function(a,b,c){this.a["@"+a]&&E(b)&&(this.remove(a),this.add(a,b,c,!0));return this};g.prototype.remove=function(a,b,c){var d="@"+a;if(this.a[d]){if(this.c)return this.i[this.a[d]].postMessage({remove:!0,id:a}),delete this.a[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,
null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)H(this.f[b],a);this.depth&&H(this.g,a);delete this.a[d];this.v=!1}return this};g.prototype.search=function(a,b,c,d){let f=a,e;var h=[];"object"===typeof a&&((c=a.callback||b)&&(f.callback=null),b=a.limit,e=a.threshold,a=a.query);e||(e=this.threshold||0);F(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.c)for(this.B=c,this.o=0,this.h=[],h=0;h<this.c;h++)this.i[h].postMessage({search:!0,limit:b,threshold:e,content:a});else{if(!d){if(this.async&&"function"!==
typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(f,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!E(a))return h;f=a;if(this.cache)if(this.v){if(c=this.j.get(a))return c}else this.j.clear(),this.v=!0;f=this.encode(f);if(!f.length)return h;c=this.b;c=F(c)?c(f):f.split(L);d=c.length;var g=!0,m=[],n=r();if(1<d)if(this.depth){var k=!0;var q=c[0];n[q]=1}else c.sort(S);var p;if(!k||(p=this.g)[q])for(let a=
k?1:0;a<d;a++){const b=c[a];if(b){if(!n[b]){const a=[];let c=!1,d=0;if(q=k?p[q]:this.f){let f;for(let h=0;h<10-e;h++)if(f=q[h][b])a[d++]=f,c=!0}if(c)m[m.length]=1<d?a.concat.apply([],a):a[0];else if(!this.u){g=!1;break}n[b]=1}q=b}}else g=!1;g&&(h=U(m,b,this.u));this.cache&&this.j.set(a,h);return h}};g.prototype.info=function(){if(this.c)for(var a=0;a<this.c;a++)this.i[a].postMessage({info:!0,id:this.id});else{var b=0,c=0,d=0;for(var f=0;f<10-(this.threshold||0);f++){a=Object.keys(this.f[f]);for(let h=
0;h<a.length;h++){var e=this.f[f][a[h]].length;b+=1*e+2*a[h].length+4;c+=e;d+=2*a[h].length}}a=Object.keys(this.a);e=a.length;for(f=0;f<e;f++)b+=2*a[f].length+2;return{id:this.id,memory:b,items:e,sequences:c,chars:d,cache:this.cache&&this.cache.l?this.cache.l.length:!1,matcher:G.length+(this.m?this.m.length:0),worker:this.c,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.b}}};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=function(){this.cache&&
(this.j.clear(),this.j=null);this.f=this.g=this.a=null;return this};g.prototype.export=function(){return JSON.stringify([this.f,this.g,this.a])};g.prototype.import=function(a){a=JSON.parse(a);this.f=a[0];this.g=a[1];this.a=a[2]};const D={icase:function(a){return a.toLowerCase()},simple:function(){const a=[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),
"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=x(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){const a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);
2<b.length&&(b=x(b,a));c||1<b.length&&(b=I(b));return b}}(),extra:function(){const a=[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+x(d.substring(1),a))}b=b.join(" ");b=I(b)}return b}}(),balance:function(){const a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return I(x(b.toLowerCase(),
a))}}()},W=function(){function a(a){this.clear();this.A=!0!==a&&a}a.prototype.clear=function(){this.cache=r();this.count=r();this.index=r();this.l=[]};a.prototype.set=function(a,c){if(this.A&&A(this.cache[a])){let b=this.l.length;if(b===this.A){b--;const a=this.l[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.l[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.A&&b){var d=++this.count[a];
const b=this.index;let c=b[a];if(0<c){const e=this.l;for(var f=c;this.count[e[--c]]<=d&&-1!==c;);c++;if(c!==f){for(d=f;d>c;d--)f=e[d-1],e[d]=f,b[f]=d;e[c]=a;b[a]=c}}}return b};return a}();return g}(function(){const u={},B="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(g,v,e,x,y){e=B?URL.createObjectURL(new Blob(["("+e.toString()+")()"],{type:"text/javascript"})):g+".min.js";g+="-"+v;u[g]||(u[g]=[]);u[g][y]=new Worker(e);u[g][y].onmessage=x;return u[g][y]}}()),
this);
{
"name": "flexsearch",
"version": "0.3.4",
"version": "0.3.5",
"description": "Next-Generation full text search library with zero dependencies.",

@@ -28,7 +28,7 @@ "homepage": "https://github.com/nextapps-de/flexsearch/",

"scripts": {
"build": "node compile RELEASE=min DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-light": "node compile RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-compact": "node compile RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=false SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-es5": "node compile RELEASE=es5 DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
"build": "node compile RELEASE=min DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-light": "node compile RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-compact": "node compile RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=false SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-es5": "node compile RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
"build-lang": "node compile RELEASE=lang",

@@ -46,3 +46,2 @@ "build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-lang",

"flexsearch.js",
"flexsearch.min.js",
"lang/",

@@ -49,0 +48,0 @@ "test/",

@@ -19,3 +19,3 @@ <p align="center">

When it comes to raw search speed <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">FlexSearch outperforms every single searching library out there</a> and also provides flexible search capabilities like multi-word matching, phonetic transformations or partial matching.
Depending on the used options it also providing the <a href="#memory">most memory-efficient index</a>. Keep in mind that updating and/or removing existing items from the index has a significant cost. When your index needs to be updated very often then <a href="bulksearch/" target="_blank">BulkSearch</a> may be a better choice.
Depending on the used options it also providing the <a href="#memory">most memory-efficient index</a>. Keep in mind that updating and/or removing existing items from the index has a significant cost. When your index needs to be updated very often then <a href="https://github.com/nextapps-de/bulksearch" target="_blank">BulkSearch</a> may be a better choice.
FlexSearch also provides you a non-blocking asynchronous processing model as well as web workers to perform any updates or queries on the index in parallel through dedicated balanced threads.

@@ -90,3 +90,3 @@

<td>
<a href="#async">Async Processing</a>
<a href="#async_search">Async Search</a>
</td>

@@ -393,3 +393,3 @@ <td>x</td>

__Note:__ This feature is actually not enabled by default. Read <a href="contextual_enable">here</a> how to enable.
__Note:__ This feature is actually not enabled by default. Read <a href="#contextual_enable">here</a> how to enable.

@@ -432,3 +432,3 @@ #### Compare BulkSearch vs. FlexSearch

<td><ul><li>less powerful contextual search</li><li>less memory efficient (has to be defragmented from time to time)</li></ul></td>
<td><ul><li>updating / deleting extisting items from index is slow</li><li>adding items to the index optimized for super partial matching (tokenize: "full") is slow</li></ul></td>
<td><ul><li>updating / deleting existing items from index is slow</li><li>adding items to the index optimized for super partial matching (tokenize: "full") is slow</li></ul></td>
</tr>

@@ -617,2 +617,3 @@ <tr></tr>

<a name="async_search"></a>
#### Async Search

@@ -1075,3 +1076,3 @@ Perform queries asynchronously:

"strict"<br>
"foward"<br>
"forward"<br>
"reverse"<br>

@@ -1218,3 +1219,3 @@ <!--"ngram"<br>-->

<tr>
<td><b>"foward"</b></td>
<td><b>"forward"</b></td>
<td>incrementally index words in forward direction</td>

@@ -1568,3 +1569,2 @@ <td><b>fo</b>obar<br><b>foob</b>ar<br></td>

<a name="builds"></a>
## Best Practices

@@ -1574,9 +1574,55 @@

Whenenver you can, try to divide content by categories and add them to its own index, e.g.:
Whenever you can, try to divide content by categories and add them to its own index, e.g.:
```js
var feeds_2017 = new FlexSearch();
var feeds_2018 = new FlexSearch();
var feeds_2019 = new FlexSearch();
var action = new FlexSearch();
var adventure = new FlexSearch();
var comedy = new FlexSearch();
```
This way you can also provide different settings for each category.
To make this workaround more extendable you can define a tiny helper:
```js
var settings = {};
var index = {};
function add(id, cat, content){
(index[cat] || (
index[cat] = new FlexSearch(settings[cat])
)).add(id, content);
}
function search(cat, query){
return index[cat] ? index[cat].search(query) : [];
}
```
Provide settings optionally (or skip and use defaults):
```js
settings = {
action: "score",
adventure: "match",
comedy: {
encode: "advanced",
tokenize: "forward",
threshold: 5
}
};
```
Add content to the index:
```js
add(1, "action", "Movie Title");
add(2, "adventure", "Movie Title");
add(3, "comedy", "Movie Title");
```
Perform queries:
```js
var results = search("action", "movie title"); // --> [1]
```
Filter queries by categories will hugely improve performance.
__Use numeric IDs__

@@ -1782,3 +1828,8 @@

</tr>
<tr></tr>
<tr>
<td>SUPPORT_SERIALIZE</td>
<td>true, false</td>
</tr>
<tr>
<td><br><b>Language Flags </b>(includes stemmer and filter)</td>

@@ -1785,0 +1836,0 @@ <td></td>

/*
FlexSearch v0.3.3
FlexSearch v0.3.5
Copyright 2019 Nextapps GmbH

@@ -8,30 +8,31 @@ Author: Thomas Wilkerling

*/
'use strict';function I(g){var h=0;return function(){return h<g.length?{done:!1,value:g[h++]}:{done:!0}}}function J(g){var h="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return h?h.call(g):{next:I(g)}}var R="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,S="function"==typeof Object.defineProperties?Object.defineProperty:function(g,h,e){g!=Array.prototype&&g!=Object.prototype&&(g[h]=e.value)};
function T(g,h){if(h){var e=R;g=g.split(".");for(var k=0;k<g.length-1;k++){var a=g[k];a in e||(e[a]={});e=e[a]}g=g[g.length-1];k=e[g];h=h(k);h!=k&&null!=h&&S(e,g,{configurable:!0,writable:!0,value:h})}}
T("Promise",function(g){function h(d){this.b=0;this.g=void 0;this.a=[];var a=this.c();try{d(a.resolve,a.reject)}catch(y){a.reject(y)}}function e(){this.a=null}function k(d){return d instanceof h?d:new h(function(a){a(d)})}if(g)return g;e.prototype.b=function(d){if(null==this.a){this.a=[];var a=this;this.c(function(){a.g()})}this.a.push(d)};var a=R.setTimeout;e.prototype.c=function(d){a(d,0)};e.prototype.g=function(){for(;this.a&&this.a.length;){var d=this.a;this.a=[];for(var a=0;a<d.length;++a){var h=
d[a];d[a]=null;try{h()}catch(C){this.f(C)}}}this.a=null};e.prototype.f=function(d){this.c(function(){throw d;})};h.prototype.c=function(){function d(d){return function(e){h||(h=!0,d.call(a,e))}}var a=this,h=!1;return{resolve:d(this.s),reject:d(this.f)}};h.prototype.s=function(d){if(d===this)this.f(new TypeError("A Promise cannot resolve to itself"));else if(d instanceof h)this.u(d);else{a:switch(typeof d){case "object":var a=null!=d;break a;case "function":a=!0;break a;default:a=!1}a?this.o(d):this.j(d)}};
h.prototype.o=function(a){var d=void 0;try{d=a.then}catch(y){this.f(y);return}"function"==typeof d?this.v(d,a):this.j(a)};h.prototype.f=function(a){this.l(2,a)};h.prototype.j=function(a){this.l(1,a)};h.prototype.l=function(a,h){if(0!=this.b)throw Error("Cannot settle("+a+", "+h+"): Promise already settled in state"+this.b);this.b=a;this.g=h;this.m()};h.prototype.m=function(){if(null!=this.a){for(var a=0;a<this.a.length;++a)m.b(this.a[a]);this.a=null}};var m=new e;h.prototype.u=function(a){var d=this.c();
a.A(d.resolve,d.reject)};h.prototype.v=function(a,h){var d=this.c();try{a.call(h,d.resolve,d.reject)}catch(C){d.reject(C)}};h.prototype.then=function(a,e){function d(a,d){return"function"==typeof a?function(d){try{g(a(d))}catch(F){k(F)}}:d}var g,k,l=new h(function(a,d){g=a;k=d});this.A(d(a,g),d(e,k));return l};h.prototype.catch=function(a){return this.then(void 0,a)};h.prototype.A=function(a,h){function d(){switch(e.b){case 1:a(e.g);break;case 2:h(e.g);break;default:throw Error("Unexpected state: "+
e.b);}}var e=this;null==this.a?m.b(d):this.a.push(d)};h.resolve=k;h.reject=function(a){return new h(function(d,h){h(a)})};h.race=function(a){return new h(function(d,h){for(var e=J(a),g=e.next();!g.done;g=e.next())k(g.value).A(d,h)})};h.all=function(a){var d=J(a),e=d.next();return e.done?k([]):new h(function(a,h){function g(d){return function(h){l[d]=h;m--;0==m&&a(l)}}var l=[],m=0;do l.push(void 0),m++,k(e.value).A(g(l.length-1),h),e=d.next();while(!e.done)})};return h});
(function(g,h,e){var k;(k=e.define)&&k.amd?k([],function(){return h}):(k=e.modules)?k[g.toLowerCase()]=h:"object"===typeof exports?module.exports=h:e[g]=h})("FlexSearch",function Y(g){function e(b){G(b)&&(b=K[b]);b||(b=u);this.id=b.id||Z++;this.init(b);k(this,"index",function(){return this.a});k(this,"length",function(){return Object.keys(this.a).length})}function k(b,c,a){Object.defineProperty(b,c,{get:a})}function a(b){return new RegExp(b,"g")}function m(b,c){for(var a=0;a<c.length;a+=2)b=b.replace(c[a],
c[a+1]);return b}function d(b,c,a,f,d,L,e){if(c[a])return c[a];d=d?(9-(e||6))*L+(e||6)*d:L;c[a]=d;d>=e&&(b=b[9-(d+.5>>0)],b=b[a]||(b[a]=[]),b[b.length]=f);return d}function l(b,c){if(b)for(var a=Object.keys(b),f=0,d=a.length;f<d;f++){var e=a[f],g=b[e];if(g)for(var A=0,k=g.length;A<k;A++)if(g[A]===c){1===k?delete b[e]:g.splice(A,1);break}else"object"===typeof g[A]&&l(g[A],c)}}function y(b){for(var c="",a="",f="",d=0;d<b.length;d++){var e=b[d];if(e!==a)if(d&&"h"===e){if(f="a"===f||"e"===f||"i"===f||
"o"===f||"u"===f||"y"===f,("a"===a||"e"===a||"i"===a||"o"===a||"u"===a||"y"===a)&&f||" "===a)c+=e}else c+=e;f=d===b.length-1?"":b[d+1];a=e}return c}function C(b,c){var a=v();if(b)for(var f=0;f<b.length;f++){var d=c?c(b[f]):b[f];a[d]=String.fromCharCode(65E3-b.length+f)}return a}function U(b,c){var d=[];if(b)for(var f in b)if(b.hasOwnProperty(f)){var e=c?c(f):f;d.push(a("(?=.{"+(e.length+3)+",})"+e+"$"),c?c(b[f]):b[f])}return d}function X(b,c){b=b.length-c.length;return 0>b?1:b?-1:0}function V(b,c){b=
b.length-c.length;return 0>b?-1:b?1:0}function W(b,c,a){var f=[],d=b.length;if(1<d){b.sort(V);for(var e=v(),w=b[0],A=w.length,g=0;g<A;)e["@"+w[g++]]=1;for(var k,r=0,p=0;++p<d;){var q=!1,l=p===d-1;var n=[];w=b[p];A=w.length;for(g=0;g<A;){k=w[g++];var m="@"+k;if(e[m]){var z=e[m];if(z===p){if(l){if(f[r++]=k,c&&r===c)return f}else e[m]=p+1;q=!0}else a&&(m=n[z]||(n[z]=[]),m[m.length]=k)}}if(!q&&!a)break}if(a&&(r=f.length,(p=n.length)&&(!c||r<c)))for(;p--;)if(k=n[p])for(b=0,a=k.length;b<a;b++)if(f[r++]=
k[b],c&&r===c)return f}else d&&(f=b[0],c&&f.length>c&&(f=f.slice(0,c)));return f}function G(b){return"string"===typeof b}function F(b){return"function"===typeof b}function x(b){return"undefined"===typeof b}function D(b){b.F||(b.F=M(function(){b.F=0;var c=b.async;c&&(b.async=!1);if(b.b.length){for(var a=Date.now(),f;(f=b.b.shift())||0===f;){var d=b.f[f];switch(d[0]){case E.add:b.add(d[1],d[2]);break;case E.remove:b.remove(d[1])}delete b.f[f];if(100<Date.now()-a)break}b.b.length&&D(b)}c&&(b.async=c)},
1,"@"+b.id))}function N(b){for(var c=Array(b),a=0;a<b;a++)c[a]=v();return c}function v(){return Object.create(null)}function aa(b,c,a,f){b=g("flexsearch","id"+b,function(){var b,c;self.onmessage=function(a){if(a=a.data)if(a.search){var f=c.search(a.content,a.threshold?{limit:a.limit,threshold:a.threshold}:a.limit);self.postMessage({id:b,content:a.content,limit:a.limit,result:f})}else a.add?c.add(a.id,a.content):a.update?c.update(a.id,a.content):a.remove?c.remove(a.id):a.clear?c.clear():a.register&&
(b=a.id,a.options.cache=!1,a.options.async=!0,a.options.worker=!1,c=(new Function(a.register.substring(a.register.indexOf("{")+1,a.register.lastIndexOf("}"))))(),c=new c(a.options))}},function(b){(b=b.data)&&b.result&&f(b.id,b.content,b.result,b.limit)},c);var d=Y.toString();a.id=c;b.postMessage(c,{register:d,options:a,id:c});return b}var u={encode:"icase",h:"forward",w:!1,cache:!1,async:!1,i:!1,threshold:0,depth:0},K={memory:{encode:"extra",h:"strict",threshold:7},speed:{encode:"icase",h:"strict",
threshold:7,depth:2},match:{encode:"extra",h:"full"},score:{encode:"extra",h:"strict",threshold:5,depth:4},balance:{encode:"balance",h:"strict",threshold:6,depth:3},fastest:{encode:"icase",h:"strict",threshold:9,depth:1}},H=[],Z=0,E={add:0,update:1,remove:2},O=a("\\W+"),P={},Q={};(function(){for(var b=Object.getOwnPropertyNames({}.__proto__),c=v(),a=0;a<b.length;a++)c[b[a]]=1;return c})();e.create=function(b){return new e(b)};e.registerMatcher=function(b){for(var c in b)b.hasOwnProperty(c)&&H.push(a(c),
b[c]);return this};e.registerEncoder=function(b,c){B[b]=c.bind(B);return this};e.registerLanguage=function(b,c){P[b]=c.filter;Q[b]=c.stemmer;return this};e.encode=function(b,c){return B[b](c)};e.prototype.init=function(b){this.D=[];b||(b=u);var c=b.profile,a=c?K[c]:{};if(c=b.worker)if(Worker){var f=this,d=parseInt(c,10)||4;f.o=-1;f.s=0;f.g=[];f.C=null;f.m=Array(d);for(var e=0;e<d;e++)f.m[e]=aa(f.id,e,b,function(b,c,a,d){if(f.s!==f.i)return f.g=f.g.concat(a),f.s++,d&&f.g.length>=d&&(f.s=f.i),f.C&&
f.s===f.i&&(f.cache&&f.j.set(c,f.g),f.C(f.g),f.g=[]),f})}else b.worker=!1,this.m=null;this.h=b.tokenize||a.h||this.h||u.h;this.async=x(c=b.async)?this.async||u.async:c;this.i=x(c=b.worker)?this.i||u.i:c;this.threshold=x(c=b.threshold)?a.threshold||this.threshold||u.threshold:c;this.depth=x(c=b.depth)?a.depth||this.depth||u.depth:c;this.w=x(c=b.suggest)?this.w||u.w:c;this.u=(c=x(c=b.encode)?a.encode:c)&&B[c]&&B[c].bind(B)||(F(c)?c:this.u||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter)this.filter=
C(P[c]||c,this.u);if(c=b.stemmer)this.stemmer=U(Q[c]||c,this.u);this.l=N(10-(this.threshold||0));this.c=v();this.a=v();this.f=v();this.b=[];this.F=0;this.v=!0;this.j=(this.cache=c=x(c=b.cache)?this.cache||u.cache:c)?new ba(c):!1;return this};e.prototype.encode=function(b){b&&H.length&&(b=m(b,H));b&&this.D.length&&(b=m(b,this.D));b&&this.u&&(b=this.u(b));b&&this.stemmer&&(b=m(b,this.stemmer));return b};e.prototype.addMatcher=function(b){var c=this.D,d;for(d in b)b.hasOwnProperty(d)&&c.push(a(d),b[d]);
return this};e.prototype.add=function(b,c,a){if(c&&G(c)&&(b||0===b)){var f="@"+b;if(this.a[f]&&!a)this.update(b,c);else{if(this.i)return++this.o>=this.m.length&&(this.o=0),this.m[this.o].postMessage(this.o,{add:!0,id:b,content:c}),this.a[f]=""+this.o,this;if(this.async)return this.f[f]||(this.b[this.b.length]=f),this.f[f]=[E.add,b,c],D(this),this;c=this.encode(c);if(!c.length)return this;a=this.h;c=F(a)?a(c):c.split(O);var e=v();e._ctx=v();for(var g=this.threshold,k=this.depth,w=this.l,m=c.length,
l=0;l<m;l++){var r=c[l];if(r){var p=r.length,q=(m-l)/m,t="";switch(a){case "reverse":case "both":for(var n=p-1;1<=n;n--)t=r[n]+t,d(w,e,t,b,(p-n)/p,q,g);t="";case "forward":for(n=0;n<p;n++)t+=r[n],d(w,e,t,b,1,q,g);break;case "full":for(n=0;n<p;n++)for(var y=(p-n)/p,z=p;z>n;z--)t=r.substring(n,z),d(w,e,t,b,y,q,g);break;default:if(p=d(w,e,r,b,1,q,g),k&&1<m&&p>=g)for(p=e._ctx[r]||(e._ctx[r]=v()),r=this.c[r]||(this.c[r]=N(10-(g||0))),q=l-k,t=l+k+1,0>q&&(q=0),t>m&&(t=m);q<t;q++)q!==l&&d(r,p,c[q],b,0,10-
(q<l?l-q:q-l),g)}}}this.a[f]=1;this.v=!1}}return this};e.prototype.update=function(b,c){this.a["@"+b]&&G(c)&&(this.remove(b),this.add(b,c,!0));return this};e.prototype.remove=function(b){var c="@"+b;if(this.a[c]){if(this.i){var a=this.a[c];this.m[a].postMessage(a,{remove:!0,id:b});delete this.a[c];return this}if(this.async)return this.f[c]||(this.b[this.b.length]=c),this.f[c]=[E.remove,b],D(this),this;for(a=0;a<10-(this.threshold||0);a++)l(this.l[a],b);this.depth&&l(this.c,b);delete this.a[c];this.v=
!1}return this};e.prototype.search=function(b,a,d,f){var c=b,e=[];if("object"===typeof b){(d=b.callback||a)&&(c.callback=null);a=b.limit;var g=b.threshold;b=b.query}g||(g=this.threshold||0);F(a)?(d=a,a=1E3):a||0===a||(a=1E3);if(this.i)for(this.C=d,this.s=0,this.g=[],e=0;e<this.i;e++)this.m[e].postMessage(e,{search:!0,limit:a,threshold:g,content:b});else if(d){var k=this;M(function(){d(k.search(c,a,null,!0));k=null},1,"search-"+this.id)}else{if(!f&&this.async&&"function"!==typeof importScripts){var l=
this;return new Promise(function(b){b(l.search(c,a,null,!0));l=null})}if(!b||!G(b))return e;c=b;if(this.cache)if(this.v){if(f=this.j.get(b))return f}else this.j.clear(),this.v=!0;c=this.encode(c);if(!c.length)return e;f=this.h;f=F(f)?f(c):c.split(O);var m=f.length,w=!0,p=[],q=v();if(1<m)if(this.depth){var t=!0;var n=f[0];q[n]=1}else f.sort(X);var y;if(!t||(y=this.c)[n])for(var z=t?1:0;z<m;z++){var u=f[z];if(u){if(!q[u]){var x=[],C=!1,B=0;if(n=t?y[n]:this.l)for(var E=void 0,D=0;D<10-g;D++)if(E=n[D][u])x[B++]=
E,C=!0;if(C)p[p.length]=1<B?x.concat.apply([],x):x[0];else if(!this.w){w=!1;break}q[u]=1}n=u}}else w=!1;w&&(e=W(p,a,this.w));this.cache&&this.j.set(b,e);return e}};e.prototype.clear=function(){this.destroy();return this.init()};e.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.filter=this.stemmer=this.l=this.c=this.a=this.f=this.b=null;return this};e.prototype.export=function(){return JSON.stringify([this.l,this.c,this.a])};e.prototype.import=function(b){b=JSON.parse(b);
this.l=b[0];this.c=b[1];this.a=b[2]};var B={icase:function(b){return b.toLowerCase()},simple:function(){var b=[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("\u00e7"),"c",a("\u00df"),"s",a(" & ")," and ",a("[-/]")," ",a("[^a-z0-9 ]"),"",a("\\s+")," "];return function(a){a=m(a.toLowerCase(),
b);return" "!==a?a:""}}(),advanced:function(){var b=[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("dt"),"t",a("ph"),"f",a("pf"),"f",a("ou"),"o",a("uo"),"u"];return function(a,d){if(!a)return a;a=this.simple(a);2<a.length&&(a=m(a,b));d||1<a.length&&(a=y(a));return a}}(),extra:function(){var b=[a("p"),"b",a("z"),"s",a("[cgq]"),"k",a("n"),"m",a("d"),"t",a("[vw]"),"f",a("[aeiouy]"),""];return function(a){if(!a)return a;
a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(var c=0;c<a.length;c++){var d=a[c];1<d.length&&(a[c]=d[0]+m(d.substring(1),b))}a=a.join(" ");a=y(a)}return a}}(),balance:function(){var b=[a("[-/]")," ",a("[^a-z0-9 ]"),"",a("\\s+")," "];return function(a){return y(m(a.toLowerCase(),b))}}()},M=function(){var a=v();return function(b,d,f){var c=a[f];c&&clearTimeout(c);return a[f]=setTimeout(b,d)}}(),ba=function(){function a(a){this.clear();this.B=!0!==a&&a}a.prototype.clear=function(){this.cache=
v();this.count=v();this.index=v();this.a=[]};a.prototype.set=function(a,b){if(this.B&&x(this.cache[a])){var c=this.a.length;if(c===this.B){c--;var d=this.a[c];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=c;this.a[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};a.prototype.get=function(a){var b=this.cache[a];if(this.B&&b){var c=++this.count[a],d=this.index,e=d[a];if(0<e){for(var g=this.a,k=e;this.count[g[--e]]<=c&&-1!==e;);e++;if(e!==k){for(c=
k;c>e;c--)k=g[c-1],g[c]=k,d[k]=c;g[e]=a;d[a]=e}}}return b};return a}();return e}(function(){var g={},h="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,k,a,m,d){var l=e;e=h?URL.createObjectURL(new Blob(["("+a.toString()+")()"],{type:"text/javascript"})):l+".es5.js";l+="-"+k;g[l]||(g[l]=[]);g[l][d]=new Worker(e);g[l][d].onmessage=m;return{postMessage:function(a,d){g[l][a].postMessage(d)}}}}()),this);
'use strict';function I(g){var k=0;return function(){return k<g.length?{done:!1,value:g[k++]}:{done:!0}}}function J(g){var k="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return k?k.call(g):{next:I(g)}}var Q="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,R="function"==typeof Object.defineProperties?Object.defineProperty:function(g,k,e){g!=Array.prototype&&g!=Object.prototype&&(g[k]=e.value)};
function S(g,k){if(k){var e=Q;g=g.split(".");for(var h=0;h<g.length-1;h++){var a=g[h];a in e||(e[a]={});e=e[a]}g=g[g.length-1];h=e[g];k=k(h);k!=h&&null!=k&&R(e,g,{configurable:!0,writable:!0,value:k})}}
S("Promise",function(g){function k(d){this.b=0;this.g=void 0;this.a=[];var a=this.c();try{d(a.resolve,a.reject)}catch(q){a.reject(q)}}function e(){this.a=null}function h(d){return d instanceof k?d:new k(function(a){a(d)})}if(g)return g;e.prototype.b=function(d){if(null==this.a){this.a=[];var a=this;this.c(function(){a.g()})}this.a.push(d)};var a=Q.setTimeout;e.prototype.c=function(d){a(d,0)};e.prototype.g=function(){for(;this.a&&this.a.length;){var d=this.a;this.a=[];for(var a=0;a<d.length;++a){var e=
d[a];d[a]=null;try{e()}catch(D){this.f(D)}}}this.a=null};e.prototype.f=function(d){this.c(function(){throw d;})};k.prototype.c=function(){function d(d){return function(k){e||(e=!0,d.call(a,k))}}var a=this,e=!1;return{resolve:d(this.u),reject:d(this.f)}};k.prototype.u=function(d){if(d===this)this.f(new TypeError("A Promise cannot resolve to itself"));else if(d instanceof k)this.v(d);else{a:switch(typeof d){case "object":var a=null!=d;break a;case "function":a=!0;break a;default:a=!1}a?this.o(d):this.j(d)}};
k.prototype.o=function(a){var d=void 0;try{d=a.then}catch(q){this.f(q);return}"function"==typeof d?this.w(d,a):this.j(a)};k.prototype.f=function(a){this.l(2,a)};k.prototype.j=function(a){this.l(1,a)};k.prototype.l=function(a,e){if(0!=this.b)throw Error("Cannot settle("+a+", "+e+"): Promise already settled in state"+this.b);this.b=a;this.g=e;this.m()};k.prototype.m=function(){if(null!=this.a){for(var a=0;a<this.a.length;++a)l.b(this.a[a]);this.a=null}};var l=new e;k.prototype.v=function(a){var d=this.c();
a.B(d.resolve,d.reject)};k.prototype.w=function(a,e){var d=this.c();try{a.call(e,d.resolve,d.reject)}catch(D){d.reject(D)}};k.prototype.then=function(a,e){function d(a,d){return"function"==typeof a?function(d){try{g(a(d))}catch(C){h(C)}}:d}var g,h,l=new k(function(a,d){g=a;h=d});this.B(d(a,g),d(e,h));return l};k.prototype.catch=function(a){return this.then(void 0,a)};k.prototype.B=function(a,e){function d(){switch(k.b){case 1:a(k.g);break;case 2:e(k.g);break;default:throw Error("Unexpected state: "+
k.b);}}var k=this;null==this.a?l.b(d):this.a.push(d)};k.resolve=h;k.reject=function(a){return new k(function(d,e){e(a)})};k.race=function(a){return new k(function(d,e){for(var k=J(a),g=k.next();!g.done;g=k.next())h(g.value).B(d,e)})};k.all=function(a){var e=J(a),d=e.next();return d.done?h([]):new k(function(a,k){function g(d){return function(e){l[d]=e;q--;0==q&&a(l)}}var l=[],q=0;do l.push(void 0),q++,h(d.value).B(g(l.length-1),k),d=e.next();while(!d.done)})};return k});
(function(g,k,e){var h;(h=e.define)&&h.amd?h([],function(){return k}):(h=e.modules)?h[g.toLowerCase()]=k:"object"===typeof exports?module.exports=k:e[g]=k})("FlexSearch",function X(g){function e(b){E(b)&&((b=K[b])||console.warn("Preset not found: "+b));b||(b=x);this.id=b.id||Y++;this.init(b);h(this,"index",function(){return this.a});h(this,"length",function(){return Object.keys(this.a).length})}function h(b,c,a){Object.defineProperty(b,c,{get:a})}function a(b){return new RegExp(b,"g")}function l(b,
c){for(var a=0;a<c.length;a+=2)b=b.replace(c[a],c[a+1]);return b}function d(b,c,a,f,d,L,e){if(c[a])return c[a];d=d?(9-(e||6))*L+(e||6)*d:L;c[a]=d;d>=e&&(b=b[9-(d+.5>>0)],b=b[a]||(b[a]=[]),b[b.length]=f);return d}function G(b,c){if(b)for(var a=Object.keys(b),f=0,d=a.length;f<d;f++){var e=a[f],g=b[e];if(g)for(var A=0,h=g.length;A<h;A++)if(g[A]===c){1===h?delete b[e]:g.splice(A,1);break}else"object"===typeof g[A]&&G(g[A],c)}}function q(b){for(var c="",a="",f="",d=0;d<b.length;d++){var e=b[d];if(e!==
a)if(d&&"h"===e){if(f="a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f,("a"===a||"e"===a||"i"===a||"o"===a||"u"===a||"y"===a)&&f||" "===a)c+=e}else c+=e;f=d===b.length-1?"":b[d+1];a=e}return c}function D(b,c){var a=y();if(b)for(var f=0;f<b.length;f++){var d=c?c(b[f]):b[f];a[d]=String.fromCharCode(65E3-b.length+f)}return a}function T(b,c){var d=[];if(b)for(var f in b)if(b.hasOwnProperty(f)){var e=c?c(f):f;d.push(a("(?=.{"+(e.length+3)+",})"+e+"$"),c?c(b[f]):b[f])}return d}function W(b,c){b=b.length-
c.length;return 0>b?1:b?-1:0}function U(b,c){b=b.length-c.length;return 0>b?-1:b?1:0}function V(b,c,a){var f=[],d=b.length;if(1<d){b.sort(U);for(var e=y(),z=b[0],A=z.length,g=0;g<A;)e["@"+z[g++]]=1;for(var h,l=0,t=0;++t<d;){var r=!1,u=t===d-1;var n=[];z=b[t];A=z.length;for(g=0;g<A;){h=z[g++];var m="@"+h;if(e[m]){var p=e[m];if(p===t){if(u){if(f[l++]=h,c&&l===c)return f}else e[m]=t+1;r=!0}else a&&(m=n[p]||(n[p]=[]),m[m.length]=h)}}if(!r&&!a)break}if(a&&(l=f.length,(t=n.length)&&(!c||l<c)))for(;t--;)if(h=
n[t])for(b=0,a=h.length;b<a;b++)if(f[l++]=h[b],c&&l===c)return f}else d&&(f=b[0],c&&f.length>c&&(f=f.slice(0,c)));return f}function E(b){return"string"===typeof b}function C(b){return"function"===typeof b}function w(b){return"undefined"===typeof b}function M(b){for(var c=Array(b),a=0;a<b;a++)c[a]=y();return c}function y(){return Object.create(null)}function Z(b,c,a,f){b=g("flexsearch","id"+b,function(){var b,c;self.onmessage=function(a){if(a=a.data)if(a.search){var f=c.search(a.content,a.threshold?
{limit:a.limit,threshold:a.threshold}:a.limit);self.postMessage({id:b,content:a.content,limit:a.limit,result:f})}else a.add?c.add(a.id,a.content):a.update?c.update(a.id,a.content):a.remove?c.remove(a.id):a.clear?c.clear():a.info?(a=c.info(),a.worker=b,console.log(a)):a.register&&(b=a.id,a.options.cache=!1,a.options.async=!1,a.options.worker=!1,c=(new Function(a.register.substring(a.register.indexOf("{")+1,a.register.lastIndexOf("}"))))(),c=new c(a.options))}},function(b){(b=b.data)&&b.result&&f(b.id,
b.content,b.result,b.limit)},c);var d=X.toString();a.id=c;b.postMessage({register:d,options:a,id:c});return b}var x={encode:"icase",h:"forward",A:!1,cache:!1,async:!1,i:!1,threshold:0,depth:0},K={memory:{encode:"extra",h:"strict",threshold:7},speed:{encode:"icase",h:"strict",threshold:7,depth:2},match:{encode:"extra",h:"full"},score:{encode:"extra",h:"strict",threshold:5,depth:4},balance:{encode:"balance",h:"strict",threshold:6,depth:3},fastest:{encode:"icase",h:"strict",threshold:9,depth:1}},F=[],
Y=0,N=a("\\W+"),O={},P={};(function(){for(var b=Object.getOwnPropertyNames({}.__proto__),c=y(),a=0;a<b.length;a++)c[b[a]]=1;return c})();e.create=function(b){return new e(b)};e.registerMatcher=function(b){for(var c in b)b.hasOwnProperty(c)&&F.push(a(c),b[c]);return this};e.registerEncoder=function(b,c){B[b]=c.bind(B);return this};e.registerLanguage=function(b,c){O[b]=c.filter;P[b]=c.stemmer;return this};e.encode=function(b,c){return B[b](c)};e.prototype.init=function(b){this.l=[];b||(b=x);var c=b.profile,
a=c?K[c]:{};a||console.warn("Preset not found: "+c);if(c=b.worker)if("undefined"!==typeof Worker){var f=this,d=parseInt(c,10)||4;f.v=-1;f.m=0;f.f=[];f.w=null;f.g=Array(d);for(var e=0;e<d;e++)f.g[e]=Z(f.id,e,b,function(b,c,a,d){if(f.m!==f.i)return f.f=f.f.concat(a),f.m++,d&&f.f.length>=d&&(f.m=f.i),f.w&&f.m===f.i&&(f.cache&&f.j.set(c,f.f),f.w(f.f),f.f=[]),f})}else b.worker=!1,this.g=null;this.h=b.tokenize||a.h||this.h||x.h;this.async="undefined"===typeof Promise||w(c=b.async)?this.async||x.async:c;
this.i=w(c=b.worker)?this.i||x.i:c;this.threshold=w(c=b.threshold)?a.threshold||this.threshold||x.threshold:c;this.depth=w(c=b.depth)?a.depth||this.depth||x.depth:c;this.A=w(c=b.suggest)?this.A||x.A:c;this.o=(c=w(c=b.encode)?a.encode:c)&&B[c]&&B[c].bind(B)||(C(c)?c:this.o||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter)this.filter=D(O[c]||c,this.o);if(c=b.stemmer)this.stemmer=T(P[c]||c,this.o);this.b=M(10-(this.threshold||0));this.c=y();this.a=y();this.u=!0;this.j=(this.cache=c=w(c=b.cache)?
this.cache||x.cache:c)?new aa(c):!1;return this};e.prototype.encode=function(b){b&&F.length&&(b=l(b,F));b&&this.l.length&&(b=l(b,this.l));b&&this.o&&(b=this.o(b));b&&this.stemmer&&(b=l(b,this.stemmer));return b};e.prototype.addMatcher=function(b){var c=this.l,d;for(d in b)b.hasOwnProperty(d)&&c.push(a(d),b[d]);return this};e.prototype.add=function(b,c,a,f,e){if(c&&E(c)&&(b||0===b)){var g="@"+b;if(this.a[g]&&!f)return this.update(b,c);if(this.i)return++this.v>=this.g.length&&(this.v=0),this.g[this.v].postMessage({add:!0,
id:b,content:c}),this.a[g]=""+this.v,a&&a(),this;if(!e){if(this.async&&"function"!==typeof importScripts){var z=this;g=new Promise(function(a){setTimeout(function(){z.add(b,c,null,f,!0);z=null;a()})});if(a)g.then(a);else return g;return this}if(a)return this.add(b,c,null,f,!0),a(),this}c=this.encode(c);if(!c.length)return this;a=this.h;e=C(a)?a(c):c.split(N);var h=y();h._ctx=y();for(var l=this.threshold,H=this.depth,q=this.b,t=e.length,r=0;r<t;r++){var u=e[r];if(u){var n=u.length,m=(t-r)/t,p="";switch(a){case "reverse":case "both":for(var v=
n-1;1<=v;v--)p=u[v]+p,d(q,h,p,b,(n-v)/n,m,l);p="";case "forward":for(v=0;v<n;v++)p+=u[v],d(q,h,p,b,1,m,l);break;case "full":for(v=0;v<n;v++)for(var x=(n-v)/n,w=n;w>v;w--)p=u.substring(v,w),d(q,h,p,b,x,m,l);break;default:if(n=d(q,h,u,b,1,m,l),H&&1<t&&n>=l)for(n=h._ctx[u]||(h._ctx[u]=y()),u=this.c[u]||(this.c[u]=M(10-(l||0))),m=r-H,p=r+H+1,0>m&&(m=0),p>t&&(p=t);m<p;m++)m!==r&&d(u,n,e[m],b,0,10-(m<r?r-m:m-r),l)}}}this.a[g]=1;this.u=!1}return this};e.prototype.update=function(b,a,d){this.a["@"+b]&&E(a)&&
(this.remove(b),this.add(b,a,d,!0));return this};e.prototype.remove=function(b,a,d){var c="@"+b;if(this.a[c]){if(this.i)return this.g[this.a[c]].postMessage({remove:!0,id:b}),delete this.a[c],a&&a(),this;if(!d){if(this.async&&"function"!==typeof importScripts){var e=this;c=new Promise(function(a){setTimeout(function(){e.remove(b,null,!0);e=null;a()})});if(a)c.then(a);else return c;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<10-(this.threshold||0);a++)G(this.b[a],b);this.depth&&
G(this.c,b);delete this.a[c];this.u=!1}return this};e.prototype.search=function(a,c,d,e){var b=a,f=[];if("object"===typeof a){(d=a.callback||c)&&(b.callback=null);c=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);C(c)?(d=c,c=1E3):c||0===c||(c=1E3);if(this.i)for(this.w=d,this.m=0,this.f=[],f=0;f<this.i;f++)this.g[f].postMessage({search:!0,limit:c,threshold:g,content:a});else{if(!e){if(this.async&&"function"!==typeof importScripts){var h=this;a=new Promise(function(a){setTimeout(function(){a(h.search(b,
c,null,!0));h=null})});if(d)a.then(d);else return a;return this}if(d)return d(this.search(b,c,null,!0)),this}if(!a||!E(a))return f;b=a;if(this.cache)if(this.u){if(d=this.j.get(a))return d}else this.j.clear(),this.u=!0;b=this.encode(b);if(!b.length)return f;d=this.h;d=C(d)?d(b):b.split(N);e=d.length;var l=!0,z=[],q=y();if(1<e)if(this.depth){var t=!0;var r=d[0];q[r]=1}else d.sort(W);var u;if(!t||(u=this.c)[r])for(var n=t?1:0;n<e;n++){var m=d[n];if(m){if(!q[m]){var p=[],v=!1,w=0;if(r=t?u[r]:this.b)for(var x=
void 0,B=0;B<10-g;B++)if(x=r[B][m])p[w++]=x,v=!0;if(v)z[z.length]=1<w?p.concat.apply([],p):p[0];else if(!this.A){l=!1;break}q[m]=1}r=m}}else l=!1;l&&(f=V(z,c,this.A));this.cache&&this.j.set(a,f);return f}};e.prototype.info=function(){if(this.i)for(var a=0;a<this.i;a++)this.g[a].postMessage({info:!0,id:this.id});else{for(var c,d=0,e=0,g=0,h=0;h<10-(this.threshold||0);h++){a=Object.keys(this.b[h]);for(var l=0;l<a.length;l++)c=this.b[h][a[l]].length,d+=1*c+2*a[l].length+4,e+=c,g+=2*a[l].length}a=Object.keys(this.a);
c=a.length;for(h=0;h<c;h++)d+=2*a[h].length+2;return{id:this.id,memory:d,items:c,sequences:e,chars:g,cache:this.cache&&this.cache.s?this.cache.s.length:!1,matcher:F.length+(this.l?this.l.length:0),worker:this.i,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.h}}};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.b=this.c=this.a=null;return this};e.prototype.export=function(){return JSON.stringify([this.b,
this.c,this.a])};e.prototype.import=function(a){a=JSON.parse(a);this.b=a[0];this.c=a[1];this.a=a[2]};var B={icase:function(a){return a.toLowerCase()},simple:function(){var b=[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("\u00e7"),"c",a("\u00df"),"s",a(" & ")," and ",a("[-/]")," ",a("[^a-z0-9 ]"),
"",a("\\s+")," "];return function(a){a=l(a.toLowerCase(),b);return" "!==a?a:""}}(),advanced:function(){var b=[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("dt"),"t",a("ph"),"f",a("pf"),"f",a("ou"),"o",a("uo"),"u"];return function(a,d){if(!a)return a;a=this.simple(a);2<a.length&&(a=l(a,b));d||1<a.length&&(a=q(a));return a}}(),extra:function(){var b=[a("p"),"b",a("z"),"s",a("[cgq]"),"k",a("n"),"m",
a("d"),"t",a("[vw]"),"f",a("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(var c=0;c<a.length;c++){var d=a[c];1<d.length&&(a[c]=d[0]+l(d.substring(1),b))}a=a.join(" ");a=q(a)}return a}}(),balance:function(){var b=[a("[-/]")," ",a("[^a-z0-9 ]"),"",a("\\s+")," "];return function(a){return q(l(a.toLowerCase(),b))}}()},aa=function(){function a(a){this.clear();this.C=!0!==a&&a}a.prototype.clear=function(){this.cache=y();this.count=y();this.index=
y();this.s=[]};a.prototype.set=function(a,b){if(this.C&&w(this.cache[a])){var c=this.s.length;if(c===this.C){c--;var d=this.s[c];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=c;this.s[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};a.prototype.get=function(a){var b=this.cache[a];if(this.C&&b){var c=++this.count[a],d=this.index,e=d[a];if(0<e){for(var g=this.s,h=e;this.count[g[--e]]<=c&&-1!==e;);e++;if(e!==h){for(c=h;c>e;c--)h=g[c-1],g[c]=h,d[h]=
c;g[e]=a;d[a]=e}}}return b};return a}();return e}(function(){var g={},k="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,h,a,l,d){a=k?URL.createObjectURL(new Blob(["("+a.toString()+")()"],{type:"text/javascript"})):e+".es5.js";e+="-"+h;g[e]||(g[e]=[]);g[e][d]=new Worker(a);g[e][d].onmessage=l;console.log("Register Worker: "+e+"@"+d);return g[e][d]}}()),this);

@@ -399,2 +399,4 @@ if(typeof module !== "undefined"){

expect(flexsearch_async.length).to.equal(0);
flexsearch_async.add(0, "foo");

@@ -426,4 +428,3 @@ flexsearch_async.add(2, "bar");

flexsearch_async.add(3, {});
flexsearch_async.add(3, function(){
});
flexsearch_async.add(3, function(){});

@@ -458,10 +459,5 @@ setTimeout(function(){

expect(result).to.include(1);
done();
});
// (async function(){
//
// expect(await flexsearch_async.search("foo")).to.have.members([0, 1]);
// })();
setTimeout(done, 25);
});

@@ -475,5 +471,5 @@

expect(result).to.not.include(1);
done();
});
setTimeout(done, 25);
});

@@ -501,5 +497,5 @@

expect(result).to.have.lengthOf(0);
done();
});
setTimeout(done, 25);
});

@@ -516,20 +512,2 @@ });

expect(flexsearch_async.length).to.equal(3);
flexsearch_async.search("foo").then(function(result){
expect(result).to.not.have.members([2, 1]);
});
flexsearch_async.search("bar").then(function(result){
expect(result).to.not.include(0);
});
flexsearch_async.search("bar").then(function(result){
expect(result).to.include(2);
});
flexsearch_async.search("foobar").then(function(result){
expect(result).to.not.include(2);
});
setTimeout(function(){

@@ -553,6 +531,6 @@

expect(result).to.include(2);
done();
});
done();
}, 25);

@@ -591,6 +569,6 @@ });

expect(result).to.include(2);
done();
});
done();
}, 25);

@@ -606,25 +584,21 @@ });

flexsearch_async.remove(2);
flexsearch_async.remove(1);
flexsearch_async.remove(1).then(function(){
expect(flexsearch_async.length).to.equal(0);
});
expect(flexsearch_async.length).to.equal(3);
setTimeout(function(){
flexsearch_async.search("foo", function(result){
expect(result).to.have.lengthOf(0);
});
expect(flexsearch_async.length).to.equal(0);
flexsearch_async.search("bar", function(result){
expect(result).to.have.lengthOf(0);
});
flexsearch_async.search("foo", function(result){
expect(result).to.have.lengthOf(0);
});
flexsearch_async.search("foobar", function(result){
expect(result).to.have.lengthOf(0);
flexsearch_async.search("bar", function(result){
expect(result).to.have.lengthOf(0);
});
flexsearch_async.search("foobar", function(result){
expect(result).to.have.lengthOf(0);
});
done();
}, 25);
});
});

@@ -637,173 +611,166 @@ });

describe("Add (Worker)", function(){
if(typeof Worker !== "undefined" && !this._phantom){
it("Should support worker", function(){
describe("Add (Worker)", function(){
if(typeof Worker === "undefined"){
it("Should support worker", function(){
Worker = function(){};
flexsearch_worker = new FlexSearch({
Worker.prototype.postMessage = function(val){
this.onmessage(val);
};
Worker.prototype.onmessage = function(val){
return val;
};
}
encode: "icase",
tokenize: "reverse",
async: false,
worker: 4
});
});
flexsearch_worker = new FlexSearch({
it("Should have been added to the index", function(done){
encode: "icase",
tokenize: "strict",
async: false,
worker: 4
});
});
flexsearch_worker.add(0, "foo");
flexsearch_worker.add(2, "bar");
flexsearch_worker.add(1, "foobar");
it("Should have been added to the index", function(done){
setTimeout(function(){
flexsearch_worker.add(0, "foo");
flexsearch_worker.add(2, "bar");
flexsearch_worker.add(1, "foobar");
expect(flexsearch_worker.length).to.equal(3);
expect(flexsearch_worker.index).to.have.keys(["@0", "@1", "@2"]);
expect(flexsearch_worker.length).to.equal(3);
expect(flexsearch_worker.index).to.have.keys(["@0", "@1", "@2"]);
flexsearch_worker.search("foo", function(result){
flexsearch_worker.search("foo", function(result){
expect(result).to.have.length(2);
expect(result).to.have.members([0, 1]);
expect(result).to.have.length(0);
done();
});
}, 25);
});
setTimeout(done, 25);
});
it("Should not have been added to the index", function(done){
it("Should not have been added to the index", function(done){
flexsearch_worker.add("foo");
flexsearch_worker.add(3);
flexsearch_worker.add(null, "foobar");
flexsearch_worker.add(void 0, "foobar");
flexsearch_worker.add(4, null);
flexsearch_worker.add(5, false);
flexsearch_worker.add(6, []);
flexsearch_worker.add(7, {});
flexsearch_worker.add(8, function(){
});
flexsearch_worker.add("foo");
flexsearch_worker.add(3);
flexsearch_worker.add(null, "foobar");
flexsearch_worker.add(void 0, "foobar");
flexsearch_worker.add(4, null);
flexsearch_worker.add(5, false);
flexsearch_worker.add(6, []);
flexsearch_worker.add(7, {});
flexsearch_worker.add(8, function(){});
setTimeout(function(){
setTimeout(function(){
expect(flexsearch_worker.length).to.equal(3);
expect(flexsearch_worker.index).to.have.keys(["@0", "@1", "@2"]);
expect(flexsearch_worker.length).to.equal(3);
expect(flexsearch_worker.index).to.have.keys(["@0", "@1", "@2"]);
done();
done();
}, 25);
}, 25);
});
});
});
describe("Search (Worker)", function(){
describe("Search (Worker)", function(){
it("Should have been matched from index", function(done){
it("Should have been matched from index", function(done){
flexsearch_worker.search("foo", function(result){
flexsearch_worker.search("foo", function(result){
expect(result).to.have.lengthOf(2);
});
expect(result).to.have.lengthOf(2);
flexsearch_worker.search("bar", function(result){
flexsearch_worker.search("bar", function(result){
expect(result).to.have.lengthOf(2);
});
expect(result).to.have.lengthOf(2);
flexsearch_worker.search("foobar", function(result){
flexsearch_worker.search("foobar", function(result){
expect(result).to.have.lengthOf(1);
expect(result).to.have.lengthOf(1);
done();
});
});
});
});
setTimeout(done, 25);
});
it("Should have been limited", function(done){
it("Should have been limited", function(done){
flexsearch_worker.search("foo", 1, function(result){
flexsearch_worker.search("foo", 1, function(result){
expect(result).to.have.lengthOf(1);
expect(result).to.include(0);
expect(result).to.not.include(1);
done();
});
});
setTimeout(done, 25);
});
it("Should not have been matched from index", function(done){
it("Should not have been matched from index", function(done){
flexsearch_worker.search("barfoo", function(result){
flexsearch_worker.search("barfoo", function(result){
expect(result).to.have.lengthOf(0);
expect(result).to.have.lengthOf(0);
});
flexsearch_worker.search("", function(result){
flexsearch_worker.search("", function(result){
expect(result).to.have.lengthOf(0);
expect(result).to.have.lengthOf(0);
});
flexsearch_worker.search(" ", function(result){
flexsearch_worker.search(" ", function(result){
expect(result).to.have.lengthOf(0);
expect(result).to.have.lengthOf(0);
});
flexsearch_worker.search(" o ", function(result){
flexsearch_worker.search(" o ", function(result){
expect(result).to.have.lengthOf(1);
expect(result).to.have.lengthOf(0);
flexsearch_worker.search(" fob ", function(result){
expect(result).to.have.lengthOf(0);
done();
});
});
});
});
});
});
setTimeout(done, 25);
});
});
// TODO:
/*
describe("Update (Worker)", function(){
describe("Update (Worker)", function(){
it("Should have been updated to the index", function(done){
it("Should have been updated to the index", function(done){
flexsearch_worker.update(0, "bar");
flexsearch_worker.update(2, "foobar");
flexsearch_worker.update(1, "foo");
flexsearch_worker.update(0, "bar");
flexsearch_worker.update(2, "foobar");
flexsearch_worker.update(1, "foo", function(){
setTimeout(function(){
expect(flexsearch_worker.length).to.equal(3);
expect(flexsearch_worker.length).to.equal(3);
flexsearch_worker.search("foo", function(results){
flexsearch_worker.search("foo", function(results){
expect(results).to.have.members([2, 1]);
expect(results).to.have.members([2, 1]);
});
flexsearch_worker.search("bar", function(results){
flexsearch_worker.search("bar", function(results){
expect(results).to.have.members([0, 2]);
expect(results).to.have.members([0, 2]);
});
flexsearch_worker.search("foobar", function(results){
flexsearch_worker.search("foobar", function(results){
expect(results).to.have.members([2]);
expect(results).to.have.members([2]);
done();
});
});
});
});
setTimeout(done, 25);
}, 25);
});
});
});
*/
describe("Remove (Worker)", function(){
describe("Remove (Worker)", function(){
it("Should have been removed from the index", function(done){
it("Should have been removed from the index", function(done){
expect(flexsearch_worker.length).to.equal(3);
expect(flexsearch_worker.length).to.equal(3);
flexsearch_worker.remove(0);
flexsearch_worker.remove(2);
flexsearch_worker.remove(1);
flexsearch_worker.remove(0);
flexsearch_worker.remove(2);
flexsearch_worker.remove(1);
setTimeout(function(){
expect(flexsearch_worker.length).to.equal(0);

@@ -815,28 +782,28 @@

expect(results).to.not.include(2);
});
flexsearch_worker.search("bar", function(results){
flexsearch_worker.search("bar", function(results){
expect(results).to.not.include(0);
expect(results).to.not.include(2);
});
expect(results).to.not.include(0);
expect(results).to.not.include(2);
flexsearch_worker.search("foobar", function(results){
flexsearch_worker.search("foobar", function(results){
expect(results).to.not.include(2);
expect(results).to.not.include(2);
done();
});
});
});
});
setTimeout(done, 25);
}, 25);
});
if(env !== "light" && env !== "min"){
if(env !== "light" && env !== "min"){
it("Should have been debug mode activated", function(){
it("Should have been debug mode activated", function(){
flexsearch_worker.info();
});
}
});
}
flexsearch_worker.info();
});
}
});
describe("Worker Not Supported", function(){

@@ -854,3 +821,3 @@

encode: false,
async: true,
async: false,
worker: 4

@@ -857,0 +824,0 @@ });

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc