flexsearch
Advanced tools
Comparing version 0.2.11 to 0.2.122
@@ -501,2 +501,3 @@ ;/**! | ||
var threshold = this.threshold; | ||
var depth = this.depth; | ||
var map = this._map; | ||
@@ -599,3 +600,3 @@ var word_length = words.length; | ||
if((word_length > 1) && this.depth && (score > threshold)){ | ||
if(depth && (word_length > 1) && (score > threshold)){ | ||
@@ -620,4 +621,4 @@ var ctx_map = map[10]; | ||
var x = i - this.depth; | ||
var y = i + this.depth; | ||
var x = i - depth; | ||
var y = i + depth; | ||
@@ -624,0 +625,0 @@ if(x < 0) x = 0; |
@@ -6,21 +6,21 @@ /* | ||
*/ | ||
'use strict';(function(p,C,f){var d;(d=f.define)&&d.amd?d([],function(){return C}):(d=f.modules)?d[p.toLowerCase()]=C:"undefined"!==typeof module?module.exports=C:f[p]=C})("FlexSearch",function H(p){function f(a){a||(a=u);this.id=a.id||I++;this.init(a);Object.defineProperty(this,"index",{get:function(){return this.a}});Object.defineProperty(this,"length",{get:function(){return Object.keys(this.a).length}})}function d(a){return new RegExp(a,"g")}function v(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 q(a,b,c,e,k,l){if("undefined"===typeof b[c]){var g=k.indexOf(c);g=3/k.length*(k.length-g)+6/(g-k.lastIndexOf(" ",g))+.5|0;b[c]=g;g>l&&(a=a[g],a=a[c]||(a[c]=[]),a[a.length]=e)}return g||b[c]}function x(a){for(var b="",c="",e="",k=0;k<a.length;k++){var l=a[k];l!==c&&(0<k&&"h"===l?(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||(b+=l)):b+=l);e=k===a.length- | ||
1?"":a[k+1];c=l}return b}function y(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function J(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function K(a,b){var c=[],e=a.length;if(1<e){a.sort(J);for(var k={},l=a[0],g=0,D=l.length;g<D;++g)k[l[g]]=1;for(var d=0,h=1;h<e;++h){var f=a[h],r=!1;g=0;for(D=f.length;g<D;++g)if(k[l=f[g]]===h){if(h===e-1&&(c[d++]=l,b&&d===b))return c;r=!0;k[l]=h+1;break}if(!r)return[]}}else e&&(c=a[0],b&&c&&c.length>b&&(c=c.slice(0,b)));return c}function z(a){a.w||(a.w=E(function(){a.w= | ||
null;var b=a.async;b&&(a.async=!1);if(a.c.length){for(var c=F(),e;(e=a.c.shift())||0===e;){var k=a.h[e];switch(k[0]){case A.add:a.add(k[1],k[2]);break;case A.update:a.update(k[1],k[2]);break;case A.remove:a.remove(k[1])}a.h[e]=null;delete a.h[e];if(100<F()-c)break}a.c.length&&z(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function F(){return"undefined"!==typeof performance?performance.now():(new Date).getTime()}function L(a,b,c,e){a=p("flexsearch","id"+a,function(){var a,b;self.a=function(c){if(c= | ||
'use strict';(function(m,C,f){var d;(d=f.define)&&d.amd?d([],function(){return C}):(d=f.modules)?d[m.toLowerCase()]=C:"undefined"!==typeof module?module.exports=C:f[m]=C})("FlexSearch",function H(m){function f(a){a||(a=t);this.id=a.id||I++;this.init(a);Object.defineProperty(this,"index",{get:function(){return this.a}});Object.defineProperty(this,"length",{get:function(){return Object.keys(this.a).length}})}function d(a){return new RegExp(a,"g")}function u(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 p(a,b,c,e,l,n){if("undefined"===typeof b[c]){var g=l.indexOf(c);g=3/l.length*(l.length-g)+6/(g-l.lastIndexOf(" ",g))+.5|0;b[c]=g;g>n&&(a=a[g],a=a[c]||(a[c]=[]),a[a.length]=e)}return g||b[c]}function x(a){for(var b="",c="",e="",l=0;l<a.length;l++){var n=a[l];n!==c&&(0<l&&"h"===n?(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||(b+=n)):b+=n);e=l===a.length- | ||
1?"":a[l+1];c=n}return b}function y(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function J(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function K(a,b){var c=[],e=a.length;if(1<e){a.sort(J);for(var l={},n=a[0],g=0,D=n.length;g<D;++g)l[n[g]]=1;for(var d=0,k=1;k<e;++k){var h=a[k],f=!1;g=0;for(D=h.length;g<D;++g)if(l[n=h[g]]===k){if(k===e-1&&(c[d++]=n,b&&d===b))return c;f=!0;l[n]=k+1;break}if(!f)return[]}}else e&&(c=a[0],b&&c&&c.length>b&&(c=c.slice(0,b)));return c}function z(a){a.w||(a.w=E(function(){a.w= | ||
null;var b=a.async;b&&(a.async=!1);if(a.c.length){for(var c=F(),e;(e=a.c.shift())||0===e;){var l=a.h[e];switch(l[0]){case A.add:a.add(l[1],l[2]);break;case A.update:a.update(l[1],l[2]);break;case A.remove:a.remove(l[1])}a.h[e]=null;delete a.h[e];if(100<F()-c)break}a.c.length&&z(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function F(){return"undefined"!==typeof performance?performance.now():(new Date).getTime()}function L(a,b,c,e){a=m("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.A&&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)},b);var k=H.toString();c.id=b;a.postMessage(b,{register:k,options:c,id:b});return a}var u={type:"integer",mode:"forward",cache:!1,async:!1,b:!1,threshold:0,depth:0,encode:"icase"},w=[],I=0,A={add:0,update:1,remove:2},G=d("[ -/]");f.new=function(a){return new this(a)};f.create=function(a){return f.new(a)};f.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(w[w.length]=d(b),w[w.length]=a[b]);return this};f.register=function(a, | ||
b){B[a]=b;return this};f.encode=function(a,b){return B[a].call(B,b)};f.prototype.init=function(a){this.m=[];if(a){if(a.worker)if("undefined"===typeof Worker)a.worker=!1,a.async=!0,this.j=null;else{var b=this,c=parseInt(a.worker,10)||4;b.s=-1;b.o=0;b.i=[];b.v=null;b.j=Array(c);for(var e=0;e<c;e++)b.j[e]=L(b.id,e,a||u,function(a,c,e,d){b.o!==b.b&&(b.i=b.i.concat(e),b.o++,d&&b.i.length>=d&&(b.o=b.b),b.v&&b.o===b.b&&(b.i.length?b.f="":b.f||(b.f=c),b.cache&&b.l.set(c,b.i),b.v(b.i),b.i=[]))})}this.mode= | ||
a.mode||this.mode||u.mode;this.cache=a.cache||this.cache||u.cache;this.async=a.async||this.async||u.async;this.b=a.worker||this.b||u.b;this.threshold=a.threshold||this.threshold||u.threshold;this.depth=a.depth||this.depth||u.depth;this.encoder=a.encode&&B[a.encode]||("function"===typeof a.encode?a.encode:this.encoder||!1);this.A=a.debug||this.A;a.matcher&&this.addMatcher(a.matcher)}this.g=[{},{},{},{},{},{},{},{},{},{},{}];this.a={};this.h={};this.c=[];this.w=null;this.f="";this.u=!0;this.l=this.cache? | ||
new M(3E4,50,!0):!1;return this};f.prototype.encode=function(a){a&&w.length&&(a=v(a,w));a&&this.m.length&&(a=v(a,this.m));a&&this.encoder&&(a=this.encoder.call(B,a));return a};f.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};f.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]=[A.add,a,b],z(this),this;b=this.encode(b);if(!b.length)return this;if("ngram"===this.mode){var c=b;var e=[];if(c)for(var d=0,l=0,g=-1,f="",n=c.length,h=0;h<n;h++){var m=c[h];"a"===m||"e"===m||"i"===m||"o"===m||"u"===m||"y"===m?d++:l++;" "!==m&&(f+=m);if(" "===m||2<=d&&2<=l||h===n-1)f&&(2<f.length?e[++g]=f:e[g]&&(e[g]+=f),f=""),l=d=0}c=e}else c=b.split(G);e={_ctx:{}};d=this.threshold; | ||
l=this.g;g=c.length;for(f=0;f<g;f++)if(n=c[f]){var r=n.length;switch(this.mode){case "reverse":case "both":var t="";for(h=r-1;1<=h;h--)t=n[h]+t,q(l,e,t,a,b,d);case "forward":t="";for(h=0;h<r;h++)t+=n[h],q(l,e,t,a,b,d);break;case "full":for(h=0;h<r;h++)for(m=r;m>h;m--)t=n.substring(h,m),q(l,e,t,a,b,d);break;default:if(h=q(l,e,n,a,b,d),1<g&&this.depth&&h>d)for(h=l[10],r=e._ctx[n]||(e._ctx[n]={}),n=h[n]||(h[n]=[{},{},{},{},{},{},{},{},{},{}]),h=f-this.depth,m=f+this.depth,0>h&&(h=0),m>g-1&&(m=g-1);h<= | ||
m;h++)h!==f&&q(n,r,c[h],a,b,d)}}this.a[a]="1";this.u=!1}return this};f.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]=[A.update,a,b],z(this),this;this.remove(a);b&&this.add(a,b)}return this};f.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]=[A.remove,a],z(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],f=this.g[b];if((f=f&&f[d])&&f.length)for(var g=0;g<f.length;g++)if(f[g]===a){f.splice(g,1);break}f.length||delete this.g[b][d]}delete this.a[a];this.u=!1}return this};f.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.v=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 f=this;E(function(){c(f.search(a,b));f=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return e;var g=a;if(!this.u)this.cache&&(this.f="",this.l.reset()),this.u=!0;else if(this.cache){var p=this.l.get(a);if(p)return p}else if(this.f&&0===a.indexOf(this.f))return e;g=this.encode(g); | ||
if(!g.length)return e;g=g.constructor===Array?g:g.split(G);p=g.length;var n=!0,h=[],m={};if(1<p)if(this.depth){var r=!0,t=g[0];m[t]="1"}else g.sort(y);var u;if(!r||(u=this.g[10])[t])for(var v=r?1:0;v<p;v++){var q=g[v];if(q&&!m[q]){for(var w,A=!1,x=[],B=0,z=9;z>=d;z--)if(w=r?u[t][z][q]:this.g[z][q])x[B++]=w,A=!0;if(A)h[h.length]=1<B?h.concat.apply([],x):x[0];else{n=!1;break}m[q]="1"}t=q}else n=!1;n&&(e=K(h,b));e.length?this.f="":this.f||(this.f=a);this.cache&&this.l.set(a,e);return e};f.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,e=0,d=0,f=0,g=0;10>g;g++)for(b=Object.keys(this.g[g]),a=0;a<b.length;a++)c=this.g[g][b[a]].length,e+=c+2*b[a].length+4,d+=c,f+=2*b[a].length;b=Object.keys(this.a);c=b.length;for(a=0;a<c;a++)e+=2*b[a].length+2;return{id:this.id,memory:e,items:c,sequences:d,chars:f,status:this.u,cache:this.c.length,matcher:w.length,worker:this.b}}};f.prototype.reset=function(){this.destroy();return this.init()}; | ||
f.prototype.destroy=function(){this.cache&&this.l.reset();this.g=this.a=this.l=null;return this};var B={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("[-/]")," ",d("[^a-z0-9 ]"),""];return function(b){return v(b.toLowerCase(), | ||
a)}}(),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=v(b,a));c||1<b.length&&(b=x(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]+v(d.substring(1),a))}b=b.join("");b=x(b)}return b}}()},E=function(){var a={};return function(b,c,d){var e=a[d];e&&clearTimeout(e);return a[d]=setTimeout(b,c)}}(),M=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 f}(function(){var p={},C= | ||
!("undefined"===typeof Blob||"undefined"===typeof URL||!URL.createObjectURL);return function(f,d,v,q,x){var y=f;f=C?URL.createObjectURL(new Blob(["("+v.toString()+")()"],{type:"text/javascript"})):"../"+y+".js";y+="-"+d;p[y]||(p[y]=[]);p[y][x]=new Worker(f);p[y][x].onmessage=q;return{postMessage:function(d,f){p[y][d].postMessage(f)}}}}()),this); | ||
function(a){(a=a.data)&&a.result&&e(a.id,a.content,a.result,a.limit)},b);var l=H.toString();c.id=b;a.postMessage(b,{register:l,options:c,id:b});return a}var t={type:"integer",mode:"forward",cache:!1,async:!1,b:!1,threshold:0,depth:0,encode:"icase"},v=[],I=0,A={add:0,update:1,remove:2},G=d("[ -/]");f.new=function(a){return new this(a)};f.create=function(a){return f.new(a)};f.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(v[v.length]=d(b),v[v.length]=a[b]);return this};f.register=function(a, | ||
b){B[a]=b;return this};f.encode=function(a,b){return B[a].call(B,b)};f.prototype.init=function(a){this.m=[];if(a){if(a.worker)if("undefined"===typeof Worker)a.worker=!1,a.async=!0,this.j=null;else{var b=this,c=parseInt(a.worker,10)||4;b.s=-1;b.o=0;b.i=[];b.v=null;b.j=Array(c);for(var e=0;e<c;e++)b.j[e]=L(b.id,e,a||t,function(a,c,e,d){b.o!==b.b&&(b.i=b.i.concat(e),b.o++,d&&b.i.length>=d&&(b.o=b.b),b.v&&b.o===b.b&&(b.i.length?b.f="":b.f||(b.f=c),b.cache&&b.l.set(c,b.i),b.v(b.i),b.i=[]))})}this.mode= | ||
a.mode||this.mode||t.mode;this.cache=a.cache||this.cache||t.cache;this.async=a.async||this.async||t.async;this.b=a.worker||this.b||t.b;this.threshold=a.threshold||this.threshold||t.threshold;this.depth=a.depth||this.depth||t.depth;this.encoder=a.encode&&B[a.encode]||("function"===typeof a.encode?a.encode:this.encoder||!1);this.A=a.debug||this.A;a.matcher&&this.addMatcher(a.matcher)}this.g=[{},{},{},{},{},{},{},{},{},{},{}];this.a={};this.h={};this.c=[];this.w=null;this.f="";this.u=!0;this.l=this.cache? | ||
new M(3E4,50,!0):!1;return this};f.prototype.encode=function(a){a&&v.length&&(a=u(a,v));a&&this.m.length&&(a=u(a,this.m));a&&this.encoder&&(a=this.encoder.call(B,a));return a};f.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};f.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]=[A.add,a,b],z(this),this;b=this.encode(b);if(!b.length)return this;if("ngram"===this.mode){var c=b;var e=[];if(c)for(var d=0,n=0,g=-1,f="",q=c.length,k=0;k<q;k++){var h=c[k];"a"===h||"e"===h||"i"===h||"o"===h||"u"===h||"y"===h?d++:n++;" "!==h&&(f+=h);if(" "===h||2<=d&&2<=n||k===q-1)f&&(2<f.length?e[++g]=f:e[g]&&(e[g]+=f),f=""),n=d=0}c=e}else c=b.split(G);e={_ctx:{}};d=this.threshold; | ||
n=this.depth;g=this.g;f=c.length;for(q=0;q<f;q++)if(k=c[q]){var m=k.length;switch(this.mode){case "reverse":case "both":var r="";for(h=m-1;1<=h;h--)r=k[h]+r,p(g,e,r,a,b,d);case "forward":r="";for(h=0;h<m;h++)r+=k[h],p(g,e,r,a,b,d);break;case "full":for(h=0;h<m;h++)for(var w=m;w>h;w--)r=k.substring(h,w),p(g,e,r,a,b,d);break;default:if(h=p(g,e,k,a,b,d),n&&1<f&&h>d)for(h=g[10],m=e._ctx[k]||(e._ctx[k]={}),k=h[k]||(h[k]=[{},{},{},{},{},{},{},{},{},{}]),h=q-n,w=q+n,0>h&&(h=0),w>f-1&&(w=f-1);h<=w;h++)h!== | ||
q&&p(k,m,c[h],a,b,d)}}this.a[a]="1";this.u=!1}return this};f.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]=[A.update,a,b],z(this),this;this.remove(a);b&&this.add(a,b)}return this};f.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]=[A.remove,a],z(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],f=this.g[b];if((f=f&&f[d])&&f.length)for(var g=0;g<f.length;g++)if(f[g]===a){f.splice(g,1);break}f.length||delete this.g[b][d]}delete this.a[a];this.u=!1}return this};f.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.v=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 f=this;E(function(){c(f.search(a,b));f=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return e;var g=a;if(!this.u)this.cache&&(this.f="",this.l.reset()),this.u=!0;else if(this.cache){var m=this.l.get(a);if(m)return m}else if(this.f&&0===a.indexOf(this.f))return e;g=this.encode(g);if(!g.length)return e; | ||
g=g.constructor===Array?g:g.split(G);m=g.length;var q=!0,k=[],h={};if(1<m)if(this.depth){var t=!0,r=g[0];h[r]="1"}else g.sort(y);var w;if(!t||(w=this.g[10])[r])for(var u=t?1:0;u<m;u++){var p=g[u];if(p&&!h[p]){for(var v,A=!1,x=[],B=0,z=9;z>=d;z--)if(v=t?w[r][z][p]:this.g[z][p])x[B++]=v,A=!0;if(A)k[k.length]=1<B?k.concat.apply([],x):x[0];else{q=!1;break}h[p]="1"}r=p}else q=!1;q&&(e=K(k,b));e.length?this.f="":this.f||(this.f=a);this.cache&&this.l.set(a,e);return e};f.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,e=0,d=0,f=0,g=0;10>g;g++)for(b=Object.keys(this.g[g]),a=0;a<b.length;a++)c=this.g[g][b[a]].length,e+=c+2*b[a].length+4,d+=c,f+=2*b[a].length;b=Object.keys(this.a);c=b.length;for(a=0;a<c;a++)e+=2*b[a].length+2;return{id:this.id,memory:e,items:c,sequences:d,chars:f,status:this.u,cache:this.c.length,matcher:v.length,worker:this.b}}};f.prototype.reset=function(){this.destroy();return this.init()};f.prototype.destroy=function(){this.cache&& | ||
this.l.reset();this.g=this.a=this.l=null;return this};var B={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("[-/]")," ",d("[^a-z0-9 ]"),""];return function(b){return u(b.toLowerCase(),a)}}(), | ||
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=u(b,a));c||1<b.length&&(b=x(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]+u(d.substring(1),a))}b=b.join("");b=x(b)}return b}}()},E=function(){var a={};return function(b,c,d){var e=a[d];e&&clearTimeout(e);return a[d]=setTimeout(b,c)}}(),M=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 f}(function(){var m={},C=!("undefined"===typeof Blob|| | ||
"undefined"===typeof URL||!URL.createObjectURL);return function(f,d,u,p,x){var y=f;f=C?URL.createObjectURL(new Blob(["("+u.toString()+")()"],{type:"text/javascript"})):"../"+y+".js";y+="-"+d;m[y]||(m[y]=[]);m[y][x]=new Worker(f);m[y][x].onmessage=p;return{postMessage:function(d,f){m[y][d].postMessage(f)}}}}()),this); |
{ | ||
"name": "flexsearch", | ||
"version": "0.2.11", | ||
"version": "0.2.122", | ||
"description": "World's fastest and most memory efficient full text search library.", | ||
@@ -19,2 +19,3 @@ "keywords": [], | ||
"build": "java -jar -Xms256m -Xmx4096m node_modules/google-closure-compiler/compiler.jar --compilation_level=ADVANCED_OPTIMIZATIONS --use_types_for_optimization=true --new_type_inf=true --jscomp_warning=newCheckTypes --generate_exports=true --export_local_property_definitions=true --language_in=ECMASCRIPT5_STRICT --language_out=ECMASCRIPT5_STRICT --process_closure_primitives=true --summary_detail_level=3 --warning_level=VERBOSE --emit_use_strict=true --output_manifest=log/manifest.log --output_module_dependencies=log/module_dependencies.log --property_renaming_report=log/renaming_report.log --js='flexsearch.js' --js_output_file='flexsearch.min.js' && echo Build Complete. && exit 0", | ||
"publish": "npm version patch && npm run build && npm publish", | ||
"test-production": "nyc --reporter=html --reporter=text mocha --timeout=3000 test --exit", | ||
@@ -21,0 +22,0 @@ "test-develop": "nyc --reporter=html --reporter=text mocha --timeout=3000 --exit", |
@@ -829,4 +829,55 @@ <p align="center"> | ||
</tr> | ||
<tr> | ||
<td align="left">Contextual Index</td> | ||
<td align="left">Multiplied with:</td> | ||
</tr> | ||
<tr> | ||
<td></td> | ||
<td>* 2(depth + 1)</td> | ||
</tr> | ||
</table> | ||
## Example Options | ||
Memory-optimized: | ||
```json | ||
{ | ||
encode: "extra", | ||
mode: "strict", | ||
threshold: 5 | ||
} | ||
``` | ||
Speed-optimized: | ||
```json | ||
{ | ||
encode: "icase", | ||
mode: "strict", | ||
threshold: 5, | ||
depth: 2 | ||
} | ||
``` | ||
Matching-tolerant: | ||
```json | ||
{ | ||
encode: "extra", | ||
mode: "full" | ||
} | ||
``` | ||
Balanced: | ||
```json | ||
{ | ||
encode: "simple", | ||
mode: "ngram", | ||
threshold: 3, | ||
depth: 3 | ||
} | ||
``` | ||
--- | ||
@@ -833,0 +884,0 @@ |
131430
2209
886