flexsearch
Advanced tools
Comparing version 0.2.32 to 0.2.42
/* | ||
FlexSearch v0.2.32 | ||
Copyright 2017-2018 Thomas Wilkerling | ||
FlexSearch v0.2.42 | ||
Copyright 2018 Thomas Wilkerling | ||
Released under the Apache 2.0 Licence | ||
https://github.com/nextapps-de/flexsearch | ||
*/ | ||
'use strict';(function(n,C,g){var p;(p=g.define)&&p.amd?p([],function(){return C}):(p=g.modules)?p[n.toLowerCase()]=C:"undefined"!==typeof module?module.exports=C:g[n]=C})("FlexSearch",function L(n){function g(a){"string"===typeof a?a=G[a]||v:a||(a=v);this.id=a.id||M++;this.init(a);p(this,"index",function(){return this.a});p(this,"length",function(){return Object.keys(this.a).length})}function p(a,b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function w(a,b,c){if("undefined"=== | ||
typeof c){for(c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}return a.replace(b,c)}function t(a,b,c,e,f,k){if("undefined"===typeof b[c]){var h=f.indexOf(c);h=3/f.length*(f.length-h)+6/(h-f.lastIndexOf(" ",h))+.5|0;b[c]=h;h>=k&&(a=a[h],a=a[c]||(a[c]=[]),a[a.length]=e)}return h||b[c]}function x(a){var b=[];if(!a)return b;for(var c=0,e=0,f=0,k="",h=a.length,B=0;B<h;B++){var d=a[B];"a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d?c++:e++;" "!==d&&(k+=d);if(" "===d||1<c&&1<e||2<c||2<e||B=== | ||
h-1)k&&(b[f]&&2<k.length&&f++,b[f]=b[f]?b[f]+k:k," "===d&&f++,k=""),e=c=0}return b}function F(a){for(var b="",c="",e="",f=0;f<a.length;f++){var k=a[f];if(k!==c)if(f&&"h"===k){if(e="a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&e||" "===c)b+=k}else b+=k;e=f===a.length-1?"":a[f+1];c=k}return b}function N(a,b){var c={};if(H)for(var e=0;e<a.length;e++){var f=b?b.call(y,a[e]):a[e];c[f]=String.fromCharCode(65E3-a.length+e)}return c}function O(a, | ||
b){var c=[];if(a){var e=0,f;for(f in a)if(a.hasOwnProperty(f)){var k=b?b.call(y,f):f;c[e++]=d("(?=.{"+(k.length+3)+",})"+k+"$");c[e++]=b?b.call(y,a[f]):a[f]}}return c}function P(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function Q(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function R(a,b){var c=[],e=a.length;if(1<e){a.sort(Q);for(var f={},k=a[0],d=k.length,B=0;B<d;)f[k[B++]]=1;for(var g,q=0,m=1;m<e;){var r=!1;k=a[m];d=k.length;for(B=0;B<d;)if(f[g=k[B++]]===m){if(m===e-1&&(c[q++]=g,b&&q=== | ||
b)){r=!1;break}r=!0;f[g]=m+1}if(!r)break;m++}}else e&&(c=a[0],b&&c&&c.length>b&&(c=c.slice(0,b)));return c}function E(a){a.B||(a.B=I(function(){a.B=null;var b=a.async;b&&(a.async=!1);if(a.c.length){for(var c=J(),e;(e=a.c.shift())||0===e;){var f=a.h[e];switch(f[0]){case D.add:a.add(f[1],f[2]);break;case D.update:a.update(f[1],f[2]);break;case D.remove:a.remove(f[1])}a.h[e]=null;delete a.h[e];if(100<J()-c)break}a.c.length&&E(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function J(){return"undefined"!== | ||
typeof performance?performance.now():(new Date).getTime()}function S(a,b,c,e){a=n("flexsearch","id"+a,function(){var a,b;self.a=function(c){if(c=c.data)c.search?self.postMessage({result:b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit),id:a,content:c.content,limit:c.limit}):c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.reset?b.reset():c.info?(c=b.info(),c.worker=a,b.C&&console.log(c)):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?e(a.id,a.content,a.result,a.limit):c.debug&&console.log(a)},b);var f=L.toString();c.id=b;a.postMessage(b,{register:f,options:c,id:b});return a}var v={encode:"icase",mode:"forward",cache:!1,async:!1,b:!1,threshold:0,depth:0},G={memory:{encode:"extra",mode:"strict",threshold:7},speed:{encode:"icase",mode:"strict",threshold:7,depth:2}, | ||
match:{encode:"extra",mode:"full"},score:{encode:"extra",mode:"strict",threshold:5,depth:4},balance:{encode:"balance",mode:"ngram",threshold:6,depth:3},fastest:{encode:"icase",threshold:9,depth:1}},z=[],M=0,D={add:0,update:1,remove:2},K=d("[ -/]"),T="a about above after again against all also am an and any are aren't as at be because been before being below both but by can cannot can't come could couldn't did didn't do does doesn't doing dont down during each even few first for from further get go had hadn't has hasn't have haven't having he hed her here here's hers herself hes him himself his how how's i id if ill im in into is isn't it it's itself i've just know let's like make me more most mustn't my myself new no nor not now of off on once only or other ought our our's ourselves out over own same say see shan't she she'd shell shes should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through time to too until up us very want was wasn't way we wed well were weren't we've what what's when when's where where's which while who whom who's why why's will with won't would wouldn't you you'd you'll your you're your's yourself yourselves you've".split(" "), | ||
H={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log",icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:"",al:"",ance:"",ence:"",er:"",ic:"",able:"",ible:"",ant:"",ement:"",ment:"",ent:"",ou:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:""};g.new=function(a){return new this(a)};g.create=function(a){return g.new(a)}; | ||
g.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(z[z.length]=d(b),z[z.length]=a[b]);return this};g.register=function(a,b){y[a]=b;return this};g.encode=function(a,b){return y[a].call(y,b)};g.prototype.init=function(a){this.m=[];if(a){var b;if(b=a.worker)if("undefined"===typeof Worker)a.worker=!1,a.async=!0,this.j=null;else{var c=this;b=parseInt(b,10)||4;c.s=-1;c.o=0;c.i=[];c.w=null;c.j=Array(b);for(var e=0;e<b;e++)c.j[e]=S(c.id,e,a||v,function(a,b,e,f){c.o!==c.b&&(c.i=c.i.concat(e),c.o++, | ||
f&&c.i.length>=f&&(c.o=c.b),c.w&&c.o===c.b&&(c.i.length?c.f="":c.f||(c.f=b),c.cache&&c.l.set(b,c.i),c.w(c.i),c.i=[]))})}if(b=a.profile)if(b=G[b])for(var f in b)b.hasOwnProperty(f)&&"undefined"===typeof a[f]&&(a[f]=b[f]);this.mode=a.mode||this.mode||v.mode;this.cache=a.cache||this.cache||v.cache;this.async=a.async||this.async||v.async;this.b=a.worker||this.b||v.b;this.threshold=a.threshold||this.threshold||v.threshold;this.depth=a.depth||this.depth||v.depth;this.v=(b=a.encode)&&y[b]||("function"=== | ||
typeof b?b:this.v||!1);this.C=a.debug||this.C;(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.A=N(!0===b?T:b,this.v);if(b=a.stemmer)this.D=O(!0===b?H:b,this.v)}this.g=[{},{},{},{},{},{},{},{},{},{},{}];this.a={};this.h={};this.c=[];this.B=null;this.f="";this.u=!0;this.l=this.cache?new U(3E4,50,!0):!1;return this};g.prototype.encode=function(a){a&&z.length&&(a=w(a,z));a&&this.m.length&&(a=w(a,this.m));a&&this.v&&(a=this.v.call(y,a));if(a&&this.A){a=a.split(" ");for(var b=0;b<a.length;b++){var c= | ||
a[b];this.A[c]&&(a[b]=this.A[c])}a=a.join(" ")}a&&this.D&&(a=w(a,this.D));return a};g.prototype.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(this.m[this.m.length]=d(b),this.m[this.m.length]=a[b]);return this};g.prototype.add=function(a,b){if("string"===typeof b&&b&&(a||0===a))if(this.a[a])this.update(a,b);else{if(this.b)return++this.s>=this.j.length&&(this.s=0),this.j[this.s].postMessage(this.s,{add:!0,id:a,content:b}),this.a[a]=""+this.s,this;if(this.async)return this.h[a]||(this.c[this.c.length]= | ||
a),this.h[a]=[D.add,a,b],E(this),this;b=this.encode(b);if(!b.length)return this;for(var c=this.mode,e="function"===typeof c?c(b):"ngram"===c?x(b):b.split(K),f={_ctx:{}},d=this.threshold,h=this.depth,g=this.g,n=e.length,q=0;q<n;q++){var m=e[q];if(m){var r=m.length;switch(c){case "reverse":case "both":for(var u="",l=r-1;1<=l;l--)u=m[l]+u,t(g,f,u,a,b,d);case "forward":u="";for(l=0;l<r;l++)u+=m[l],t(g,f,u,a,b,d);break;case "full":for(l=0;l<r;l++)for(var A=r;A>l;A--)u=m.substring(l,A),t(g,f,u,a,b,d);break; | ||
default:if(l=t(g,f,m,a,b,d),h&&1<n&&l>=d)for(l=g[10],r=f._ctx[m]||(f._ctx[m]={}),m=l[m]||(l[m]=[{},{},{},{},{},{},{},{},{},{}]),l=q-h,A=q+h,0>l&&(l=0),A>n-1&&(A=n-1);l<=A;l++)l!==q&&t(m,r,e[l],a,b,d)}}}this.a[a]="1";this.u=!1}return this};g.prototype.update=function(a,b){if("string"===typeof b&&(a||0===a)&&this.a[a]){if(this.b){var c=parseInt(this.a[a],10);this.j[c].postMessage(c,{update:!0,id:a,content:b});return this}if(this.async)return this.h[a]||(this.c[this.c.length]=a),this.h[a]=[D.update, | ||
a,b],E(this),this;this.remove(a);b&&this.add(a,b)}return this};g.prototype.remove=function(a){if(this.a[a]){if(this.b){var b=parseInt(this.a[a],10);this.j[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this}if(this.async)return this.h[a]||(this.c[this.c.length]=a),this.h[a]=[D.remove,a],E(this),this;for(b=0;10>b;b++)for(var c=Object.keys(this.g[b]),e=0;e<c.length;e++){var d=c[e],k=this.g[b];if((k=k&&k[d])&&k.length)for(var h=0;h<k.length;h++)if(k[h]===a){k.splice(h,1);break}k.length|| | ||
delete this.g[b][d]}delete this.a[a];this.u=!1}return this};g.prototype.search=function(a,b,c){var e=[];if(a&&"object"===typeof a){c=a.callback||b;b=a.limit;var d=a.threshold;a=a.query}d||(d=0);"function"===typeof b?(c=b,b=1E3):b||(b=1E3);if(this.b){this.w=c;this.o=0;this.i=[];for(e=0;e<this.b;e++)this.j[e].postMessage(e,{search:!0,limit:b,threshold:d,content:a});return null}if(c){var k=this;I(function(){c(k.search(a,b));k=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return e; | ||
var h=a;if(!this.u)this.cache&&(this.f="",this.l.reset()),this.u=!0;else if(this.cache){var g=this.l.get(a);if(g)return g}else if(this.f&&0===a.indexOf(this.f))return e;h=this.encode(h);if(!h.length)return e;g=this.mode;h="function"===typeof g?g(h):"ngram"===g?x(h):h.split(K);g=h.length;var n=!0,q=[],m={};if(1<g)if(this.depth){var r=!0,u=h[0];m[u]="1"}else h.sort(P);var l;if(!r||(l=this.g[10])[u])for(var A=r?1:0;A<g;A++){var p=h[A];if(p&&!m[p]){for(var v,w=!1,t=[],y=0,z=9;z>=d;z--)if(v=(r?l[u]:this.g)[z][p])t[y++]= | ||
v,w=!0;if(w)q[q.length]=1<y?q.concat.apply([],t):t[0];else{n=!1;break}m[p]="1"}u=p}else n=!1;n&&(e=R(q,b));e.length?this.f="":this.f||(this.f=a);this.cache&&this.l.set(a,e);return e};g.prototype.info=function(){if(this.b)for(var a=0;a<this.b;a++)this.j[a].postMessage(a,{info:!0,id:this.id});else{for(var b,c,d=0,f=0,g=0,h=0;10>h;h++)for(b=Object.keys(this.g[h]),a=0;a<b.length;a++)c=this.g[h][b[a]].length,d+=c+2*b[a].length+4,f+=c,g+=2*b[a].length;b=Object.keys(this.a);c=b.length;for(a=0;a<c;a++)d+= | ||
2*b[a].length+2;return{id:this.id,memory:d,items:c,sequences:f,chars:g,status:this.u,cache:this.c.length,matcher:z.length,worker:this.b}}};g.prototype.reset=function(){this.destroy();return this.init()};g.prototype.destroy=function(){this.cache&&this.l.reset();this.g=this.a=this.l=null;return this};var y={icase:function(a){return a.toLowerCase()},simple:function(){var a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), | ||
"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s\\s+")," "];return function(b){b=w(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){var a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b, | ||
c){if(!b)return b;b=this.simple(b);2<b.length&&(b=w(b,a));c||1<b.length&&(b=F(b));return b}}(),extra:function(){var a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+w(d.substring(1),a))}b=b.join(" ");b=F(b)}return b}}(),balance:function(){var a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s\\s+")," ",d("[aeiouy]"), | ||
""];return function(b){return F(w(b.toLowerCase(),a))}}()},I=function(){var a={};return function(b,c,d){var e=a[d];e&&clearTimeout(e);return a[d]=setTimeout(b,c)}}(),U=function(){function a(){this.cache={}}a.prototype.reset=function(){this.cache={}};a.prototype.set=function(a,c){this.cache[a]=c};a.prototype.get=function(a){return this.cache[a]};return a}();return g}(function(){var n={},C=!("undefined"===typeof Blob||"undefined"===typeof URL||!URL.createObjectURL);return function(g,p,d,w,t){var x= | ||
g;g=C?URL.createObjectURL(new Blob(["var SUPPORT_WORKER = true;var SUPPORT_BUILTINS = true;var SUPPORT_DEBUG = true;var SUPPORT_CACHE = true;var SUPPORT_ASYNC = true;("+d.toString()+")()"],{type:"text/javascript"})):"../"+x+".js";x+="-"+p;n[x]||(n[x]=[]);n[x][t]=new Worker(g);n[x][t].onmessage=w;console.log("Register Worker: "+x+"@"+t);return{postMessage:function(d,g){n[x][d].postMessage(g)}}}}()),this); | ||
'use strict';(function(r,B,g){var q;(q=g.define)&&q.amd?q([],function(){return B}):(q=g.modules)?q[r.toLowerCase()]=B:"undefined"!==typeof module?module.exports=B:g[r]=B})("FlexSearch",function K(r){function g(a){"string"===typeof a&&(a=F[a]);a||(a=v);this.id=a.id||L++;this.init(a);q(this,"index",function(){return this.a});q(this,"length",function(){return Object.keys(this.a).length})}function q(a,b,d){Object.defineProperty(a,b,{get:d})}function e(a){return new RegExp(a,"g")}function w(a,b,d){if("undefined"=== | ||
typeof d){for(d=0;d<b.length;d+=2)a=a.replace(b[d],b[d+1]);return a}return a.replace(b,d)}function x(a,b,d,c,f,l,k){if("undefined"===typeof b[d]){if(l)f=10-l;else{var h=f.indexOf(d);f=3/f.length*(f.length-h)+6/(h-f.lastIndexOf(" ",h))}h=f;b[d]=h;h>=k&&(a=a[h+.5|0],a=a[d]||(a[d]=[]),a[a.length]=c)}return h||b[d]}function n(a,b){if(a)for(var d=Object.keys(a),c=0,f=d.length;c<f;c++){var l=d[c],k=a[l];if(k)for(var h=0,e=k.length;h<e;h++)if(k[h]===b){1===e?delete a[l]:k.splice(h,1);break}else"object"=== | ||
typeof k[h]&&n(k[h],b)}}function G(a){var b=[];if(!a)return b;for(var d=0,c=0,f=0,l="",k=a.length,h=0;h<k;h++){var e=a[h];"a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e?d++:c++;" "!==e&&(l+=e);if(" "===e||1<d&&1<c||2<d||2<c||h===k-1)l&&(b[f]&&2<l.length&&f++,b[f]=b[f]?b[f]+l:l," "===e&&f++,l=""),c=d=0}return b}function D(a){for(var b="",d="",c="",f=0;f<a.length;f++){var 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 M(a,b){var d={};if(a)for(var c=0;c<a.length;c++){var f=b?b.call(z,a[c]):a[c];d[f]=String.fromCharCode(65E3-a.length+c)}return d}function N(a,b){var d=[];if(a){var c=0,f;for(f in a)if(a.hasOwnProperty(f)){var l=b?b.call(z,f):f;d[c++]=e("(?=.{"+(l.length+3)+",})"+l+"$");d[c++]=b?b.call(z,a[f]):a[f]}}return d}function O(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function P(a,b){a=a.length-b.length;return 0> | ||
a?-1:0<a?1:0}function Q(a,b){var d=[],c=a.length;if(1<c){a.sort(P);for(var f={},l=a[0],e=l.length,h=0;h<e;)f[l[h++]]=1;for(var g,y=0,p=1;p<c;){var t=!1;l=a[p];e=l.length;for(h=0;h<e;)if(f[g=l[h++]]===p){if(p===c-1&&(d[y++]=g,b&&y===b)){t=!1;break}t=!0;f[g]=p+1}if(!t)break;p++}}else if(c&&(d=a[0],b&&d.length>b))return d.slice(0,b);return d}function E(a){a.C||(a.C=H(function(){a.C=null;var b=a.async;b&&(a.async=!1);if(a.f.length){for(var d=I(),c;(c=a.f.shift())||0===c;){var f=a.h[c];switch(f[0]){case C.add:a.add(f[1], | ||
f[2]);break;case C.update:a.update(f[1],f[2]);break;case C.remove:a.remove(f[1])}a.h[c]=null;delete a.h[c];if(100<I()-d)break}a.f.length&&E(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function I(){return"undefined"!==typeof performance?performance.now():(new Date).getTime()}function R(a,b,d,c){a=r("flexsearch","id"+a,function(){var a,b;self.a=function(c){if(c=c.data)if(c.search){var 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.reset?b.reset():c.info?(c=b.info(),c.worker=a,b.F&&console.log(c)):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):d.debug&&console.log(a)},b);var f=K.toString();d.id= | ||
b;a.postMessage(b,{register:f,options:d,id:b});return a}var v={encode:"icase",mode:"ngram",cache:!1,async:!1,b:!1,threshold:0,depth:0},F={memory:{encode:"extra",mode:"strict",threshold:7},speed:{encode:"icase",mode:"strict",threshold:7,depth:2},match:{encode:"extra",mode:"full"},score:{encode:"extra",mode:"strict",threshold:5,depth:4},balance:{encode:"balance",mode:"ngram",threshold:6,depth:3},fastest:{encode:"icase",mode:"strict",threshold:9,depth:1}},A=[],L=0,C={add:0,update:1,remove:2},J=e("[ -/]"), | ||
S="a about above after again against all also am an and any are aren't as at be because been before being below both but by can cannot can't come could couldn't did didn't do does doesn't doing dont down during each even few first for from further get go had hadn't has hasn't have haven't having he hed her here here's hers herself hes him himself his how how's i id if ill im in into is isn't it it's itself i've just know let's like make me more most mustn't my myself new no nor not now of off on once only or other ought our our's ourselves out over own same say see shan't she she'd shell shes should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through time to too until up us very want was wasn't way we wed well were weren't we've what what's when when's where where's which while who whom who's why why's will with won't would wouldn't you you'd you'll your you're your's yourself yourselves you've".split(" "), | ||
T={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log",icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:"",al:"",ance:"",ence:"",er:"",ic:"",able:"",ible:"",ant:"",ement:"",ment:"",ent:"",ou:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:""};g.new=function(a){return new this(a)};g.create=function(a){return g.new(a)}; | ||
g.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(A[A.length]=e(b),A[A.length]=a[b]);return this};g.register=function(a,b){z[a]=b;return this};g.encode=function(a,b){return z[a].call(z,b)};g.prototype.init=function(a){this.B=[];if(a){var b=a.profile,d=b?F[b]:{};if(b=a.worker)if("undefined"===typeof Worker)a.worker=!1,a.async=!0,this.i=null;else{var c=this;b=parseInt(b,10)||4;c.s=-1;c.m=0;c.g=[];c.w=null;c.i=Array(b);for(var f=0;f<b;f++)c.i[f]=R(c.id,f,a||v,function(a,b,d,f){c.m!==c.b&& | ||
(c.g=c.g.concat(d),c.m++,f&&c.g.length>=f&&(c.m=c.b),c.w&&c.m===c.b&&(c.g.length?c.c="":c.c||(c.c=b),c.cache&&c.j.set(b,c.g),c.w(c.g),c.g=[]))})}this.mode=a.mode||d.mode||this.mode||v.mode;this.cache=a.cache||this.cache||v.cache;this.async=a.async||this.async||v.async;this.b=a.worker||this.b||v.b;this.threshold=a.threshold||d.threshold||this.threshold||v.threshold;this.depth=a.depth||d.depth||this.depth||v.depth;this.v=(b=a.encode||d.encode)&&z[b]||("function"===typeof b?b:this.v||!1);this.F=a.debug|| | ||
this.F;(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.A=M(!0===b?S:b,this.v);if(b=a.stemmer)this.D=N(!0===b?T:b,this.v)}this.l=[{},{},{},{},{},{},{},{},{},{}];this.o={};this.a={};this.h={};this.f=[];this.C=null;this.c="";this.u=!0;this.j=this.cache?new U(3E4,50,!0):!1;return this};g.prototype.encode=function(a){a&&A.length&&(a=w(a,A));a&&this.B.length&&(a=w(a,this.B));a&&this.v&&(a=this.v.call(z,a));if(a&&this.A){a=a.split(" ");for(var b=0;b<a.length;b++){var d=this.A[a[b]];d&&(a[b]=d)}a=a.join(" ")}a&& | ||
this.D&&(a=w(a,this.D));return a};g.prototype.addMatcher=function(a){var b=this.B,d;for(d in a)a.hasOwnProperty(d)&&(b[b.length]=e(d),b[b.length]=a[d]);return this};g.prototype.add=function(a,b,d){if("string"===typeof b&&b&&(a||0===a))if(this.a[a]&&!d)this.update(a,b);else{if(this.b)return++this.s>=this.i.length&&(this.s=0),this.i[this.s].postMessage(this.s,{add:!0,id:a,content:b}),this.a[a]=""+this.s,this;if(this.async)return this.h[a]||(this.f[this.f.length]=a),this.h[a]=[C.add,a,b],E(this),this; | ||
b=this.encode(b);if(!b.length)return this;d=this.mode;for(var c="function"===typeof d?d(b):"ngram"===d?G(b):b.split(J),f={_ctx:{}},e=this.threshold,k=this.depth,h=this.l,g=c.length,y=0;y<g;y++){var p=c[y];if(p){var t=p.length;switch(d){case "reverse":case "both":for(var u="",m=t-1;1<=m;m--)u=p[m]+u,x(h,f,u,a,b,0,e);case "forward":u="";for(m=0;m<t;m++)u+=p[m],x(h,f,u,a,b,0,e);break;case "full":for(m=0;m<t;m++)for(var n=t;n>m;n--)u=p.substring(m,n),x(h,f,u,a,b,0,e);break;default:if(m=x(h,f,p,a,b,k? | ||
1:0,e),k&&1<g&&m>=e)for(t=f._ctx[p]||(f._ctx[p]={}),p=this.o[p]||(this.o[p]=[{},{},{},{},{},{},{},{},{},{}]),m=y-k,n=y+k+1,0>m&&(m=0),n>g&&(n=g);m<n;m++)m!==y&&x(p,t,c[m],a,b,m<y?y-m:m-y,e)}}}this.a[a]="1";this.u=!1}return this};g.prototype.update=function(a,b){this.a[a]&&b&&"string"===typeof b&&(this.remove(a),this.add(a,b,!0));return this};g.prototype.remove=function(a){if(this.a[a]){if(this.b){var b=parseInt(this.a[a],10);this.i[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this}if(this.async)return this.h[a]|| | ||
(this.f[this.f.length]=a),this.h[a]=[C.remove,a],E(this),this;for(b=0;10>b;b++)n(this.l[b],a);this.depth&&n(this.o,a);delete this.a[a];this.u=!1}return this};g.prototype.search=function(a,b,d){var c=[];if(a&&"object"===typeof a){d=a.callback||b;b=a.limit;var f=a.threshold;a=a.query}f=(f||this.threshold||0)|0;"function"===typeof b?(d=b,b=1E3):b||(b=1E3);if(this.b){this.w=d;this.m=0;this.g=[];for(c=0;c<this.b;c++)this.i[c].postMessage(c,{search:!0,limit:b,threshold:f,content:a});return null}if(d){var e= | ||
this;H(function(){d(e.search(a,b));e=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return c;var k=a;if(!this.u)this.cache&&(this.c="",this.j.reset()),this.u=!0;else if(this.cache){var h=this.j.get(a);if(h)return h}else if(this.c&&0===a.indexOf(this.c))return c;k=this.encode(k);if(!k.length)return c;h=this.mode;k="function"===typeof h?h(k):"ngram"===h?G(k):k.split(J);h=k.length;var g=!0,n=[],p={};if(1<h)if(this.depth){var t=!0,u=k[0];p[u]="1"}else k.sort(O);var m;if(!t||(m=this.o)[u])for(var r= | ||
t?1:0;r<h;r++){var q=k[r];if(q&&!p[q]){for(var w,x=!1,v=[],z=0,A=9;A>=f;A--)if(w=(t?m[u]:this.l)[A][q])v[z++]=w,x=!0;if(x)n[n.length]=1<z?n.concat.apply([],v):v[0];else{g=!1;break}p[q]="1"}u=q}else g=!1;g&&(c=Q(n,b));c.length?this.c="":this.c||(this.c=a);this.cache&&this.j.set(a,c);return c};g.prototype.info=function(){if(this.b)for(var a=0;a<this.b;a++)this.i[a].postMessage(a,{info:!0,id:this.id});else{for(var b,d,c=0,f=0,e=0,g=0;10>g;g++)for(b=Object.keys(this.l[g]),a=0;a<b.length;a++)d=this.l[g][b[a]].length, | ||
c+=d+2*b[a].length+4,f+=d,e+=2*b[a].length;b=Object.keys(this.a);d=b.length;for(a=0;a<d;a++)c+=2*b[a].length+2;return{id:this.id,memory:c,items:d,sequences:f,chars:e,status:this.u,cache:this.f.length,matcher:A.length,worker:this.b}}};g.prototype.reset=function(){this.destroy();return this.init()};g.prototype.destroy=function(){this.cache&&this.j.reset();this.A=this.D=this.l=this.o=this.a=this.h=this.f=this.j=null;return this};var z={icase:function(a){return a.toLowerCase()},simple:function(){var 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(){var 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=D(b));return b}}(),extra:function(){var 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(var d=0;d<b.length;d++){var c=b[d]; | ||
1<c.length&&(b[d]=c[0]+w(c.substring(1),a))}b=b.join(" ");b=D(b)}return b}}(),balance:function(){var a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s\\s+")," ",e("[aeiouy]"),""];return function(b){return D(w(b.toLowerCase(),a))}}()},H=function(){var a={};return function(b,d,c){var f=a[c];f&&clearTimeout(f);return a[c]=setTimeout(b,d)}}(),U=function(){function a(a){this.reset();this.G=a||1E3}a.prototype.reset=function(){this.cache={};this.count={};this.index={};this.keys=[]};a.prototype.set=function(a,d){if(!this.count[a]){var b= | ||
this.keys.length;if(b===this.G){b--;var f=this.keys[b];delete this.cache[f];delete this.count[f];delete this.index[f]}this.index[a]=b;this.keys[b]=a;this.count[a]=1}this.cache[a]=d;this.get(a)};a.prototype.get=function(a){var b=this.cache[a];if(b){var c=++this.count[a],f=this.index,e=f[a];if(0<e){for(var g=this.keys,h=e;e&&this.count[g[e--]]<=c;);0<=e&&e+1!==h&&(c=g[e],f[a]=e,g.splice(e,1,a),f[c]=h,g.splice(h,1,c))}}return b};return a}();return g}(function(){var r={},B=!("undefined"===typeof Blob|| | ||
"undefined"===typeof URL||!URL.createObjectURL);return function(g,q,e,w,x){var n=g;g=B?URL.createObjectURL(new Blob(["var SUPPORT_WORKER = true;var SUPPORT_BUILTINS = true;var SUPPORT_DEBUG = true;var SUPPORT_CACHE = true;var SUPPORT_ASYNC = true;("+e.toString()+")()"],{type:"text/javascript"})):"../"+n+".js";n+="-"+q;r[n]||(r[n]=[]);r[n][x]=new Worker(g);r[n][x].onmessage=w;console.log("Register Worker: "+n+"@"+x);return{postMessage:function(e,g){r[n][e].postMessage(g)}}}}()),this); |
{ | ||
"name": "flexsearch", | ||
"version": "0.2.32", | ||
"version": "0.2.42", | ||
"description": "World's fastest and most memory efficient full text search library.", | ||
"keywords": [], | ||
"homepage": "https://nextapps-de.github.io/xone/", | ||
"author": "Thomas Wilkerling", | ||
"copyright": "Nextapps GmbH", | ||
"license": "Apache-2.0", | ||
"keywords": [ | ||
"full text search", | ||
"elastic search", | ||
"fastest search", | ||
"contextual search" | ||
], | ||
"bugs": { | ||
@@ -35,5 +44,2 @@ "url": "https://github.com/nextapps-de/flexsearch/issues", | ||
], | ||
"homepage": "https://nextapps-de.github.io/xone/", | ||
"author": "Thomas Wilkerling", | ||
"license": "Apache-2.0", | ||
"dependencies": {}, | ||
@@ -40,0 +46,0 @@ "devDependencies": { |
@@ -24,4 +24,5 @@ <p align="center"> | ||
Comparison: | ||
- <a href="https://jsperf.com/compare-search-libraries" target="_blank">Library Benchmarks</a> | ||
- <a href="https://jsperf.com/compare-search-libraries" target="_blank">Library Query Benchmarks</a> | ||
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">Library Relevance Scoring</a> | ||
- <a href="#consumption">Library Memory Consumption</a> | ||
@@ -87,2 +88,3 @@ Supported Platforms: | ||
<!-- | ||
#### Compare BulkSearch vs. FlexSearch | ||
@@ -139,2 +141,3 @@ | ||
</table> | ||
--> | ||
@@ -900,2 +903,10 @@ <a name="installation"></a> | ||
<a name="consumption"></a> | ||
#### Compare Memory Consumption | ||
The book "Gulliver's Travels" (Swift Jonathan 1726) was used for this test. | ||
<br> | ||
<img src="https://rawgithub.com/nextapps-de/flexsearch/master/doc/memory-comparison.svg"> | ||
<a name="profiles"></a> | ||
@@ -906,2 +917,10 @@ ## Built-in Profiles | ||
Standard profile: __"default"__ | ||
```js | ||
{ | ||
encode: "icase", | ||
mode: "forward" | ||
} | ||
``` | ||
Memory-optimized profile: __"memory"__ | ||
@@ -912,3 +931,5 @@ ```js | ||
mode: "strict", | ||
threshold: 7 | ||
threshold: 7, | ||
stemmer: true, | ||
filter: true | ||
} | ||
@@ -1008,3 +1029,3 @@ ``` | ||
Copyright 2017-2018 Thomas Wilkerling<br> | ||
Copyright 2018 Thomas Wilkerling<br> | ||
Released under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache 2.0 License</a><br> |
@@ -44,2 +44,3 @@ if(typeof module !== 'undefined'){ | ||
mode: 'forward', | ||
encode: false, | ||
@@ -52,2 +53,3 @@ async: false, | ||
mode: 'forward', | ||
encode: false, | ||
@@ -174,3 +176,3 @@ async: true, | ||
expect(flexsearch_default.async).to.equal(false); | ||
expect(flexsearch_default.mode).to.equal("forward"); | ||
expect(flexsearch_default.mode).to.equal("ngram"); | ||
expect(flexsearch_sync.async).to.equal(false); | ||
@@ -585,3 +587,3 @@ expect(flexsearch_async.async).to.equal(true); | ||
mode: 'strict', | ||
async: true, | ||
async: false, | ||
worker: 4 | ||
@@ -588,0 +590,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
1327114
2878
1025