flexsearch
Advanced tools
Comparing version 0.3.2 to 0.3.3
/* | ||
FlexSearch v0.3.2 | ||
FlexSearch v0.3.3 | ||
Copyright 2019 Nextapps GmbH | ||
@@ -8,24 +8,23 @@ Author: Thomas Wilkerling | ||
*/ | ||
'use strict';(function(q,z,h){let t;(t=h.define)&&t.amd?t([],function(){return z}):(t=h.modules)?t[q.toLowerCase()]=z:"object"===typeof exports?module.exports=z:h[q]=z})("FlexSearch",function Q(q){function h(a){B(a)&&(a=H[a]);a||(a=v);this.id=a.id||R++;this.init(a);t(this,"index",function(){return this.a});t(this,"length",function(){return Object.keys(this.a).length})}function t(a,b,d){Object.defineProperty(a,b,{get:d})}function e(a){return new RegExp(a,"g")}function w(a,b){for(let d=0;d<b.length;d+= | ||
2)a=a.replace(b[d],b[d+1]);return a}function x(a,b,d,c,f,k,g){if(b[d])return b[d];f=f?(9-(g||6))*k+(g||6)*f:k;b[d]=f;f>=g&&(a=a[f+.5>>0],a=a[d]||(a[d]=[]),a[a.length]=c);return f}function r(a,b){if(a){const d=Object.keys(a);for(let c=0,f=d.length;c<f;c++){const f=d[c],g=a[f];if(g)for(let c=0,d=g.length;c<d;c++)if(g[c]===b){1===d?delete a[f]:g.splice(c,1);break}else"object"===typeof g[c]&&r(g[c],b)}}}function J(a){const b=[];if(!a)return b;let d=0,c=0,f=0,k="";const g=a.length;for(let l=0;l<g;l++){const e= | ||
a[l];"a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e?d++:c++;" "!==e&&(k+=e);if(" "===e||d>=(8<g?2:1)&&2<=c||2<=d&&c>=(8<g?2:1)||l===g-1)k&&(b[f]&&2<k.length&&f++,b[f]=b[f]?b[f]+k:k," "===e&&f++,k=""),c=d=0}return b}function E(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 S(a,b){const d={};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 T(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 U(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function V(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function W(a,b,d){let c=[],f=[];const k=a.length;if(1<k){a.sort(V);const l={};let e=a[0],h=e.length, | ||
u=0;for(;u<h;)l[e[u++]]=1;let n,p=0,m=0;for(;++m<k;){let I=!1;const X=m===k-1;f=[];e=a[m];h=e.length;for(u=0;u<h;)if(n=e[u++],l[n]){var g=l[n];if(g===m){if(X){if(c[p++]=n,b&&p===b)return c}else l[n]=m+1;I=!0}else d&&(g=f[g]||(f[g]=[]),g[g.length]=n)}if(!I&&!d)break}if(d&&(p=c.length,(m=f.length)&&(!b||p<b)))for(;m--;)if(n=f[m])for(let a=0,d=n.length;a<d;a++)if(c[p++]=n[a],b&&p===b)return c}else k&&(c=a[0],b&&c.length>b&&(c=c.slice(0,b)));return c}function B(a){return"string"===typeof a}function C(a){return"function"=== | ||
typeof a}function y(a){return"undefined"===typeof a}function F(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.g[f];switch(d[0]){case D.add:a.add(d[1],d[2]);break;case D.remove:a.remove(d[1])}delete a.g[f];if(100<Date.now()-b)break}a.f.length&&F(a)}b&&(a.async=b)}},1,"search-async-"+a.id))}function L(a){const b=Array(a);for(let d=0;d<a;d++)b[d]={};return b}function Y(a,b,d,c){a=q("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=Q.toString();d.id=b;a.postMessage(b,{register:f,options:d,id:b});return a}const v={encode:"icase",b:"forward",u:!1,cache:!1,async:!1,c:!1,threshold:0,depth:0},H={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 R=0;const D={add:0,update:1,remove:2},M=e("[ -/]"),N={},O={},P=function(){const a=Object.getOwnPropertyNames({}.__proto__),b={};for(let d=0;d<a.length;d++)b[a[d]]=1;return b}();h.create=function(a){return new h(a)};h.registerMatcher=function(a){for(let b in a)a.hasOwnProperty(b)&&G.push(e(b),a[b]);return this};h.registerEncoder=function(a,b){A[a]=b.bind(A);return this};h.registerLanguage=function(a,b){N[a]=b.filter;O[a]=b.stemmer;return this};h.encode=function(a, | ||
b){return P[a]?b:A[a](b)};h.prototype.init=function(a){this.C=[];a||(a=v);let b=a.profile;const d=b?H[b]:{};if(b=a.worker)if(Worker){const c=this,d=parseInt(b,10)||4;c.m=-1;c.o=0;c.h=[];c.B=null;c.j=Array(d);for(let b=0;b<d;b++)c.j[b]=Y(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.i.set(b,c.h),c.B(c.h),c.h=[]),c})}else a.worker=!1,this.j=null;this.b=a.tokenize||d.b||this.b||v.b;this.async=y(b=a.async)?this.async||v.async: | ||
b;this.c=y(b=a.worker)?this.c||v.c:b;this.threshold=y(b=a.threshold)?d.threshold||this.threshold||v.threshold:b;this.depth=y(b=a.depth)?d.depth||this.depth||v.depth:b;this.u=y(b=a.suggest)?this.u||v.u:b;this.s=(b=y(b=a.encode)?d.encode:b)&&A[b]&&A[b].bind(A)||(C(b)?b:this.s||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.filter=S(N[b]||b,this.s);if(b=a.stemmer)this.stemmer=T(O[b]||b,this.s);this.w=L(10);this.l={};this.a={};this.g={};this.f=[];this.D=0;this.v=!0;this.i=(this.cache=b=y(b= | ||
a.cache)?this.cache||v.cache:b)?new Z(b):!1;return this};h.prototype.encode=function(a){a&&G.length&&(a=w(a,G));a&&this.C.length&&(a=w(a,this.C));a&&this.s&&(a=this.s(a));a&&this.stemmer&&(a=w(a,this.stemmer));return a};h.prototype.addMatcher=function(a){const b=this.C;for(const d in a)a.hasOwnProperty(d)&&b.push(e(d),a[d]);return this};h.prototype.add=function(a,b,d){if(b&&B(b)&&(a&&!P[a]||0===a))if(this.a[a]&&!d)this.update(a,b);else{if(this.c)return++this.m>=this.j.length&&(this.m=0),this.j[this.m].postMessage(this.m, | ||
{add:!0,id:a,content:b}),this.a[a]=""+this.m,this;if(this.async)return this.g[a]||(this.f[this.f.length]=a),this.g[a]=[D.add,a,b],F(this),this;b=this.encode(b);if(!b.length)return this;d=this.b;b=C(d)?d(b):"ngram"===d?J(b):b.split(M);const k={_ctx:{}},h=this.threshold,u=this.depth,n=this.w,p=b.length;for(let m=0;m<p;m++){var c=b[m];if(c){var f=c.length,e=(p-m)/p,g="";switch(d){case "reverse":case "both":for(var l=f-1;1<=l;l--)g=c[l]+g,x(n,k,g,a,(f-l)/f,e,h);g="";case "forward":for(l=0;l<f;l++)g+= | ||
c[l],x(n,k,g,a,1,e,h);break;case "full":for(l=0;l<f;l++){const b=(f-l)/f;for(let d=f;d>l;d--)g=c.substring(l,d),x(n,k,g,a,b,e,h)}break;default:if(f=x(n,k,c,a,1,e,h),u&&1<p&&f>=h)for(f=k._ctx[c]||(k._ctx[c]={}),c=this.l[c]||(this.l[c]=L(10)),e=m-u,g=m+u+1,0>e&&(e=0),g>p&&(g=p);e<g;e++)e!==m&&x(c,f,b[e],a,0,10-(e<m?m-e:e-m),h)}}}this.a[a]=1;this.v=!1}return this};h.prototype.update=function(a,b){this.a[a]&&B(b)&&(this.remove(a),this.add(a,b,!0));return this};h.prototype.remove=function(a){if(this.a[a]){if(this.c){var b= | ||
this.a[a];this.j[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this}if(this.async)return this.g[a]||(this.f[this.f.length]=a),this.g[a]=[D.remove,a],F(this),this;for(b=0;10>b;b++)r(this.w[b],a);this.depth&&r(this.l,a);delete this.a[a];this.v=!1}return this};h.prototype.search=function(a,b,d,c){let f=a,e;var g=[];"object"===typeof a&&((d=a.callback||b)&&(f.callback=null),b=a.limit,e=a.threshold,a=a.query);e||(e=this.threshold||0);C(b)?(d=b,b=1E3):b||0===b||(b=1E3);if(this.c)for(this.B= | ||
d,this.o=0,this.h=[],g=0;g<this.c;g++)this.j[g].postMessage(g,{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||!B(a))return g;f=a;if(this.cache)if(this.v){if(c=this.i.get(a))return c}else this.i.clear(),this.v=!0;f=this.encode(f);if(!f.length)return g;c=this.b;c=C(c)?c(f):"ngram"=== | ||
c?J(f):f.split(M);var h=c.length,r=!0,q=[],u={};if(1<h)if(this.depth){var n=!0;var p=c[0];u[p]=1}else c.sort(U);var m;if(!n||(m=this.l)[p])for(let a=n?1:0;a<h;a++){const b=c[a];if(b&&!u[b]){let a=!1;const c=[];let d=0;for(let f=9;f>=e;f--){var t=(n?m[p]:this.w)[f];if(t=t[b])c[d++]=t,a=!0}if(a)q[q.length]=1<d?q.concat.apply([],c):c[0];else if(!this.u){r=!1;break}u[b]=1}p=b}else r=!1;r&&(g=W(q,b,this.u));this.cache&&this.i.set(a,g);return g}};h.prototype.clear=function(){this.destroy();return this.init()}; | ||
h.prototype.destroy=function(){this.cache&&(this.i.clear(),this.i=null);this.filter=this.stemmer=this.w=this.l=this.a=this.g=this.f=null;return this};const A={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\\s+")," "];return function(b){b=w(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=w(b,a));d||1<b.length&&(b=E(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]+w(c.substring(1),a))}b=b.join(" ");b=E(b)}return b}}(),balance:function(){const a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s\\s+")," "];return function(b){return E(w(b.toLowerCase(),a))}}()},K=function(){const a={};return function(b,d,c){const f=a[c];f&&clearTimeout(f); | ||
return a[c]=setTimeout(b,d)}}(),Z=function(){function a(a){this.clear();this.A=!0!==a&&a}a.prototype.clear=function(){this.cache={};this.count={};this.index={};this.a=[]};a.prototype.set=function(a,d){if(this.A&&y(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 f=this.a;for(var e=d;this.count[f[--d]]<=c&&-1!==d;);d++;if(d!==e){for(c=e;c>d;c--)e=f[c-1],f[c]=e,b[e]=c;f[d]=a;b[a]=d}}}return b};return a}();return h}(function(){const q=Object.create(null),z="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(h,t,e,w,x){let r=h;h=z?URL.createObjectURL(new Blob(["("+e.toString()+")()"],{type:"text/javascript"})):r+".min.js";r+="-"+t;q[r]||(q[r]=[]);q[r][x]= | ||
new Worker(h);q[r][x].onmessage=w;return{postMessage:function(e,h){q[r][e].postMessage(h)}}}}()),this); | ||
'use strict';(function(r,A,g){let v;(v=g.define)&&v.amd?v([],function(){return A}):(v=g.modules)?v[r.toLowerCase()]=A:"object"===typeof exports?module.exports=A:g[r]=A})("FlexSearch",function P(r){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,l,h){if(b[d])return b[d];f=f?(9-(h||6))*l+(h||6)*f:l;b[d]=f;f>=h&&(a=a[f+.5>>0],a=a[d]||(a[d]=[]),a[a.length]=c);return f}function p(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]&&p(h[c],b)}}}function F(a){let b="",d="";var c="";for(let f=0;f<a.length;f++){const l=a[f];if(l!==d)if(f&&"h"=== | ||
l){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+=l}else b+=l;c=f===a.length-1?"":a[f+1];d=l}return b}function S(a,b){const d=q();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 T(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 U(a,b){a=a.length- | ||
b.length;return 0>a?1:a?-1:0}function V(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function W(a,b,d){let c=[],f=[];const l=a.length;if(1<l){a.sort(V);const u=q();let e=a[0],g=e.length,t=0;for(;t<g;)u[e[t++]]=1;let n,m=0,k=0;for(;++k<l;){let J=!1;const R=k===l-1;f=[];e=a[k];g=e.length;for(t=0;t<g;)if(n=e[t++],u[n]){var h=u[n];if(h===k){if(R){if(c[m++]=n,b&&m===b)return c}else u[n]=k+1;J=!0}else d&&(h=f[h]||(f[h]=[]),h[h.length]=n)}if(!J&&!d)break}if(d&&(m=c.length,(k=f.length)&&(!b||m<b)))for(;k--;)if(n= | ||
f[k])for(let a=0,d=n.length;a<d;a++)if(c[m++]=n[a],b&&m===b)return c}else l&&(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.g[f];switch(d[0]){case E.add:a.add(d[1],d[2]);break;case E.remove:a.remove(d[1])}delete a.g[f]; | ||
if(100<Date.now()-b)break}a.f.length&&G(a)}b&&(a.async=b)}},1,"search-async-"+a.id))}function L(a){const b=Array(a);for(let d=0;d<a;d++)b[d]=q();return b}function q(){return Object.create(null)}function X(a,b,d,c){a=r("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",u:!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=q();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.m=-1;c.o=0;c.h=[];c.B=null;c.j=Array(d);for(let b=0;b<d;b++)c.j[b]=X(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.i.set(b,c.h),c.B(c.h),c.h=[]),c})}else a.worker=!1,this.j=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.u=z(b=a.suggest)?this.u||w.u:b;this.s=(b=z(b=a.encode)?d.encode:b)&&B[b]&&B[b].bind(B)|| | ||
(D(b)?b:this.s||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.filter=S(N[b]||b,this.s);if(b=a.stemmer)this.stemmer=T(O[b]||b,this.s);this.w=L(10);this.l=q();this.a=q();this.g=q();this.f=[];this.D=0;this.v=!0;this.i=(this.cache=b=z(b=a.cache)?this.cache||w.cache:b)?new Y(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.s&&(a=this.s(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))if(this.a[a]&&!d)this.update(a,b);else{if(this.c)return++this.m>=this.j.length&&(this.m=0),this.j[this.m].postMessage(this.m,{add:!0,id:a,content:b}),this.a[a]=""+this.m,this;if(this.async)return this.g[a]||(this.f[this.f.length]=a),this.g[a]=[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 l=q();l._ctx=q();const u= | ||
this.threshold,t=this.depth,n=this.w,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(n,l,h,a,(f-g)/f,e,u);h="";case "forward":for(g=0;g<f;g++)h+=c[g],y(n,l,h,a,1,e,u);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(n,l,h,a,b,e,u)}break;default:if(f=y(n,l,c,a,1,e,u),t&&1<m&&f>=u)for(f=l._ctx[c]||(l._ctx[c]=q()),c=this.l[c]||(this.l[c]=L(10)),e=k-t,h=k+t+ | ||
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),u)}}}this.a[a]=1;this.v=!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){if(this.a[a]){if(this.c){var b=this.a[a];this.j[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this}if(this.async)return this.g[a]||(this.f[this.f.length]=a),this.g[a]=[E.remove,a],G(this),this;for(b=0;10>b;b++)p(this.w[b],a);this.depth&&p(this.l,a); | ||
delete this.a[a];this.v=!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.o=0,this.h=[],h=0;h<this.c;h++)this.j[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.v){if(c=this.i.get(a))return c}else this.i.clear(),this.v=!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,p=!0,r=[],t=q();if(1<g)if(this.depth){var n=!0;var m=c[0];t[m]=1}else c.sort(U);var k;if(!n||(k=this.l)[m])for(let a=n?1:0;a<g;a++){const b=c[a];if(b){if(!t[b]){const a=[];let c=!1,d=0;if(m=n?k[m]:this.w){let f; | ||
for(let h=9;h>=e;h--)if(f=m[h][b])a[d++]=f,c=!0}if(c)r[r.length]=1<d?a.concat.apply([],a):a[0];else if(!this.u){p=!1;break}t[b]=1}m=b}}else p=!1;p&&(h=W(r,b,this.u));this.cache&&this.i.set(a,h);return h}};g.prototype.clear=function(){this.destroy();return this.init()};g.prototype.destroy=function(){this.cache&&(this.i.clear(),this.i=null);this.filter=this.stemmer=this.w=this.l=this.a=this.g=this.f=null;return this};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=q();return function(b,d,c){const f=a[c];f&&clearTimeout(f);return a[c]=setTimeout(b,d)}}(),Y=function(){function a(a){this.clear();this.A=!0!==a&&a}a.prototype.clear=function(){this.cache=q();this.count=q();this.index=q();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 r={}, | ||
A="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(g,v,e,x,y){let p=g;g=A?URL.createObjectURL(new Blob(["("+e.toString()+")()"],{type:"text/javascript"})):p+".min.js";p+="-"+v;r[p]||(r[p]=[]);r[p][y]=new Worker(g);r[p][y].onmessage=x;return{postMessage:function(e,g){r[p][e].postMessage(g)}}}}()),this); |
{ | ||
"name": "flexsearch", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Next-Generation full text search library with zero dependencies.", | ||
@@ -10,6 +10,7 @@ "homepage": "https://github.com/nextapps-de/flexsearch/", | ||
"keywords": [ | ||
"full text search", | ||
"fulltext search", | ||
"elastic search", | ||
"fastest search", | ||
"contextual search" | ||
"contextual search", | ||
"fuzzy search" | ||
], | ||
@@ -16,0 +17,0 @@ "bugs": { |
500
README.md
@@ -16,6 +16,6 @@ <p align="center"> | ||
<h1></h1> | ||
<h3>World's fastest and most memory efficient full text search library with zero dependencies.</h3> | ||
<h3>Web's fastest and most memory-flexible full-text search library with zero dependencies.</h3> | ||
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. | ||
It also has 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 continuously 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="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. | ||
@@ -29,2 +29,7 @@ | ||
Library Comparison: | ||
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">Benchmark "Gulliver's Travels"</a> | ||
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">Relevance Scoring</a> | ||
- <a href="#consumption">Memory Consumption</a> | ||
Get Latest (Stable Release): | ||
@@ -173,5 +178,5 @@ | ||
<td>File Size (gzip)</td> | ||
<td>6.7 kb</td> | ||
<td>4.5 kb</td> | ||
<td>4.1 kb</td> | ||
<td>5.0 kb</td> | ||
<td>3.9 kb</td> | ||
<td>2.7 kb</td> | ||
</tr> | ||
@@ -183,7 +188,5 @@ </table> | ||
<a name="compare" id="compare"></a> | ||
#### Benchmark Ranking | ||
## Benchmark Ranking | ||
- Library Comparison: <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">Benchmark "Gulliver's Travels"</a> | ||
- Library Comparison: <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">Relevance Scoring</a> | ||
- Library Comparison: <a href="#consumption">Memory Consumption</a> | ||
Comparison: <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">Benchmark "Gulliver's Travels"</a> | ||
@@ -198,11 +201,13 @@ __Query Test: "Gulliver's Travels"__ | ||
<td align="left">Library Version</td> | ||
<td align="left">Library Size</td> | ||
<td align="left">Operations per second</td> | ||
<td align="left">Single Phrase (op/s)</td> | ||
<td align="left">Multi Phrase (op/s)</td> | ||
<td align="left">Not Found (op/s)</td> | ||
</tr> | ||
<tr> | ||
<td>1</td> | ||
<td>FlexSearch</td> | ||
<td>FlexSearch <a href="#notes">***</a></td> | ||
<td>0.3.2</td> | ||
<td>4.1 kb</td> | ||
<td><b>333738</b></td> | ||
<td><b>342040</b></td> | ||
<td><b>178456</b></td> | ||
<td><b>1527778</b></td> | ||
</tr> | ||
@@ -214,4 +219,5 @@ <tr></tr> | ||
<td>0.3.3</td> | ||
<td>1.6 kb</td> | ||
<td><b>1587</b></td> | ||
<td><b>899</b></td> | ||
<td><b>6098</b></td> | ||
<td><b>214286</b></td> | ||
</tr> | ||
@@ -223,4 +229,5 @@ <tr></tr> | ||
<td>1.4.2</td> | ||
<td>3.8 kb</td> | ||
<td><b>771</b></td> | ||
<td><b>735</b></td> | ||
<td><b>8889</b></td> | ||
<td><b>800000</b></td> | ||
</tr> | ||
@@ -232,4 +239,5 @@ <tr></tr> | ||
<td>1.0</td> | ||
<td>3.9 kb</td> | ||
<td><b>584</b></td> | ||
<td><b>551</b></td> | ||
<td><b>9970</b></td> | ||
<td><b>75000</b></td> | ||
</tr> | ||
@@ -241,4 +249,5 @@ <tr></tr> | ||
<td>2.3.5</td> | ||
<td>8.8 kb</td> | ||
<td><b>322</b></td> | ||
<td><b>355</b></td> | ||
<td><b>1051</b></td> | ||
<td><b>25000</b></td> | ||
</tr> | ||
@@ -250,4 +259,5 @@ <tr></tr> | ||
<td>0.9.6</td> | ||
<td>5.6 kb</td> | ||
<td><b>319</b></td> | ||
<td><b>327</b></td> | ||
<td><b>781</b></td> | ||
<td><b>6667</b></td> | ||
</tr> | ||
@@ -259,4 +269,5 @@ <tr></tr> | ||
<td>0.1.3</td> | ||
<td>3.1 kb</td> | ||
<td><b>265</b></td> | ||
<td><b>535</b></td> | ||
<td><b>2778</b></td> | ||
</tr> | ||
@@ -268,4 +279,5 @@ <tr></tr> | ||
<td>0.2</td> | ||
<td>3.5 kb</td> | ||
<td><b>107</b></td> | ||
<td><b>71</b></td> | ||
<td><b>116</b></td> | ||
<td><b>2065</b></td> | ||
</tr> | ||
@@ -277,4 +289,5 @@ <tr></tr> | ||
<td>3.3.0</td> | ||
<td>3.7 kb</td> | ||
<td><b>1</b></td> | ||
<td><b>0.5</b></td> | ||
<td><b>0.4</b></td> | ||
<td><b>0.7</b></td> | ||
</tr> | ||
@@ -296,3 +309,3 @@ </table> | ||
<td>1</td> | ||
<td>FlexSearch</td> | ||
<td>FlexSearch <a href="#notes">****</a></td> | ||
<td>0.3.1</td> | ||
@@ -313,6 +326,6 @@ <td>1.33 Mb</td> | ||
<td>3</td> | ||
<td>JS Search</td> | ||
<td>1.4.2</td> | ||
<td>36.9 Mb</td> | ||
<td>53.0 kb</td> | ||
<td>Fuse</td> | ||
<td>3.3.0</td> | ||
<td>0.22 Mb</td> | ||
<td>156.46 kb</td> | ||
</tr> | ||
@@ -330,6 +343,6 @@ <tr></tr> | ||
<td>5</td> | ||
<td>Lunr.js</td> | ||
<td>2.3.5</td> | ||
<td>16.24 Mb</td> | ||
<td>84.73 kb</td> | ||
<td>bm25</td> | ||
<td>0.2</td> | ||
<td>6.95 Mb</td> | ||
<td>137.88 kb</td> | ||
</tr> | ||
@@ -339,2 +352,10 @@ <tr></tr> | ||
<td>6</td> | ||
<td>BulkSearch</td> | ||
<td>0.1.3</td> | ||
<td>1.53 Mb</td> | ||
<td>984.30 kb</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>7</td> | ||
<td>Elasticlunr.js</td> | ||
@@ -347,15 +368,7 @@ <td>0.9.6</td> | ||
<tr> | ||
<td>7</td> | ||
<td>BulkSearch</td> | ||
<td>0.1.3</td> | ||
<td>1.53 Mb</td> | ||
<td>984.30 kb</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>8</td> | ||
<td>bm25</td> | ||
<td>0.2</td> | ||
<td>6.95 Mb</td> | ||
<td>137.88 kb</td> | ||
<td>Lunr.js</td> | ||
<td>2.3.5</td> | ||
<td>16.24 Mb</td> | ||
<td>84.73 kb</td> | ||
</tr> | ||
@@ -365,6 +378,6 @@ <tr></tr> | ||
<td>9</td> | ||
<td>Fuse</td> | ||
<td>3.3.0</td> | ||
<td>0.22 Mb</td> | ||
<td>156.46 kb</td> | ||
<td>JS Search</td> | ||
<td>1.4.2</td> | ||
<td>36.9 Mb</td> | ||
<td>53.0 kb</td> | ||
</tr> | ||
@@ -375,3 +388,5 @@ </table> | ||
_* Index Size: The size of memory the index requires_<br> | ||
_** Memory Allocation: The amount of memory which was additionally allocated during a row of 10 queries_ | ||
_** Memory Allocation: The amount of memory which was additionally allocated during a row of 10 queries_<br> | ||
_*** The preset "fastest" was used for this test_ <br> | ||
_**** The preset "memory" was used for this test_ | ||
@@ -381,4 +396,6 @@ Library Comparison: <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">Benchmark "Gulliver's Travels"</a> | ||
<a name="contextual"></a> | ||
#### Contextual Search | ||
## Contextual Search | ||
> "TF-IDF and all kinds of variations (like BM25) is a big mistake in searching algorithms today. They don't provide neither: a meaningful relevance of a term nor the importance of it! Like many pseudo-intelligent algorithms this is also just an example of mathematical stupidity." — Thomas Wilkerling, _Contextual-based Scoring_, 2018 | ||
FlexSearch introduce a new scoring mechanism called __Contextual Search__ which was invented by Thomas Wilkerling, the author of this library. A Contextual Search <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">incredibly boost up queries to a complete new level</a> but also requires a lot of additionally memory. | ||
@@ -393,15 +410,4 @@ The basic idea of this concept is to limit relevance by its context instead of calculating relevance through the whole (unlimited) distance. | ||
__Note:__ This feature is actually not enabled by default. | ||
__Note:__ This feature is actually not enabled by default. Read <a href="contextual_enable">here</a> how to enable. | ||
###### TF-IDF / BM25? | ||
> "TF-IDF and all kinds of variations (like BM25) is a big mistake in searching algorithms today. They don't provide neither: a meaningful relevance of a term nor the importance of it! Like many pseudo-intelligent algorithms this is also just an example of mathematical stupidity." — Thomas Wilkerling, _Contextual-based Scoring_, 2018 | ||
<a name="webworker"></a> | ||
#### Web-Worker Support | ||
Workers get its own dedicated memory. Especially for larger indexes, web worker improves speed and available memory a lot. FlexSearch index was tested with a 250 Mb text file including 10 Million words. The indexing was done silently in background by multiple parallel running workers in about 7 minutes. The final index reserves ~ 8.2 Mb memory/space. The search result took ~ 0.25 ms. | ||
__Note:__ It is slightly faster to use no web worker when the index or query isn't too big (index < 500,000 words, query < 25 words). | ||
#### Compare BulkSearch vs. FlexSearch | ||
@@ -412,5 +418,5 @@ | ||
<tr> | ||
<td align="left">Description</th> | ||
<td align="left">BulkSearch</th> | ||
<td align="left">FlexSearch</th> | ||
<td align="left"></th> | ||
<td align="left"><b>BulkSearch</b></th> | ||
<td align="left"><b>FlexSearch</b></th> | ||
</tr> | ||
@@ -437,3 +443,3 @@ <tr> | ||
<td>Strength</td> | ||
<td><ul><li>fast adds / fast updates / fast removals</li></ul></td> | ||
<td><ul><li>fast adds</li><li>fast updates</li><li>fast removals</li></ul></td> | ||
<td><ul><li>fast queries</li><li>memory-efficient index</li></ul></td> | ||
@@ -496,4 +502,6 @@ </tr> | ||
##### HTML / Javascript | ||
#### HTML / Javascript | ||
> Use _flexsearch.min.js_ for production and _flexsearch.js_ for development. | ||
```html | ||
@@ -506,3 +514,2 @@ <html> | ||
``` | ||
__Note:__ Use _flexsearch.min.js_ for production and _flexsearch.js_ for development. | ||
@@ -514,4 +521,15 @@ Use latest from CDN: | ||
##### Node.js | ||
Or a specific version: | ||
```html | ||
<script src="https://cdn.rawgit.com/nextapps-de/flexsearch/0.3.2/flexsearch.min.js"></script> | ||
``` | ||
__AMD__ | ||
```javascript | ||
var FlexSearch = require("./flexsearch.js"); | ||
``` | ||
#### Node.js | ||
```npm | ||
@@ -533,8 +551,2 @@ npm install flexsearch | ||
__AMD__ | ||
```javascript | ||
var FlexSearch = require("./flexsearch.js"); | ||
``` | ||
<a name="api"></a> | ||
@@ -579,3 +591,3 @@ ## API Overview | ||
##### Create a new index and choosing one of the built-in profiles | ||
Create a new index and choosing one of the built-in profiles: | ||
@@ -586,3 +598,3 @@ ```js | ||
##### Create a new index with custom options | ||
Create a new index with custom options: | ||
@@ -594,6 +606,6 @@ ```js | ||
profile: "balance", | ||
encode: "icase", | ||
tokenize: "ngram", | ||
encode: "balance", | ||
tokenize: "forward", | ||
async: false, | ||
worker: false, | ||
cache: false | ||
@@ -608,3 +620,3 @@ }); | ||
> Index.__add___(id, string) | ||
> Index.__add(id, string)__ | ||
@@ -617,3 +629,3 @@ ```js | ||
> Index.__search(string|options, \<limit\>, \<callback\>)__ | ||
> Index.__search(string | options, \<limit\>, \<callback\>)__ | ||
@@ -630,2 +642,3 @@ ```js | ||
#### Async Search | ||
Perform queries asynchronously: | ||
@@ -640,2 +653,4 @@ | ||
> Passing a callback always will perform as asynchronous even if the "async" option was not set. | ||
Perform queries asynchronously (Promise-based): | ||
@@ -656,8 +671,8 @@ | ||
async function search(query){ | ||
return await index.search(query); | ||
const result = await index.search(query); | ||
} | ||
const result = search("John"); | ||
``` | ||
#### Custom Search | ||
Pass custom options for each query: | ||
@@ -691,2 +706,3 @@ | ||
#### Suggestions | ||
Get also suggestions for a query: | ||
@@ -705,5 +721,5 @@ | ||
<a name="index.update"></a> | ||
#### Update item to the index | ||
#### Update item of an index | ||
> Index.__update__(id, string) | ||
> Index.__update(id, string)__ | ||
@@ -717,3 +733,3 @@ ```js | ||
> Index.__remove__(id) | ||
> Index.__remove(id)__ | ||
@@ -738,8 +754,6 @@ ```js | ||
<a name="index.init"></a> | ||
#### Re-Initialize index | ||
#### Re-Initialize the index | ||
> Index.__init(\<options\>)__ | ||
__Note:__ Re-initialization will also destroy the old index! | ||
Initialize (with same options): | ||
@@ -757,2 +771,5 @@ ```js | ||
``` | ||
> Re-initialization will also destroy the old index. | ||
<a name="flexsearch.addmatcher"></a> | ||
@@ -772,2 +789,3 @@ #### Add custom matcher | ||
``` | ||
<a name="index.addmatcher"></a> | ||
@@ -783,6 +801,7 @@ Add private matchers for a specific instance: | ||
``` | ||
<a name="flexsearch.encoder"></a> | ||
#### Add custom encoder | ||
Define a private custom encoder during creation/initialization: | ||
Assign a custom encoder by passing a function during index creation/initialization: | ||
```js | ||
@@ -799,32 +818,33 @@ var index = new FlexSearch({ | ||
``` | ||
Call a custom encoder directly: | ||
```js | ||
var encoded = index.encode("sample text"); | ||
``` | ||
<a name="flexsearch.register"></a> | ||
##### Register a global encoder to be used by all instances | ||
#### Register a global encoder | ||
> FlexSearch.__registerEncoder(name, encoder)__ | ||
Global encoders can be shared/used by all instances. | ||
```js | ||
FlexSearch.registerEncoder('whitespace', function(str){ | ||
FlexSearch.registerEncoder("whitespace", function(str){ | ||
return str.replace(/ /g, ''); | ||
return str.replace(/\s/g, ""); | ||
}); | ||
``` | ||
Use global encoders: | ||
Initialize index and assign a global encoder: | ||
```js | ||
var index = new FlexSearch({ encode: 'whitespace' }); | ||
var index = new FlexSearch({ encode: "whitespace" }); | ||
``` | ||
<a name="index.encode"></a> | ||
##### Call encoders directly | ||
Private encoder: | ||
Call a global encoder directly: | ||
```js | ||
var encoded = index.encode("sample text"); | ||
``` | ||
<a name="flexsearch.encode"></a> | ||
Global encoder: | ||
```js | ||
var encoded = FlexSearch.encode("whitespace", "sample text"); | ||
``` | ||
##### Mixup/Extend multiple encoders | ||
#### Mix/Extend multiple encoders | ||
@@ -834,21 +854,16 @@ ```js | ||
str = this.encode("icase", str); // built-in | ||
str = this.encode("icase", str); // built-in | ||
str = this.encode("whitespace", str); // custom | ||
// do something additional with str ... | ||
return str; | ||
}); | ||
``` | ||
```js | ||
FlexSearch.registerEncoder('extended', function(str){ | ||
str = this.encode("custom", str); | ||
// do something additional with str ... | ||
return str; | ||
}); | ||
``` | ||
<a name="flexsearch.tokenizer"></a> | ||
#### Add custom tokenizer | ||
> A tokenizer split words into components or chunks. | ||
Define a private custom tokenizer during creation/initialization: | ||
@@ -859,9 +874,8 @@ ```js | ||
tokenize: function(str){ | ||
// split string into components, e.g.: | ||
return str.split(/ -\//g); | ||
return str.split(/\s-\//g); | ||
} | ||
}); | ||
``` | ||
<a name="flexsearch.language"></a> | ||
@@ -874,3 +888,3 @@ #### Add language-specific stemmer and/or filter | ||
Define a private custom stemmer or filter during creation/initialization: | ||
Assign a private custom stemmer or filter during creation/initialization: | ||
```js | ||
@@ -901,11 +915,14 @@ var index = new FlexSearch({ | ||
Or assign stemmer/filters globally to a language: | ||
> Stemmer are passed as a object (key-value-pair), filter as an array. | ||
```js | ||
FlexSearch.registerLanguage('us', { | ||
FlexSearch.registerLanguage("us", { | ||
stemmer: {/* ... */}, | ||
filter: [/* ... */] | ||
stemmer: { /* ... */ }, | ||
filter: [ /* ... */ ] | ||
}); | ||
``` | ||
Or use built-in stemmer or filter of your preferred languages: | ||
Or use some pre-defined stemmer or filter of your preferred languages: | ||
```html | ||
@@ -923,11 +940,19 @@ <html> | ||
```js | ||
var index_en = new FlexSearch({stemmer: 'en', filter: 'en'}); | ||
var index_de = new FlexSearch({stemmer: 'de', filter: [/* custom */]}); | ||
var index_en = new FlexSearch({ | ||
stemmer: "en", | ||
filter: "en" | ||
}); | ||
var index_de = new FlexSearch({ | ||
stemmer: "de", | ||
filter: [ /* custom */ ] | ||
}); | ||
``` | ||
In Node.js you just need require the language pack files to make them available: | ||
In Node.js you just have to require the language pack files to make them available: | ||
```js | ||
require('lang/en.js'); | ||
require('lang/de.js'); | ||
require("flexsearch.js"); | ||
require("lang/en.js"); | ||
require("lang/de.js"); | ||
``` | ||
@@ -942,4 +967,6 @@ | ||
<a name="index.info"></a> | ||
#### Get info about an index | ||
### Get info about an index | ||
> This feature is available in _DEBUG_ mode. | ||
```js | ||
@@ -953,11 +980,18 @@ index.info(); | ||
{ | ||
"bytes": 64000, | ||
"id": 0, | ||
"memory": 10000, | ||
"items": 500, | ||
"sequences": 3000, | ||
"matchers": 0, | ||
"size": 10000, | ||
"status": false | ||
"chars": 3500, | ||
"cache": false, | ||
"matcher": 0, | ||
"worker": false, | ||
"threshold": 7, | ||
"depth": 3, | ||
"contextual": true | ||
} | ||
``` | ||
<a name="chaining"></a> | ||
#### Chaining | ||
### Chaining | ||
@@ -977,5 +1011,6 @@ Simply chain methods like: | ||
#### Enable Contextual Index | ||
<a name="contextual_enable"></a> | ||
### Enable Contextual Scoring | ||
Create index and just set the limit of relevance ("depth"): | ||
Create an index and just set the limit of relevance as "depth": | ||
```js | ||
@@ -986,2 +1021,3 @@ var index = new FlexSearch({ | ||
tokenize: "strict", | ||
threshold: 7, | ||
depth: 3 | ||
@@ -991,4 +1027,10 @@ }); | ||
> Only the tokenizer "strict" is actually supported by the contextual index. | ||
> The contextual index requires <a href="#memory">additional amount of memory</a> depending on depth. | ||
> Try to use the __lowest depth__ and __highest threshold__ which fits your needs. | ||
<a name="cache"></a> | ||
#### Enable Auto-Balanced Cache | ||
### Enable Auto-Balanced Cache | ||
@@ -1004,4 +1046,13 @@ Create index and just set a limit of cache entries: | ||
#### Use WebWorker Sharding (Browser only) | ||
> When passing a number as a limit the cache automatically balance stored entries related to their popularity. | ||
> When just using "true" the cache is unbounded and perform actually 2-3 times faster (because the balancer do not have to run). | ||
<a name="webworker"></a> | ||
### WebWorker Sharding (Browser only) | ||
Worker get its own dedicated memory and also run in their own dedicated thread without blocking the UI while processing. Especially for larger indexes, web worker improves speed and available memory a lot. FlexSearch index was tested with a 250 Mb text file including 10 Million words. <!--The indexing was done silently in background by multiple parallel running workers in about 7 minutes. The final index reserves ~ 8.2 Mb memory/space. The search result took ~ 0.25 ms.--> | ||
> When the index isn't big enough it is faster to use no web worker. | ||
Create index and just set the count of parallel threads: | ||
@@ -1031,2 +1082,10 @@ ```js | ||
Or use promises accordingly: | ||
```js | ||
index.search("John Doe").then(function(results){ | ||
// do something with array of results | ||
}); | ||
``` | ||
<a name="options"></a> | ||
@@ -1060,3 +1119,3 @@ ## Options | ||
<tr> | ||
<td align="top">tokenize<br><br><br><br><br><br></td> | ||
<td align="top">tokenize<br><br><br><br><br><!--<br>--></td> | ||
<td vertical="top" vertical-align="top"> | ||
@@ -1066,3 +1125,3 @@ "strict"<br> | ||
"reverse"<br> | ||
"ngram"<br> | ||
<!--"ngram"<br>--> | ||
"full"<br> | ||
@@ -1197,2 +1256,3 @@ function() | ||
<tr></tr> | ||
<!-- | ||
<tr> | ||
@@ -1205,2 +1265,3 @@ <td><b>"ngram"</b> (default)</td> | ||
<tr></tr> | ||
--> | ||
<tr> | ||
@@ -1294,6 +1355,6 @@ <td><b>"foward"</b></td> | ||
<td align="left">Query</td> | ||
<td align="left">iCase</td> | ||
<td align="left">Simple</td> | ||
<td align="left">Advanced</td> | ||
<td align="left">Extra</td> | ||
<td align="left">icase</td> | ||
<td align="left">simple</td> | ||
<td align="left">advanced</td> | ||
<td align="left">extra</td> | ||
</tr> | ||
@@ -1439,2 +1500,3 @@ <tr> | ||
</tr> | ||
<!-- | ||
<tr></tr> | ||
@@ -1445,2 +1507,3 @@ <tr> | ||
</tr> | ||
--> | ||
<tr></tr> | ||
@@ -1480,7 +1543,7 @@ <tr> | ||
<a name="profiles"></a> | ||
## Built-in Profiles | ||
## Presets | ||
You can pass a built-in profile during creation/initialization. They have these following settings: | ||
You can pass a preset during creation/initialization. They represents these following settings: | ||
Standard profile: __"default"__ | ||
__"default"__: Standard profile | ||
```js | ||
@@ -1493,3 +1556,3 @@ { | ||
Memory-optimized profile: __"memory"__ | ||
__"memory"__: Memory-optimized profile | ||
```js | ||
@@ -1503,3 +1566,3 @@ { | ||
Speed-optimized profile: __"speed"__ | ||
__"speed"__: Speed-optimized profile | ||
@@ -1515,3 +1578,3 @@ ```js | ||
Matching-tolerant profile: __"match"__ | ||
__"match"__: Matching-tolerant profile | ||
@@ -1525,3 +1588,3 @@ ```js | ||
Relevance-optimized profile: __"score"__ | ||
__"score"__: Relevance-optimized profile | ||
@@ -1537,8 +1600,8 @@ ```js | ||
Most-balanced profile: __"balanced"__ | ||
__"balance"__: Most-balanced profile | ||
```js | ||
{ | ||
encode: "balanced", | ||
tokenize: "ngram", | ||
encode: "balance", | ||
tokenize: "strict", | ||
threshold: 6, | ||
@@ -1549,3 +1612,3 @@ depth: 3 | ||
Absolute fastest profile: __"fastest"__ | ||
__"fastest"__: Absolute fastest profile | ||
@@ -1560,7 +1623,114 @@ ```js | ||
Compare these options above: | ||
- <a href="https://jsperf.com/compare-flexsearch-options" target="_blank">Benchmarks</a> | ||
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching-flexsearch.html" target="_blank">Relevance Scoring</a> | ||
Compare these presets: | ||
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching-flexsearch.html" target="_blank">Relevance Scoring</a><br> | ||
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark-presets.html" target="_blank">Benchmarks</a> | ||
<a name="builds"></a> | ||
## Best Practices | ||
__Divide & Conquer__ | ||
Whenenver 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(); | ||
``` | ||
__Use numeric IDs__ | ||
It is recommended to use numeric id values as reference when adding content to the index. The byte length of passed ids influences the memory consumption significantly. If this is not possible you should consider to use a index table and map the ids with indexes, this becomes important especially when using contextual indexes on a large amount of content. | ||
e.g. instead of this: | ||
```js | ||
index.add("fdf12cad-8779-47ab-b614-4dbbd649178b", "content"); | ||
``` | ||
you should probably use this: | ||
```js | ||
var index_table = { | ||
"fdf12cad-8779-47ab-b614-4dbbd649178b": 0, | ||
"48b3041c-a243-4a52-b1ed-225041847366": 1, | ||
"7236c8b5-86e1-451a-842f-d9aba9642e4d": 2, | ||
// .... | ||
}; | ||
index.add(index_table["fdf12cad-8779-47ab-b614-4dbbd649178b"], "content"); | ||
``` | ||
It is planned to provide a built-in feature which should replace this workaround. | ||
<a name="debug"></a> | ||
## Debug | ||
> Do not use DEBUG in production builds. | ||
If you get issues, you can temporary set the _DEBUG_ flag to _true_ on top of _flexsearch.js_: | ||
```js | ||
DEBUG = true; | ||
``` | ||
This enables console logging of several processes. Just open the browsers console to make this information visible. | ||
<a name="profile"></a> | ||
## Profiler Stats | ||
> Do not use PROFILER in production builds. | ||
To collect some performance statistics of your indexes you need to temporary set the _PROFILER_ flag to _true_ on top of _flexsearch.js_: | ||
```js | ||
PROFILER = true; | ||
``` | ||
This enables profiling of several processes. | ||
An array of all profiles is available on: | ||
```js | ||
window.stats; | ||
``` | ||
You can also just open the browsers console and enter this line to get stats. | ||
> The index of the array corresponds to the _index.id_. | ||
Get stats from a specific index: | ||
```js | ||
index.stats; | ||
``` | ||
The returning stats payload is divided into several categories. Each of these category provides its own statistic values. | ||
__Profiler Stats Properties__ | ||
<table> | ||
<tr></tr> | ||
<tr> | ||
<td>Property</td> | ||
<td>Description</td> | ||
</tr> | ||
<tr> | ||
<td>time</td> | ||
<td>The sum of time (ms) the process takes (lower is better)</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>count</td> | ||
<td>How often the process was called</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>ops</td> | ||
<td>Average operations per seconds (higher is better)</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>nano</td> | ||
<td>Average cost (ns) per operation/call (lower is better)</td> | ||
</tr> | ||
</table> | ||
<a name="builds"></a> | ||
## Custom Builds | ||
@@ -1567,0 +1737,0 @@ |
/* | ||
FlexSearch v0.3.2 | ||
FlexSearch v0.3.3 | ||
Copyright 2019 Nextapps GmbH | ||
@@ -8,30 +8,30 @@ Author: Thomas Wilkerling | ||
*/ | ||
'use strict';function J(g){var h=0;return function(){return h<g.length?{done:!1,value:g[h++]}:{done:!0}}}function K(g){var h="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return h?h.call(g):{next:J(g)}}var S="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,T="function"==typeof Object.defineProperties?Object.defineProperty:function(g,h,e){g!=Array.prototype&&g!=Object.prototype&&(g[h]=e.value)}; | ||
function U(g,h){if(h){var e=S;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&&T(e,g,{configurable:!0,writable:!0,value:h})}} | ||
U("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(D){a.reject(D)}}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=S.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(v){this.f(v)}}}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(D){this.f(D);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)l.b(this.a[a]);this.a=null}};var l=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(v){d.reject(v)}};h.prototype.then=function(a,e){function d(a,d){return"function"==typeof a?function(d){try{g(a(d))}catch(E){k(E)}}:d}var g,k,m=new h(function(a,d){g=a;k=d});this.A(d(a,g),d(e,k));return m};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?l.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=K(a),g=e.next();!g.done;g=e.next())k(g.value).A(d,h)})};h.all=function(a){var d=K(a),e=d.next();return e.done?k([]):new h(function(a,h){function g(d){return function(h){m[d]=h;l--;0==l&&a(m)}}var m=[],l=0;do m.push(void 0),l++,k(e.value).A(g(m.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 aa(g){function e(b){E(b)&&(b=L[b]);b||(b=w);this.id=b.id||ba++;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 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,A,d,e){if(c[a])return c[a];A=A?(9-(e||6))*d+(e||6)*A:d;c[a]=A;A>=e&&(b=b[A+.5>>0],b=b[a]||(b[a]=[]),b[b.length]=f);return A}function m(b,c){if(b)for(var a=Object.keys(b),f=0,A=a.length;f<A;f++){var d=a[f],e=b[d];if(e)for(var r=0,g=e.length;r<g;r++)if(e[r]===c){1===g?delete b[d]:e.splice(r,1);break}else"object"===typeof e[r]&&m(e[r],c)}}function D(b){var c=[];if(!b)return c;for(var a=0,f=0,d=0,e="",g=b.length,r=0;r<g;r++){var z=b[r];"a"===z||"e"===z||"i"===z||"o"=== | ||
z||"u"===z||"y"===z?a++:f++;" "!==z&&(e+=z);if(" "===z||a>=(8<g?2:1)&&2<=f||2<=a&&f>=(8<g?2:1)||r===g-1)e&&(c[d]&&2<e.length&&d++,c[d]=c[d]?c[d]+e:e," "===z&&d++,e=""),f=a=0}return c}function v(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 V(b,c){var a={};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 Z(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 X(b,c){b=b.length-c.length;return 0>b?-1:b?1:0}function Y(b,c,a){var f=[],d=[],e=b.length;if(1<e){b.sort(X);for(var g={},r=b[0],t=r.length,k=0;k<t;)g[r[k++]]=1;for(var n,p=0,q=0;++q<e;){var u=!1,m=q===e-1;d=[];r=b[q];t= | ||
r.length;for(k=0;k<t;)if(n=r[k++],g[n]){var l=g[n];if(l===q){if(m){if(f[p++]=n,c&&p===c)return f}else g[n]=q+1;u=!0}else a&&(l=d[l]||(d[l]=[]),l[l.length]=n)}if(!u&&!a)break}if(a&&(p=f.length,(q=d.length)&&(!c||p<c)))for(;q--;)if(n=d[q])for(b=0,a=n.length;b<a;b++)if(f[p++]=n[b],c&&p===c)return f}else e&&(f=b[0],c&&f.length>c&&(f=f.slice(0,c)));return f}function E(b){return"string"===typeof b}function H(b){return"function"===typeof b}function x(b){return"undefined"===typeof b}function B(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.c[f];switch(d[0]){case C.add:b.add(d[1],d[2]);break;case C.remove:b.remove(d[1])}delete b.c[f];if(100<Date.now()-a)break}b.b.length&&B(b)}c&&(b.async=c)},1,"search-async-"+b.id))}function N(b){for(var c=Array(b),a=0;a<b;a++)c[a]={};return c}function ca(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=aa.toString();a.id=c;b.postMessage(c,{register:d,options:a,id:c});return b}var w={encode:"icase",h:"forward",w:!1,cache:!1,async:!1,i:!1,threshold:0,depth:0},L={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=[],ba=0,C={add:0,update:1,remove:2}, | ||
O=a("[ -/]"),P={},Q={},R=function(){for(var b=Object.getOwnPropertyNames({}.__proto__),c={},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){y[b]=c.bind(y);return this};e.registerLanguage=function(b,c){P[b]=c.filter;Q[b]=c.stemmer;return this};e.encode=function(b,c){return R[b]?c:y[b](c)};e.prototype.init=function(b){this.D=[];b||(b=w);var c= | ||
b.profile,a=c?L[c]:{};if(c=b.worker)if(Worker){var f=this,d=parseInt(c,10)||4;f.m=-1;f.o=0;f.f=[];f.C=null;f.j=Array(d);for(var e=0;e<d;e++)f.j[e]=ca(f.id,e,b,function(b,c,a,d){if(f.o!==f.i)return f.f=f.f.concat(a),f.o++,d&&f.f.length>=d&&(f.o=f.i),f.C&&f.o===f.i&&(f.cache&&f.g.set(c,f.f),f.C(f.f),f.f=[]),f})}else b.worker=!1,this.j=null;this.h=b.tokenize||a.h||this.h||w.h;this.async=x(c=b.async)?this.async||w.async:c;this.i=x(c=b.worker)?this.i||w.i:c;this.threshold=x(c=b.threshold)?a.threshold|| | ||
this.threshold||w.threshold:c;this.depth=x(c=b.depth)?a.depth||this.depth||w.depth:c;this.w=x(c=b.suggest)?this.w||w.w:c;this.s=(c=x(c=b.encode)?a.encode:c)&&y[c]&&y[c].bind(y)||(H(c)?c:this.s||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter)this.filter=V(P[c]||c,this.s);if(c=b.stemmer)this.stemmer=Z(Q[c]||c,this.s);this.v=N(10);this.l={};this.a={};this.c={};this.b=[];this.F=0;this.u=!0;this.g=(this.cache=c=x(c=b.cache)?this.cache||w.cache:c)?new da(c):!1;return this};e.prototype.encode=function(b){b&& | ||
F.length&&(b=l(b,F));b&&this.D.length&&(b=l(b,this.D));b&&this.s&&(b=this.s(b));b&&this.stemmer&&(b=l(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&&E(c)&&(b&&!R[b]||0===b))if(this.a[b]&&!a)this.update(b,c);else{if(this.i)return++this.m>=this.j.length&&(this.m=0),this.j[this.m].postMessage(this.m,{add:!0,id:b,content:c}),this.a[b]=""+this.m,this;if(this.async)return this.c[b]|| | ||
(this.b[this.b.length]=b),this.c[b]=[C.add,b,c],B(this),this;c=this.encode(c);if(!c.length)return this;a=this.h;c=H(a)?a(c):"ngram"===a?D(c):c.split(O);for(var f={_ctx:{}},e=this.threshold,g=this.depth,k=this.v,r=c.length,t=0;t<r;t++){var l=c[t];if(l){var n=l.length,p=(r-t)/r,q="";switch(a){case "reverse":case "both":for(var u=n-1;1<=u;u--)q=l[u]+q,d(k,f,q,b,(n-u)/n,p,e);q="";case "forward":for(u=0;u<n;u++)q+=l[u],d(k,f,q,b,1,p,e);break;case "full":for(u=0;u<n;u++)for(var m=(n-u)/n,v=n;v>u;v--)q= | ||
l.substring(u,v),d(k,f,q,b,m,p,e);break;default:if(n=d(k,f,l,b,1,p,e),g&&1<r&&n>=e)for(n=f._ctx[l]||(f._ctx[l]={}),l=this.l[l]||(this.l[l]=N(10)),p=t-g,q=t+g+1,0>p&&(p=0),q>r&&(q=r);p<q;p++)p!==t&&d(l,n,c[p],b,0,10-(p<t?t-p:p-t),e)}}}this.a[b]=1;this.u=!1}return this};e.prototype.update=function(b,c){this.a[b]&&E(c)&&(this.remove(b),this.add(b,c,!0));return this};e.prototype.remove=function(b){if(this.a[b]){if(this.i){var c=this.a[b];this.j[c].postMessage(c,{remove:!0,id:b});delete this.a[b];return this}if(this.async)return this.c[b]|| | ||
(this.b[this.b.length]=b),this.c[b]=[C.remove,b],B(this),this;for(c=0;10>c;c++)m(this.v[c],b);this.depth&&m(this.l,b);delete this.a[b];this.u=!1}return this};e.prototype.search=function(b,c,a,f){var d=b,e=[];if("object"===typeof b){(a=b.callback||c)&&(d.callback=null);c=b.limit;var g=b.threshold;b=b.query}g||(g=this.threshold||0);H(c)?(a=c,c=1E3):c||0===c||(c=1E3);if(this.i)for(this.C=a,this.o=0,this.f=[],e=0;e<this.i;e++)this.j[e].postMessage(e,{search:!0,limit:c,threshold:g,content:b});else if(a){var k= | ||
this;M(function(){a(k.search(d,c,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(d,c,null,!0));l=null})}if(!b||!E(b))return e;d=b;if(this.cache)if(this.u){if(f=this.g.get(b))return f}else this.g.clear(),this.u=!0;d=this.encode(d);if(!d.length)return e;f=this.h;f=H(f)?f(d):"ngram"===f?D(d):d.split(O);var t=f.length,n=!0,p=[],q={};if(1<t)if(this.depth){var m=!0;var v=f[0];q[v]=1}else f.sort(W);var w; | ||
if(!m||(w=this.l)[v])for(var x=m?1:0;x<t;x++){var y=f[x];if(y&&!q[y]){var G=void 0;G=void 0;for(var C=!1,B=[],F=0,I=9;I>=g;I--)if(G=(m?w[v]:this.v)[I],G=G[y])B[F++]=G,C=!0;if(C)p[p.length]=1<F?p.concat.apply([],B):B[0];else if(!this.w){n=!1;break}q[y]=1}v=y}else n=!1;n&&(e=Y(p,c,this.w));this.cache&&this.g.set(b,e);return e}};e.prototype.clear=function(){this.destroy();return this.init()};e.prototype.destroy=function(){this.cache&&(this.g.clear(),this.g=null);this.filter=this.stemmer=this.v=this.l= | ||
this.a=this.c=this.b=null;return this};var y={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\\s+")," "];return function(c){c=l(c.toLowerCase(), | ||
b);return" "!==c?c:""}}(),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(c,a){if(!c)return c;c=this.simple(c);2<c.length&&(c=l(c,b));a||1<c.length&&(c=v(c));return c}}(),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=v(a)}return a}}(),balance:function(){var b=[a("[-/]")," ",a("[^a-z0-9 ]"),"",a("\\s\\s+")," "];return function(a){return v(l(a.toLowerCase(),b))}}()},M=function(){var b={};return function(a,d,f){var c=b[f];c&&clearTimeout(c);return b[f]=setTimeout(a,d)}}(),da=function(){function a(a){this.clear();this.B=!0!==a&&a}a.prototype.clear=function(){this.cache= | ||
{};this.count={};this.index={};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=Object.create(null),h="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,k,a,l,d){var m=e;e=h?URL.createObjectURL(new Blob(["("+a.toString()+")()"],{type:"text/javascript"})):m+".es5.js";m+="-"+k;g[m]||(g[m]=[]);g[m][d]=new Worker(e);g[m][d].onmessage=l;return{postMessage:function(a,d){g[m][a].postMessage(d)}}}}()),this); | ||
'use strict';function H(g){var h=0;return function(){return h<g.length?{done:!1,value:g[h++]}:{done:!0}}}function I(g){var h="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return h?h.call(g):{next:H(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,h,e){g!=Array.prototype&&g!=Object.prototype&&(g[h]=e.value)}; | ||
function S(g,h){if(h){var e=Q;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&&R(e,g,{configurable:!0,writable:!0,value:h})}} | ||
S("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(t){a.reject(t)}}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=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 h= | ||
d[a];d[a]=null;try{h()}catch(z){this.f(z)}}}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(t){this.f(t);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)l.b(this.a[a]);this.a=null}};var l=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(z){d.reject(z)}};h.prototype.then=function(a,e){function d(a,d){return"function"==typeof a?function(d){try{g(a(d))}catch(C){k(C)}}:d}var g,k,m=new h(function(a,d){g=a;k=d});this.A(d(a,g),d(e,k));return m};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?l.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=I(a),g=e.next();!g.done;g=e.next())k(g.value).A(d,h)})};h.all=function(a){var d=I(a),e=d.next();return e.done?k([]):new h(function(a,h){function g(d){return function(h){m[d]=h;l--;0==l&&a(m)}}var m=[],l=0;do m.push(void 0),l++,k(e.value).A(g(m.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 X(g){function e(b){F(b)&&(b=J[b]);b||(b=x);this.id=b.id||Y++;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 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,K,e){if(c[a])return c[a];d=d?(9-(e||6))*K+(e||6)*d:K;c[a]=d;d>=e&&(b=b[d+.5>>0],b=b[a]||(b[a]=[]),b[b.length]=f);return d}function m(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 r=0,k=g.length;r<k;r++)if(g[r]===c){1===k?delete b[e]:g.splice(r,1);break}else"object"===typeof g[r]&&m(g[r],c)}}function t(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 z(b,c){var a=w();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=[],e=b.length;if(1<e){b.sort(U);for(var g=w(),r=b[0],u=r.length,k=0;k<u;)g[r[k++]]=1;for(var n,p=0,q=0;++q<e;){var v=!1,m=q===e-1;d=[];r=b[q];u=r.length;for(k=0;k<u;)if(n=r[k++],g[n]){var l=g[n];if(l===q){if(m){if(f[p++]=n,c&&p===c)return f}else g[n]=q+1;v=!0}else a&&(l=d[l]||(d[l]=[]),l[l.length]=n)}if(!v&&!a)break}if(a&&(p=f.length,(q=d.length)&&(!c||p<c)))for(;q--;)if(n=d[q])for(b=0,a=n.length;b<a;b++)if(f[p++]=n[b],c&&p===c)return f}else e&& | ||
(f=b[0],c&&f.length>c&&(f=f.slice(0,c)));return f}function F(b){return"string"===typeof b}function C(b){return"function"===typeof b}function y(b){return"undefined"===typeof b}function D(b){b.F||(b.F=L(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.c[f];switch(d[0]){case B.add:b.add(d[1],d[2]);break;case B.remove:b.remove(d[1])}delete b.c[f];if(100<Date.now()-a)break}b.b.length&&D(b)}c&&(b.async=c)},1,"search-async-"+b.id))}function M(b){for(var c= | ||
Array(b),a=0;a<b;a++)c[a]=w();return c}function w(){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.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=X.toString();a.id=c;b.postMessage(c,{register:d,options:a,id:c});return b}var x={encode:"icase",h:"forward",w:!1,cache:!1,async:!1,i:!1,threshold:0,depth:0},J={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}},E=[],Y=0,B={add:0,update:1,remove:2},N=a("\\W+"),O={},P={};(function(){for(var b=Object.getOwnPropertyNames({}.__proto__),c=w(),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)&&E.push(a(c),b[c]);return this};e.registerEncoder= | ||
function(b,c){A[b]=c.bind(A);return this};e.registerLanguage=function(b,c){O[b]=c.filter;P[b]=c.stemmer;return this};e.encode=function(b,c){return A[b](c)};e.prototype.init=function(b){this.D=[];b||(b=x);var c=b.profile,a=c?J[c]:{};if(c=b.worker)if(Worker){var f=this,d=parseInt(c,10)||4;f.m=-1;f.o=0;f.f=[];f.C=null;f.j=Array(d);for(var e=0;e<d;e++)f.j[e]=Z(f.id,e,b,function(b,c,a,d){if(f.o!==f.i)return f.f=f.f.concat(a),f.o++,d&&f.f.length>=d&&(f.o=f.i),f.C&&f.o===f.i&&(f.cache&&f.g.set(c,f.f),f.C(f.f), | ||
f.f=[]),f})}else b.worker=!1,this.j=null;this.h=b.tokenize||a.h||this.h||x.h;this.async=y(c=b.async)?this.async||x.async:c;this.i=y(c=b.worker)?this.i||x.i:c;this.threshold=y(c=b.threshold)?a.threshold||this.threshold||x.threshold:c;this.depth=y(c=b.depth)?a.depth||this.depth||x.depth:c;this.w=y(c=b.suggest)?this.w||x.w:c;this.s=(c=y(c=b.encode)?a.encode:c)&&A[c]&&A[c].bind(A)||(C(c)?c:this.s||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter)this.filter=z(O[c]||c,this.s);if(c=b.stemmer)this.stemmer= | ||
T(P[c]||c,this.s);this.v=M(10);this.l=w();this.a=w();this.c=w();this.b=[];this.F=0;this.u=!0;this.g=(this.cache=c=y(c=b.cache)?this.cache||x.cache:c)?new aa(c):!1;return this};e.prototype.encode=function(b){b&&E.length&&(b=l(b,E));b&&this.D.length&&(b=l(b,this.D));b&&this.s&&(b=this.s(b));b&&this.stemmer&&(b=l(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&&F(c)&&(b||0=== | ||
b))if(this.a[b]&&!a)this.update(b,c);else{if(this.i)return++this.m>=this.j.length&&(this.m=0),this.j[this.m].postMessage(this.m,{add:!0,id:b,content:c}),this.a[b]=""+this.m,this;if(this.async)return this.c[b]||(this.b[this.b.length]=b),this.c[b]=[B.add,b,c],D(this),this;c=this.encode(c);if(!c.length)return this;a=this.h;c=C(a)?a(c):c.split(N);var f=w();f._ctx=w();for(var e=this.threshold,g=this.depth,k=this.v,r=c.length,u=0;u<r;u++){var l=c[u];if(l){var n=l.length,p=(r-u)/r,q="";switch(a){case "reverse":case "both":for(var v= | ||
n-1;1<=v;v--)q=l[v]+q,d(k,f,q,b,(n-v)/n,p,e);q="";case "forward":for(v=0;v<n;v++)q+=l[v],d(k,f,q,b,1,p,e);break;case "full":for(v=0;v<n;v++)for(var m=(n-v)/n,t=n;t>v;t--)q=l.substring(v,t),d(k,f,q,b,m,p,e);break;default:if(n=d(k,f,l,b,1,p,e),g&&1<r&&n>=e)for(n=f._ctx[l]||(f._ctx[l]=w()),l=this.l[l]||(this.l[l]=M(10)),p=u-g,q=u+g+1,0>p&&(p=0),q>r&&(q=r);p<q;p++)p!==u&&d(l,n,c[p],b,0,10-(p<u?u-p:p-u),e)}}}this.a[b]=1;this.u=!1}return this};e.prototype.update=function(b,c){this.a[b]&&F(c)&&(this.remove(b), | ||
this.add(b,c,!0));return this};e.prototype.remove=function(b){if(this.a[b]){if(this.i){var c=this.a[b];this.j[c].postMessage(c,{remove:!0,id:b});delete this.a[b];return this}if(this.async)return this.c[b]||(this.b[this.b.length]=b),this.c[b]=[B.remove,b],D(this),this;for(c=0;10>c;c++)m(this.v[c],b);this.depth&&m(this.l,b);delete this.a[b];this.u=!1}return this};e.prototype.search=function(b,c,a,d){var f=b,e=[];if("object"===typeof b){(a=b.callback||c)&&(f.callback=null);c=b.limit;var g=b.threshold; | ||
b=b.query}g||(g=this.threshold||0);C(c)?(a=c,c=1E3):c||0===c||(c=1E3);if(this.i)for(this.C=a,this.o=0,this.f=[],e=0;e<this.i;e++)this.j[e].postMessage(e,{search:!0,limit:c,threshold:g,content:b});else if(a){var k=this;L(function(){a(k.search(f,c,null,!0));k=null},1,"search-"+this.id)}else{if(!d&&this.async&&"function"!==typeof importScripts){var l=this;return new Promise(function(b){b(l.search(f,c,null,!0));l=null})}if(!b||!F(b))return e;f=b;if(this.cache)if(this.u){if(d=this.g.get(b))return d}else this.g.clear(), | ||
this.u=!0;f=this.encode(f);if(!f.length)return e;d=this.h;d=C(d)?d(f):f.split(N);var u=d.length,n=!0,p=[],q=w();if(1<u)if(this.depth){var m=!0;var t=d[0];q[t]=1}else d.sort(W);var x;if(!m||(x=this.l)[t])for(var y=m?1:0;y<u;y++){var z=d[y];if(z){if(!q[z]){var A=[],B=!1,D=0;if(t=m?x[t]:this.v)for(var E=void 0,G=9;G>=g;G--)if(E=t[G][z])A[D++]=E,B=!0;if(B)p[p.length]=1<D?A.concat.apply([],A):A[0];else if(!this.w){n=!1;break}q[z]=1}t=z}}else n=!1;n&&(e=V(p,c,this.w));this.cache&&this.g.set(b,e);return e}}; | ||
e.prototype.clear=function(){this.destroy();return this.init()};e.prototype.destroy=function(){this.cache&&(this.g.clear(),this.g=null);this.filter=this.stemmer=this.v=this.l=this.a=this.c=this.b=null;return this};var A={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=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=t(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=t(a)}return a}}(),balance:function(){var b=[a("[-/]")," ",a("[^a-z0-9 ]"),"",a("\\s+")," "];return function(a){return t(l(a.toLowerCase(),b))}}()},L=function(){var a=w();return function(b, | ||
d,f){var c=a[f];c&&clearTimeout(c);return a[f]=setTimeout(b,d)}}(),aa=function(){function a(a){this.clear();this.B=!0!==a&&a}a.prototype.clear=function(){this.cache=w();this.count=w();this.index=w();this.a=[]};a.prototype.set=function(a,b){if(this.B&&y(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,l,d){var m=e;e=h?URL.createObjectURL(new Blob(["("+a.toString()+")()"],{type:"text/javascript"})):m+".es5.js";m+="-"+k;g[m]||(g[m]=[]);g[m][d]=new Worker(e); | ||
g[m][d].onmessage=l;return{postMessage:function(a,d){g[m][a].postMessage(d)}}}}()),this); |
@@ -458,7 +458,8 @@ if(typeof module !== "undefined"){ | ||
setTimeout(function(){ | ||
// (async function(){ | ||
// | ||
// expect(await flexsearch_async.search("foo")).to.have.members([0, 1]); | ||
// })(); | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}); | ||
@@ -474,7 +475,3 @@ | ||
setTimeout(function(){ | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}); | ||
@@ -504,7 +501,3 @@ | ||
setTimeout(function(){ | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}); | ||
@@ -677,7 +670,3 @@ }); | ||
setTimeout(function(){ | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}); | ||
@@ -727,7 +716,3 @@ | ||
setTimeout(function(){ | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}); | ||
@@ -743,7 +728,3 @@ | ||
setTimeout(function(){ | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}); | ||
@@ -773,7 +754,3 @@ | ||
setTimeout(function(){ | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}); | ||
@@ -811,7 +788,3 @@ }); | ||
setTimeout(function(){ | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}, 25); | ||
@@ -853,7 +826,3 @@ }); | ||
setTimeout(function(){ | ||
done(); | ||
}, 25); | ||
setTimeout(done, 25); | ||
}, 25); | ||
@@ -860,0 +829,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17
1768
272290
3547