From cdfe44c6fac863e496e671c9428d0bb37df02cec Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Mon, 28 Jan 2019 11:41:03 +0100 Subject: [PATCH] v0.3.21 FIX whitespace regex split --- flexsearch.compact.js | 10 +++++----- flexsearch.js | 13 +++++++------ flexsearch.light.js | 12 ++++++------ flexsearch.min.js | 8 ++++---- package.json | 2 +- test/flexsearch.es5.js | 8 ++++---- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/flexsearch.compact.js b/flexsearch.compact.js index 24f24e6..b909d11 100644 --- a/flexsearch.compact.js +++ b/flexsearch.compact.js @@ -1,5 +1,5 @@ /* - FlexSearch v0.3.2 + FlexSearch v0.3.21 Copyright 2019 Nextapps GmbH Author: Thomas Wilkerling Released under the Apache 2.0 Licence @@ -11,7 +11,7 @@ a[l];"a"===n||"e"===n||"i"===n||"o"===n||"u"===n||"y"===n?d++:f++;" "!==n&&(c+=n function O(a,b){a=a.length-b.length;return 0>a?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(100b;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} */ @@ -1359,9 +1360,9 @@ const global_encoder_balance = (function(){ - const regex_whitespace = regex("\\s\\s+"), + const regex_whitespace = regex("\\s+"), regex_strip = regex("[^a-z0-9 ]"), - regex_space = regex("[-\/]"), + regex_space = regex("[-/]"), regex_vowel = regex("[aeiouy]"); /** @const {Array} */ @@ -1406,9 +1407,9 @@ "simple": (function(){ - const regex_whitespace = regex("\\s\\s+"), + const regex_whitespace = regex("\\s+"), regex_strip = regex("[^a-z0-9 ]"), - regex_space = regex("[-\/]"), + regex_space = regex("[-/]"), regex_a = regex("[àáâãäå]"), regex_e = regex("[èéêë]"), regex_i = regex("[ìíîï]"), diff --git a/flexsearch.light.js b/flexsearch.light.js index fc83822..98615f1 100644 --- a/flexsearch.light.js +++ b/flexsearch.light.js @@ -1,5 +1,5 @@ /* - FlexSearch v0.3.2 + FlexSearch v0.3.21 Copyright 2019 Nextapps GmbH Author: Thomas Wilkerling Released under the Apache 2.0 Licence @@ -7,11 +7,11 @@ */ '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);hm;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 45f322c..92ae7a7 100644 --- a/flexsearch.min.js +++ b/flexsearch.min.js @@ -1,5 +1,5 @@ /* - FlexSearch v0.3.2 + FlexSearch v0.3.21 Copyright 2019 Nextapps GmbH Author: Thomas Wilkerling Released under the Apache 2.0 Licence @@ -13,7 +13,7 @@ u=0;for(;u=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, @@ -23,8 +23,8 @@ this.a[a];this.j[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this 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 083fc4c..5153c9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flexsearch", - "version": "0.3.2", + "version": "0.3.21", "description": "Next-Generation full text search library with zero dependencies.", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", diff --git a/test/flexsearch.es5.js b/test/flexsearch.es5.js index c272266..68522b8 100644 --- a/test/flexsearch.es5.js +++ b/test/flexsearch.es5.js @@ -1,5 +1,5 @@ /* - FlexSearch v0.3.2 + FlexSearch v0.3.21 Copyright 2019 Nextapps GmbH Author: Thomas Wilkerling Released under the Apache 2.0 Licence @@ -20,7 +20,7 @@ r.length;for(k=0;k=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]|| @@ -29,8 +29,8 @@ 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 (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=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);