From e5f79b984c647c00b2196ed37482e589fed9c098 Mon Sep 17 00:00:00 2001
From: Thomas Wilkerling
-
+
-
+
=h)for(e=f._ctx[c]||(f._ctx[c]=q()),c=this.g[c]||(this.g[c]=I(10)),g=m-u,k=m+u+1,0>g&&(g=0),k>p&&(k=p);g =n)for(d=l._ctx[f]||(l._ctx[f]=r()),f=this.b[f]||(this.b[f]=C(10-(n||0))),m=e-t,g=e+t+1,0>m&&(m=0),g>p&&(g=
+p);m=n)for(f=p._ctx[c]||(p._ctx[c]=t()),c=this.f[c]||(this.f[c]=K(10-(n||0))),g=e-l,h=e+l+1,0>g&&(g=0),h>q&&(h=q);g
-
+
+
@@ -346,7 +346,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
"Library " +
"Benchmark (Single Phrase) " +
"Benchmark (Multi Phrase) " +
- "Benchmark (Mixed Not Found) " +
+ "Benchmark (Not Found) " +
"
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=g;G--)if(E=t[G][z])A[D++]=E,B=!0;if(B)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={},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 I(g){var h=0;return function(){return h =e&&(b=b[9-(d+.5>>0)],b=b[a]||(b[a]=[]),b[b.length]=f);return d}function l(b,c){if(b)for(var a=Object.keys(b),f=0,d=a.length;f b?1:b?-1:0}function V(b,c){b= +b.length-c.length;return 0>b?-1:b?1:0}function W(b,c,a){var f=[],d=b.length;if(1 c&&(f=f.slice(0,c)));return f}function G(b){return"string"===typeof b}function F(b){return"function"===typeof b}function x(b){return"undefined"===typeof b}function D(b){b.F||(b.F=M(function(){b.F=0;var c=b.async;c&&(b.async=!1);if(b.b.length){for(var a=Date.now(),f;(f=b.b.shift())||0===f;){var d=b.f[f];switch(d[0]){case E.add:b.add(d[1],d[2]);break;case E.remove:b.remove(d[1])}delete b.f[f];if(100 =d&&(f.s=f.i),f.C&& +f.s===f.i&&(f.cache&&f.j.set(c,f.g),f.C(f.g),f.g=[]),f})}else b.worker=!1,this.m=null;this.h=b.tokenize||a.h||this.h||u.h;this.async=x(c=b.async)?this.async||u.async:c;this.i=x(c=b.worker)?this.i||u.i:c;this.threshold=x(c=b.threshold)?a.threshold||this.threshold||u.threshold:c;this.depth=x(c=b.depth)?a.depth||this.depth||u.depth:c;this.w=x(c=b.suggest)?this.w||u.w:c;this.u=(c=x(c=b.encode)?a.encode:c)&&B[c]&&B[c].bind(B)||(F(c)?c:this.u||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter)this.filter= +C(P[c]||c,this.u);if(c=b.stemmer)this.stemmer=U(Q[c]||c,this.u);this.l=N(10-(this.threshold||0));this.c=v();this.a=v();this.f=v();this.b=[];this.F=0;this.v=!0;this.j=(this.cache=c=x(c=b.cache)?this.cache||u.cache:c)?new ba(c):!1;return this};e.prototype.encode=function(b){b&&H.length&&(b=m(b,H));b&&this.D.length&&(b=m(b,this.D));b&&this.u&&(b=this.u(b));b&&this.stemmer&&(b=m(b,this.stemmer));return b};e.prototype.addMatcher=function(b){var c=this.D,d;for(d in b)b.hasOwnProperty(d)&&c.push(a(d),b[d]); +return this};e.prototype.add=function(b,c,a){if(c&&G(c)&&(b||0===b)){var f="@"+b;if(this.a[f]&&!a)this.update(b,c);else{if(this.i)return++this.o>=this.m.length&&(this.o=0),this.m[this.o].postMessage(this.o,{add:!0,id:b,content:c}),this.a[f]=""+this.o,this;if(this.async)return this.f[f]||(this.b[this.b.length]=f),this.f[f]=[E.add,b,c],D(this),this;c=this.encode(c);if(!c.length)return this;a=this.h;c=F(a)?a(c):c.split(O);var e=v();e._ctx=v();for(var g=this.threshold,k=this.depth,w=this.l,m=c.length, +l=0;l n;z--)t=r.substring(n,z),d(w,e,t,b,y,q,g);break;default:if(p=d(w,e,r,b,1,q,g),k&&1 =g)for(p=e._ctx[r]||(e._ctx[r]=v()),r=this.c[r]||(this.c[r]=N(10-(g||0))),q=l-k,t=l+k+1,0>q&&(q=0),t>m&&(t=m);q e;c--)k=g[c-1],g[c]=k,d[k]=c;g[e]=a;d[a]=e}}}return b};return a}();return e}(function(){var g={},h="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,k,a,m,d){var l=e;e=h?URL.createObjectURL(new Blob(["("+a.toString()+")()"],{type:"text/javascript"})):l+".es5.js";l+="-"+k;g[l]||(g[l]=[]);g[l][d]=new Worker(e);g[l][d].onmessage=m;return{postMessage:function(a,d){g[l][a].postMessage(d)}}}}()),this); diff --git a/test/matching-presets.html b/test/matching-presets.html index 570ace2..724ce42 100644 --- a/test/matching-presets.html +++ b/test/matching-presets.html @@ -16,7 +16,7 @@ Presets Relevance Scoring Comparison
Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)
- +diff --git a/test/matching.html b/test/matching.html index 344c36c..d50dccd 100644 --- a/test/matching.html +++ b/test/matching.html @@ -201,7 +201,7 @@ Most relevant results was successfully found in the first place.
Note: Open console and type e.g. data[493] - + diff --git a/test/test.js b/test/test.js index 27deb9b..1047181 100644 --- a/test/test.js +++ b/test/test.js @@ -203,7 +203,7 @@ describe("Add (Sync)", function(){ flexsearch_sync.add(2, "bar"); flexsearch_sync.add(1, "foobar"); - expect(flexsearch_sync.index).to.have.keys([0, 1, 2]); + expect(flexsearch_sync.index).to.have.keys(["@0", "@1", "@2"]); expect(flexsearch_sync.length).to.equal(3); }); @@ -405,7 +405,7 @@ if(env !== "light"){ setTimeout(function(){ expect(flexsearch_async.length).to.equal(3); - expect(flexsearch_async.index).to.have.keys([0, 1, 2]); + expect(flexsearch_async.index).to.have.keys(["@0", "@1", "@2"]); done(); @@ -428,7 +428,7 @@ if(env !== "light"){ setTimeout(function(){ expect(flexsearch_async.length).to.equal(3); - expect(flexsearch_async.index).to.have.keys([0, 1, 2]); + expect(flexsearch_async.index).to.have.keys(["@0", "@1", "@2"]); done(); @@ -657,7 +657,7 @@ if(env !== "light"){ flexsearch_worker.add(1, "foobar"); expect(flexsearch_worker.length).to.equal(3); - expect(flexsearch_worker.index).to.have.keys([0, 1, 2]); + expect(flexsearch_worker.index).to.have.keys(["@0", "@1", "@2"]); flexsearch_worker.search("foo", function(result){ @@ -682,7 +682,7 @@ if(env !== "light"){ setTimeout(function(){ expect(flexsearch_worker.length).to.equal(3); - expect(flexsearch_worker.index).to.have.keys([0, 1, 2]); + expect(flexsearch_worker.index).to.have.keys(["@0", "@1", "@2"]); done();