diff --git a/README.md b/README.md index 293d77d..c3cba37 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,11 @@ Supported Platforms: - Browser - Node.js +Library Comparison: +- Benchmark "Gulliver's Travels" +- Relevance Scoring +- Memory Consumption + Get Latest (Stable Release): @@ -170,18 +175,16 @@ All Features: - +
File Size (gzip) 6.7 kb 4.5 kb2.1 kb4.1 kb
> It is also pretty simple to make Custom Builds -#### Benchmark Ranking +## Benchmark Ranking -- Library Comparison: Benchmark "Gulliver's Travels" -- Library Comparison: Relevance Scoring -- Library Comparison: Memory Consumption +Comparison: Benchmark "Gulliver's Travels" __Query Test: "Gulliver's Travels"__ @@ -197,9 +200,9 @@ __Query Test: "Gulliver's Travels"__ 1 FlexSearch - 0.3.1 - 2.1 kb - 327771 + 0.3.2 + 4.1 kb + 333738 @@ -296,10 +299,10 @@ __Memory Test: "Gulliver's Travels"__ 3 - JS Search - 1.4.2 - 36.9 Mb - 53.0 kb + Fuse + 3.3.0 + 0.22 Mb + 156.46 kb @@ -312,42 +315,42 @@ __Memory Test: "Gulliver's Travels"__ 5 - Lunr.js - 2.3.5 - 16.24 Mb - 84.73 kb - - - - 6 - Elasticlunr.js - 0.9.6 - 11.83 Mb - 68.69 kb - - - - 7 - BulkSearch - 0.1.3 - 1.53 Mb - 984.30 kb - - - - 8 bm25 0.2 6.95 Mb 137.88 kb + + 6 + BulkSearch + 0.1.3 + 1.53 Mb + 984.30 kb + + + + 7 + Elasticlunr.js + 0.9.6 + 11.83 Mb + 68.69 kb + + + + 8 + Lunr.js + 2.3.5 + 16.24 Mb + 84.73 kb + + 9 - Fuse - 3.3.0 - 0.22 Mb - 156.46 kb + JS Search + 1.4.2 + 36.9 Mb + 53.0 kb @@ -418,7 +421,7 @@ __Note:__ It is slightly faster to use no web worker when the index or query isn Weaks - + @@ -563,7 +566,7 @@ var index = new FlexSearch({ profile: "balance", encode: "icase", - mode: "ngram", + tokenize: "ngram", async: false, cache: false }); @@ -810,7 +813,7 @@ Define a private custom tokenizer during creation/initialization: ```js var index = new FlexSearch({ - mode: function(str){ + tokenize: function(str){ // split string into components, e.g.: @@ -930,7 +933,7 @@ Create index and just set the limit of relevance ("depth"): var index = new FlexSearch({ encode: "icase", - mode: "strict", + tokenize: "strict", depth: 3 }); ``` @@ -954,7 +957,7 @@ Create index and just set the count of parallel threads: var index = new FlexSearch({ encode: "icase", - mode: "full", + tokenize: "full", async: true, worker: 4 }); @@ -1001,7 +1004,7 @@ FlexSearch ist highly customizable. Make use of the the righ - mode





+ tokenize





"strict"
"foward"
@@ -1422,7 +1425,7 @@ Standard profile: __"default"__ ```js { encode: "icase", - mode: "forward" + tokenize: "forward" } ``` @@ -1430,7 +1433,7 @@ Memory-optimized profile: __"memory"__ ```js { encode: "extra", - mode: "strict", + tokenize: "strict", threshold: 7 } ``` @@ -1440,7 +1443,7 @@ Speed-optimized profile: __"speed"__ ```js { encode: "icase", - mode: "strict", + tokenize: "strict", threshold: 7, depth: 2 } @@ -1451,7 +1454,7 @@ Matching-tolerant profile: __"match"__ ```js { encode: "extra", - mode: "full" + tokenize: "full" } ``` @@ -1460,7 +1463,7 @@ Relevance-optimized profile: __"score"__ ```js { encode: "extra", - mode: "strict", + tokenize: "strict", threshold: 5, depth: 5 } @@ -1471,7 +1474,7 @@ Most-balanced profile: __"balanced"__ ```js { encode: "balanced", - mode: "ngram", + tokenize: "ngram", threshold: 6, depth: 3 } @@ -1487,9 +1490,11 @@ Absolute fastest profile: __"fastest"__ } ``` +
## Custom Builds diff --git a/compile.js b/compile.js index 1e97c44..ff640e9 100644 --- a/compile.js +++ b/compile.js @@ -71,7 +71,7 @@ var parameter = (function(opt){ generate_exports: true, export_local_property_definitions: true, language_in: "ECMASCRIPT6_STRICT", - language_out: language_out || "ECMASCRIPT5_STRICT", + language_out: language_out || "ECMASCRIPT6_STRICT", process_closure_primitives: true, summary_detail_level: 3, warning_level: "VERBOSE", @@ -118,12 +118,12 @@ else{ console.log("Build Complete: " + filename); - if(release === "demo"){ + if(release === "es5"){ //fs.existsSync("dist/") || fs.mkdirSync("dist/"); //fs.existsSync("dist/latest") || fs.mkdirSync("dist/latest"); - fs.copyFileSync(filename, "docs/" + filename); + fs.copyFileSync(filename, "test/" + filename); //fs.copyFileSync(filename, "dist/latest/" + filename); fs.unlinkSync(filename); } diff --git a/flexsearch.compact.js b/flexsearch.compact.js index 76cf347..24f24e6 100644 --- a/flexsearch.compact.js +++ b/flexsearch.compact.js @@ -1,31 +1,24 @@ /* - FlexSearch v0.3.1 + FlexSearch v0.3.2 Copyright 2019 Nextapps GmbH Author: Thomas Wilkerling Released under the Apache 2.0 Licence https://github.com/nextapps-de/flexsearch */ -'use strict';function J(d){var c=0;return function(){return c=l&&(b=b[d+.5>>0],b=b[a]||(b[a]=[]),b[b.length]=c);return d}function w(b,e){if(b)for(var a=Object.keys(b),c=0,d=a.length;c=(8=(8b? -1:b?-1:0}function z(b,e){b=b.length-e.length;return 0>b?-1:b?1:0}function V(b,e,a){var c=[],d=[],f=b.length;if(1e&&(c=c.slice(0,e)));return c}function F(b){return"string"===typeof b}function A(b){return"function"===typeof b}function v(b){return"undefined"===typeof b}function H(b){b.j||(b.j=N(function(){b.j=0;var a=b.async;a&&(b.async=!1);if(b.b.length){for(var c=Date.now(),d;(d=b.b.shift())||0===d;){var f=b.c[d];switch(f[0]){case G.add:b.add(f[1],f[2]);break;case G.remove:b.remove(f[1])}delete b.c[d];if(100r;u--)n=q.substring(r,u),g(l,e,n,b,v,m,d);break;default:if(k=g(l,e,q,b,1,m,d),f&&1=d)for(k=e._ctx[q]||(e._ctx[q]={}),q=this.f[q]||(this.f[q]=E(10)),m=h-f,n=h+f+1,0>m&&(m=0),n>t&&(n=t);mb;b++)w(this.h[b],a);this.depth&&w(this.f,a);delete this.a[a]}return this};d.prototype.search=function(a,c,d,f){var b=a,e=[];if("object"===typeof a){(d=a.callback||c)&&(b.callback=null);c=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);A(c)?(d=c,c=1E3):c||0===c||(c=1E3);if(d){var t=this;N(function(){d(t.search(b, -c,null,!0));t=null},1,"search-"+this.id)}else{if(!f&&this.async){var h=this;return new Promise(function(a){a(h.search(b,c,null,!0));h=null})}if(!a||!F(a))return e;b=a;b=this.encode(b);if(!b.length)return e;a=this.mode;a=A(a)?a(b):"ngram"===a?p(b):b.split(O);f=a.length;var q=!0,k=[],m={};if(1=g;z--)if(x=(n?v[r]:this.h)[z], -x=x[w])y[B++]=x,M=!0;if(M)k[k.length]=1=c&&(a=a[e+.5>>0],a=a[d]||(a[d]=[]),a[a.length]=f);return e}function A(a,b){if(a){const d=Object.keys(a);for(let f=0,e=d.length;f=(8=(8a?1:a?-1:0}function P(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function Q(a,b,d){let c=[],e=[];const l=a.length;if(1b&&(c=c.slice(0,b)));return c}function w(a){return"string"===typeof a}function x(a){return"function"===typeof a}function y(a){return"undefined"===typeof a}function C(a){a.l||(a.l=H(function(){a.l=0;{const b=a.async;let d;b&&(a.async=!1);if(a.c.length){const b=Date.now();let c;for(;(c=a.c.shift())||0===c;){d=a.f[c];switch(d[0]){case z.add:a.add(d[1],d[2]);break;case z.remove:a.remove(d[1])}delete a.f[c]; +if(100g;d--)k=c.substring(g,d),v(p,f,k,a,b,l,h)}break;default:if(e=v(p,f,c,a,1,l,h),r&&1=h)for(e=f._ctx[c]||(f._ctx[c]={}),c=this.g[c]||(this.g[c]=I(10)),l=m-r,k=m+r+1,0>l&&(l=0),k>q&&(k=q);lb;b++)A(this.i[b],a);this.depth&&A(this.g,a);delete this.b[a]}return this};g.prototype.search=function(a,b,c,f){let d=a,g,k=[];"object"===typeof a&&((c=a.callback||b)&&(d.callback=null),b=a.limit,g=a.threshold,a=a.query);g||(g=this.threshold||0);x(b)?(c=b,b=1E3):b||0=== +b||(b=1E3);if(c){{let a=this;H(function(){c(a.search(d,b,null,!0));a=null},1,"search-"+this.id)}}else{if(!f&&this.async&&"function"!==typeof importScripts){let a=this;return new Promise(function(c){c(a.search(d,b,null,!0));a=null})}if(!a||!w(a))return k;d=a;d=this.encode(d);if(!d.length)return k;a=this.a;a=x(a)?a(d):"ngram"===a?G(d):d.split(J);f=a.length;var h=!0,n=[],r={};if(1=g;e--){var m=(t?q[p]:this.i)[e];if(m=m[c])b[d++]=m,a=!0}if(a)n[n.length]=1=g&&(a=a[f+.5>>0],a=a[c]||(a[c]=[]),a[a.length]=e);return f}function y(a,b){if(a)for(var c=Object.keys(a),e=0,f=c.length;ea?1:a?-1:0}function I(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function x(a){return"function"===typeof a}function z(a){return"undefined"=== -typeof a}function B(a){for(var b=Array(a),c=0;cp;q--)n=l.substring(p,q),r(g,e,n,a,t,m,f);break;default:if(d=r(g,e,l,a,1,m,f),u&&1=f)for(d=e._ctx[l]||(e._ctx[l]={}),l=this.b[l]||(this.b[l]=B(10)),m=k-u,n=k+u+1,0>m&&(m=0),n>h&&(n=h);mb;b++)y(this.f[b],a);this.depth&&y(this.b,a);delete this.a[a]}return this};d.prototype.search=function(a,b,c){var e=a,f=[];if("object"===typeof a){b=a.limit;var d=a.threshold;a=a.query}d||(d=this.threshold||0);x(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(c)c(this.search(e,b,null,!0));else{if(!a||"string"!==typeof a)return f;e=this.encode(a);if(!e.length)return f;a=this.mode;a=x(a)?a(e):e.split(C);c=a.length;var g= -!0;e=[];var h={};if(1=d;v--)if(p=(k?q[l]:this.f)[v],p=p[n])t[w++]=p,r=!0;if(r)e[e.length]=1b&&(d=d.slice(0,b)));f=d}return f}};d.prototype.clear=function(){this.destroy();return this.init()};d.prototype.destroy=function(){this.filter=this.stemmer=this.f=this.b=this.a=null;return this};var w={icase:function(a){return a.toLowerCase()}};return d}(!1),this); +'use strict';(function(f,t,u){let k;(k=u.define)&&k.amd?k([],function(){return t}):(k=u.modules)?k[f.toLowerCase()]=t:"object"===typeof exports?module.exports=t:u[f]=t})("FlexSearch",function(){function f(a){a||(a=w);this.id=a.id||G++;this.init(a);t(this,"index",function(){return this.a});t(this,"length",function(){return Object.keys(this.a).length})}function t(a,b,c){Object.defineProperty(a,b,{get:c})}function u(a,b){for(let c=0;c=g&&(a=a[d+.5>>0],a=a[c]||(a[c]=[]),a[a.length]=e);return d}function y(a,b){if(a){const c=Object.keys(a);for(let e=0,d=c.length;ea?1:a?-1:0}function I(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function x(a){return"function"===typeof a} +function z(a){return"undefined"===typeof a}function B(a){const b=Array(a);for(let c=0;cm;c--)g=e.substring(m,c),k(q,f,g,a,b,h,l)}break;default:if(d=k(q,f,e,a,1,h,l),r&&1=l)for(d=f._ctx[e]||(f._ctx[e]={}),e=this.c[e]||(this.c[e]=B(10)),h=p-r,g=p+r+1,0>h&&(h=0),g>n&&(g=n);hb;b++)y(this.g[b],a);this.depth&&y(this.c,a);delete this.a[a]}return this};f.prototype.search=function(a,b,c){var e=a,d=[];if("object"===typeof a){b=a.limit;var h=a.threshold;a=a.query}h||(h=this.threshold||0);x(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(c)c(this.search(e,b,null,!0));else{if(!a||"string"!==typeof a)return d;e=this.encode(a);if(!e.length)return d; +a=this.b;a=x(a)?a(e):e.split(C);c=a.length;var g=!0;e=[];var f={};if(1=h;d--){var p=(k?r[l]:this.g)[d];if(p=p[n])b[c++]=p,a=!0}if(a)e[e.length]=1b&&(h=h.slice(0,b)));d=h}return d}};f.prototype.clear=function(){this.destroy();return this.init()};f.prototype.destroy=function(){this.filter=this.stemmer=this.g=this.c=this.a=null;return this};const v={icase:function(a){return a.toLowerCase()}};return f}(!1),this); diff --git a/flexsearch.min.js b/flexsearch.min.js index a318406..45f322c 100644 --- a/flexsearch.min.js +++ b/flexsearch.min.js @@ -1,36 +1,30 @@ /* - FlexSearch v0.3.1 + FlexSearch v0.3.2 Copyright 2019 Nextapps GmbH Author: Thomas Wilkerling Released under the Apache 2.0 Licence https://github.com/nextapps-de/flexsearch */ -'use strict';function J(g){var h=0;return function(){return h=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=(8=(8b?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(1c&&(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.D||(b.D= -M(function(){b.D=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=d&&(f.m=f.h),f.B&&f.m===f.h&&(f.cache&&f.g.set(c,f.f),f.B(f.f),f.f=[]),f})}else b.worker=!1,this.i=null;this.mode=b.mode||a.mode||this.mode||w.mode;this.async=x(c=b.async)?this.async||w.async:c;this.h=x(c=b.worker)?this.h||w.h: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.v=x(c=b.suggest)?this.v||w.v:c;this.o=(c=x(c=b.encode)?a.encode:c)&&y[c]&&y[c].bind(y)||(H(c)?c:this.o||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter)this.filter=V(P[c]||c,this.o);if(c=b.stemmer)this.stemmer=Z(Q[c]||c,this.o);this.u=N(10);this.j={};this.a={};this.c={};this.b=[];this.D=0;this.s=!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.C.length&&(b=l(b,this.C));b&&this.o&&(b=this.o(b));b&&this.stemmer&&(b=l(b,this.stemmer));return b};e.prototype.addMatcher=function(b){var c=this.C,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.h)return++this.l>=this.i.length&&(this.l=0),this.i[this.l].postMessage(this.l,{add:!0,id:b,content:c}),this.a[b]=""+ -this.l,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.mode;c=H(a)?a(c):"ngram"===a?D(c):c.split(O);for(var f={_ctx:{}},e=this.threshold,g=this.depth,k=this.u,r=c.length,t=0;tu;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=e)for(n=f._ctx[l]||(f._ctx[l]={}),l=this.j[l]||(this.j[l]=N(10)),p=t-g,q=t+g+1,0>p&&(p=0),q>r&&(q=r);pc;c++)m(this.u[c],b);this.depth&&m(this.j,b);delete this.a[b];this.s=!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.h)for(this.B=a,this.m=0,this.f=[],e=0;e=g;I--)if(G=(m?w[v]:this.u)[I],G=G[y])B[F++]=G,C=!0;if(C)p[p.length]=1e;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+".min.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(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=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=(8=(8a?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(1b&&(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=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;ml;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=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);eb;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=e;f--){var t=(n?m[p]:this.w)[f];if(t=t[b])c[d++]=t,a=!0}if(a)q[q.length]=1d;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); diff --git a/package.json b/package.json index 694586e..083fc4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flexsearch", - "version": "0.3.1", + "version": "0.3.2", "description": "Next-Generation full text search library with zero dependencies.", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", @@ -28,8 +28,9 @@ "build-light": "node compile RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false", "build-compact": "node compile RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=false SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false", "build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false", + "build-es5": "node compile RELEASE=es5 DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT", "build-lang": "node compile RELEASE=lang", - "build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-lang", + "build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-lang", "test-production": "nyc --reporter=html --reporter=text mocha --timeout=3000 test --exit", "test-light": "nyc --reporter=html --reporter=text mocha --timeout=3000 test/ --exit", "test-develop": "nyc --reporter=html --reporter=text mocha --timeout=3000 --exit", diff --git a/test/benchmark.html b/test/benchmark.html index 2fe8b50..eb18067 100644 --- a/test/benchmark.html +++ b/test/benchmark.html @@ -360,7 +360,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least html += "" + "" + test + "" + - "wait ..." + + "indexing ..." + "" } } @@ -443,7 +443,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least console.log(key + ":", duration); - document.getElementById("test-" + key).textContent = /*format_number*/((1000 / duration * loops + 0.5) >> 0) + " op/s"; + document.getElementById("test-" + key).textContent = /*format_number*/(((1000 / duration * loops * 10 + 0.5) >> 0) / 10) + " op/s"; if(++index < keys.length){ diff --git a/test/flexsearch.es5.js b/test/flexsearch.es5.js new file mode 100644 index 0000000..c272266 --- /dev/null +++ b/test/flexsearch.es5.js @@ -0,0 +1,36 @@ +/* + FlexSearch v0.3.2 + Copyright 2019 Nextapps GmbH + Author: Thomas Wilkerling + Released under the Apache 2.0 Licence + https://github.com/nextapps-de/flexsearch +*/ +'use strict';function J(g){var h=0;return function(){return h=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=(8=(8b?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(1c&&(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=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;tu;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=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);pc;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=g;I--)if(G=(m?w[v]:this.v)[I],G=G[y])B[F++]=G,C=!0;if(C)p[p.length]=1 +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); diff --git a/test/index.html b/test/index.html index 1f893aa..4b5288b 100644 --- a/test/index.html +++ b/test/index.html @@ -12,7 +12,7 @@ - +