Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flexsearch

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flexsearch - npm Package Compare versions

Comparing version 0.1.21 to 0.1.22

252

flexsearch.js

@@ -283,3 +283,3 @@ /**!

(new cache(30 * 1000, 50, true))
:
:
false;

@@ -387,3 +387,3 @@ };

var tmp = "", arr;
var tmp = "";

@@ -394,22 +394,3 @@ for(var a = value.length - 1; a >= 1; a--){

if(!dupes[tmp]){
dupes[tmp] = "1";
(arr = this._map[tmp[0]]) || (
this._map[tmp[0]] = arr = {}
);
if(!arr[tmp]){
arr[tmp] = arr = [];
}
else{
arr = arr[tmp];
}
arr[arr.length] = id;
}
addIndex(this._map, dupes, tmp);
}

@@ -421,3 +402,3 @@

var tmp = "", arr;
var tmp = "";

@@ -428,22 +409,3 @@ for(var a = 0; a < value.length; a++){

if(!dupes[tmp]){
dupes[tmp] = "1";
(arr = this._map[tmp[0]]) || (
this._map[tmp[0]] = arr = {}
);
if(!arr[tmp]){
arr[tmp] = arr = [];
}
else{
arr = arr[tmp];
}
arr[arr.length] = id;
}
addIndex(this._map, dupes, tmp);
}

@@ -455,3 +417,3 @@

var tmp = "", arr;
var tmp = "";

@@ -464,22 +426,3 @@ for(var x = 0; x < value.length; x++){

if(!dupes[tmp]){
dupes[tmp] = "1";
(arr = this._map[tmp[0]]) || (
this._map[tmp[0]] = arr = {}
);
if(!arr[tmp]){
arr[tmp] = arr = [];
}
else{
arr = arr[tmp];
}
arr[arr.length] = id;
}
addIndex(this._map, dupes, tmp);
}

@@ -493,25 +436,4 @@ }

if(!dupes[value]){
addIndex(this._map, dupes, value);
var arr;
dupes[value] = "1";
(arr = this._map[value[0]]) || (
this._map[value[0]] = arr = {}
);
if(!arr[value]){
arr[value] = arr = [];
}
else{
arr = arr[value];
}
arr[arr.length] = id;
}
break;

@@ -1007,2 +929,17 @@ }

var regex_pairs = [
regex_a, 'a',
regex_e, 'e',
regex_i, 'i',
regex_o, 'o',
regex_u, 'u',
regex_y, 'y',
regex_n, 'n',
regex_c, 'c',
regex_s, 's',
regex_split, ' ',
regex_strip, ''
];
return function(str){

@@ -1012,14 +949,3 @@

str.toLowerCase()
.replace(regex_a, 'a')
.replace(regex_e, 'e')
.replace(regex_i, 'i')
.replace(regex_o, 'o')
.replace(regex_u, 'u')
.replace(regex_y, 'y')
.replace(regex_n, 'n')
.replace(regex_c, 'c')
.replace(regex_s, 's')
.replace(regex_split, ' ')
.replace(regex_strip, '')
replace(str.toLowerCase(), regex_pairs)
);

@@ -1052,2 +978,23 @@ };

var regex_pairs = [
regex_ae, 'a',
regex_ai, 'ei',
regex_ay, 'ei',
regex_ey, 'ei',
regex_oe, 'o',
regex_ue, 'u',
regex_ie, 'i',
regex_sz, 's',
regex_zs, 's',
regex_sh, 's',
regex_ck, 'k',
regex_cc, 'k',
//regex_th, 't',
regex_dt, 't',
regex_ph, 'f',
regex_ou, 'o',
regex_uo, 'u'
];
return function(string, _skip_post_processing){

@@ -1066,19 +1013,3 @@

string = string.replace(regex_ae, 'a')
.replace(regex_ai, 'ei')
.replace(regex_ay, 'ei')
.replace(regex_ey, 'ei')
.replace(regex_oe, 'o')
.replace(regex_ue, 'u')
.replace(regex_ie, 'i')
.replace(regex_sz, 's')
.replace(regex_zs, 's')
.replace(regex_sh, 's')
.replace(regex_ck, 'k')
.replace(regex_cc, 'k')
//.replace(regex_th, 't')
.replace(regex_dt, 't')
.replace(regex_ph, 'f')
.replace(regex_ou, 'o')
.replace(regex_uo, 'u');
string = replace(string, regex_pairs)
}

@@ -1115,2 +1046,14 @@

var regex_pairs = [
soundex_b, 'b',
soundex_c, 'c',
soundex_k, 'k',
soundex_i, 'i',
soundex_m, 'm',
soundex_t, 't',
soundex_f, 'f',
regex_vowel, ''
];
return function(str){

@@ -1137,11 +1080,3 @@

// remove all vowels after 2nd char
str[i] = current[0] + current.substring(1)
.replace(soundex_b, 'b')
.replace(soundex_c, 'c')
.replace(soundex_k, 'k')
.replace(soundex_i, 'i')
.replace(soundex_m, 'm')
.replace(soundex_t, 't')
.replace(soundex_f, 'f')
.replace(regex_vowel, '');
str[i] = current[0] + replace(current.substring(1), regex_pairs)
}

@@ -1223,2 +1158,7 @@ }

/**
* @param {!string} str
* @returns {RegExp}
*/
function regex(str){

@@ -1230,2 +1170,50 @@

/**
* @param {!string} str
* @param {RegExp|Array<RegExp, string>} regex
* @param {string=} replacement
* @returns {*}
*/
function replace(str, regex, replacement){
if(typeof replacement === 'undefined'){
for(var i = 0; i < regex.length; i += 2){
str = str.replace(regex[i], regex[i + 1]);
}
return str;
}
else{
return str.replace(/** @type {!RegExp} */ (regex), replacement);
}
}
function addIndex(map, dupes, tmp){
if(!dupes[tmp]){
dupes[tmp] = "1";
var arr = map[tmp[0]] || (
map[tmp[0]] = {}
);
if(!arr[tmp]){
arr[tmp] = arr = [];
}
else{
arr = arr[tmp];
}
arr[arr.length] = id;
}
}
/**
* @param {!string} string

@@ -1335,9 +1323,9 @@ * @returns {string}

-1
:(
diff > 0 ?
:(
diff > 0 ?
1
:
0
)
1
:
0
)
);

@@ -1600,3 +1588,3 @@ }

if(flexsearch.debug){
if(options['debug']){

@@ -1735,3 +1723,3 @@ console.log(data);

// CommonJS (Node.js)
else if(typeof window === 'undefined'){
else if(typeof module !== 'undefined'){

@@ -1738,0 +1726,0 @@ module.exports = factory;

@@ -9,19 +9,18 @@ /**!

*/
(function(n,v,g){g||(g=this);var b=g.define,p=g.module;p&&p.exports?p.exports=v:b&&b.amd?b([],function(){return v}):(p=g.modules)?p[n.toLowerCase()]=v:"undefined"===typeof window?module.G=v:g[n]=v})("FlexSearch",function D(n){function g(a){a||(a=l);this.id=a.id||E++;this.C(a)}function b(a){return new RegExp(a,"g")}function p(a){for(var c="",k="",f="",h=0;h<a.length;h++){var q=a[h];q!==k&&(0<h&&"h"===q?(f="a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f,"a"!==k&&"e"!==k&&"i"!==k&&"o"!==k&&"u"!==
k&&"y"!==k||!f||(c+=q)):c+=q);f=h===a.length-1?"":a[h+1];k=q}return c}function w(a,c){var k=a.length-c.length;return 0>k?1:0<k?-1:0}function A(a,c){var k=a.length-c.length;return 0>k?-1:0<k?1:0}function F(a,c,k){var f=a.length,h=c.length,q=[];if(f&&h)for(var e=0,d=0;d<f;d++)for(var b=a[d],g=0;g<h;g++)if(c[g]===b){q[e++]=b;if(k&&e===k)return q;break}return q}function x(a){a.w||(a.w=B(function(){a.w=null;var c=a.async;c&&(a.async=!1);if(a.c.length){for(var k=C(),f;(f=a.c.shift())||0===f;){var h=a.g[f];
switch(h[0]){case t.add:a.add(h[1],h[2]);break;case t.update:a.update(h[1],h[2]);break;case t.remove:a.remove(h[1])}a.g[f]=null;delete a.g[f];if(100<C()-k)break}a.c.length&&x(a)}c&&(a.async=c)},1,"search-async-"+a.id))}function C(){return"undefined"!==typeof performance?performance.now():(new Date).getTime()}function G(a,c,k,f){a=n("flexsearch-"+a,function(){var a,c;self.onmessage=function(d){if(d=d.data)c.debug&&console.log("Worker Job Started: "+d.id),d.search?self.postMessage({result:c.search(d.content,
d.limit),id:a,content:d.content,limit:d.limit}):d.add?c.add(d.id,d.content):d.update?c.update(d.id,d.content):d.remove?c.remove(d.id):d.reset?c.reset():d.info?(d=c.info(),d.worker=a,c.debug&&console.log(d)):d.register&&(a=d.id,c=Function(d.register.substring(d.register.indexOf("{")+1,d.register.lastIndexOf("}")))(),d.options.cache=!1,d.options.async=!0,d.options.worker=!1,c=new c(d.options))}},function(a){(a=a.data)&&a.result?f(a.id,a.content,a.result,a.limit):flexsearch.debug&&console.log(a)},c);
var h=D.toString();k.id=c;a.postMessage(c,{register:h,options:k,id:c});return a}var l={type:"integer",mode:"forward",A:!1,cache:!1,async:!1,j:!1,encode:!1,i:4,debug:!0},u=[],E=0,t={add:0,update:1,remove:2};g.create=function(a){return new this(a)};g.F=function(a){for(var c in a)a.hasOwnProperty(c)&&(u[u.length]=[b(c),a[c]])};g.prototype.C=function(a){if(a){if(a.worker)if("undefined"===typeof Worker)a.worker=!1;else{var c=this,k=a.threads||l.threads;c.o=-1;c.u=0;c.h=[];c.v=null;c.l=Array(k);for(var f=
0;f<k;f++)c.l[f]=G(c.id,f,a||l,function(a,k,e,d){c.u!==c.i&&(c.h=c.h.concat(e),c.u++,d&&c.h.length>=d&&(c.u=c.i),c.v&&c.u===c.i&&(c.h.length?c.f="":c.f||(c.f=k),c.cache&&c.m.set(k,c.h),c.v(c.h),c.h=[]))})}this.mode=a.mode||this.mode||l.mode;this.A="or"===a["boolean"]||this.A||l.A;this.cache=a.cache||this.cache||l.cache;this.async=a.async||this.async||l.async;this.j=a.worker||this.j||l.j;this.i=a.threads||this.i||l.i;this.B=a.encode&&z[a.encode]||this.B||l.encode&&z[l.encode]||a.encode;this.debug=
a.debug||this.debug||l.debug}this.a={};this.b={};this.g={};this.c=[];this.w=null;this.f="";this.s=!0;this.m=this.cache?new H(3E4,50,!0):!1};g.prototype.encode=function(a){this.B&&(a=this.B(a));if(u.length)for(var c=0;c<u.length;c++){var k=u[c];a=a.replace(k[0],k[1])}return a};g.prototype.add=function(a,c){if("string"===typeof c&&c&&(a||0===a))if(this.b[a])this.update(a,c);else if(this.j)++this.o>=this.l.length&&(this.o=0),this.l[this.o].postMessage(this.o,{add:!0,id:a,content:c}),this.b[a]=""+this.o;
else if(this.async)this.g[a]||(this.c[this.c.length]=a),this.g[a]=[t.add,a,c],x(this);else{for(var k={},f=c.split(" "),h=0;h<f.length;h++){var b=f[h];if(b&&(this.encode&&(b=this.encode(b)),b))switch(this.mode){case "inverse":case "both":for(var e="",d,m=b.length-1;1<=m;m--)e=b[m]+e,k[e]||(k[e]="1",(d=this.a[e[0]])||(this.a[e[0]]=d={}),d[e]?d=d[e]:d[e]=d=[],d[d.length]=a);case "forward":e="";for(m=0;m<b.length;m++)e+=b[m],k[e]||(k[e]="1",(d=this.a[e[0]])||(this.a[e[0]]=d={}),d[e]?d=d[e]:d[e]=d=[],
d[d.length]=a);break;case "full":for(m=0;m<b.length;m++)for(var g=b.length;g>m;g--)e=b.substring(m,g),k[e]||(k[e]="1",(d=this.a[e[0]])||(this.a[e[0]]=d={}),d[e]?d=d[e]:d[e]=d=[],d[d.length]=a);break;default:k[b]||(k[b]="1",(d=this.a[b[0]])||(this.a[b[0]]=d={}),d[b]?d=d[b]:d[b]=d=[],d[d.length]=a)}}this.b[a]="1";this.s=!1}};g.prototype.update=function(a,c){if("string"===typeof c&&(a||0===a)&&this.b[a])if(this.j){var b=parseInt(this.b[a],10);this.l[b].postMessage(b,{update:!0,id:a,content:c})}else this.async?
(this.g[a]||(this.c[this.c.length]=a),this.g[a]=[t.update,a,c],x(this)):(this.remove(a),c&&this.add(a,c))};g.prototype.remove=function(a){if(this.b[a])if(this.j){var c=parseInt(this.b[a],10);this.l[c].postMessage(c,{remove:!0,id:a});delete this.b[a]}else if(this.async)this.g[a]||(this.c[this.c.length]=a),this.g[a]=[t.remove,a],x(this);else{c=Object.keys(this.a);for(var b=0;b<c.length;b++)for(var f=Object.keys(this.a[c[b]]),h=0;h<f.length;h++){var g=f[h],e=this.a[c[b]];if((e=e&&e[g])&&e.length)for(var d=
0;d<e.length;d++)if(e[d]===a){e.splice(d,1);break}e.length||delete this.a[c[b]][g]}delete this.b[a];this.s=!1}};var I=b("[ -/]");g.prototype.search=function(a,c,b){if("string"===typeof a&&a)"function"===typeof c?(b=c,c=1E3):c||(c=1E3);else return[];var f=a;if(!this.s)this.cache&&(this.f="",this.m.reset()),this.s=!0;else if(this.cache){var h=this.m.get(a);if(h)return h}else if(this.f&&-1!==a.indexOf(this.f))return[];if(this.j){this.v=b;this.u=0;this.h=[];for(f=0;f<this.i;f++)this.l[f].postMessage(f,
{search:!0,limit:c,content:a});return null}if(b){var k=this;B(function(){b(k.search(a,c));k=null},1,"search-"+this.id);return null}for(h=0;" "===a[h];)h++;h&&(f=a.substring(h));if(!f)return[];var e=f.split(I);1<e.length&&e.sort(w);h=[];var d=!0;f=[];for(var g={},y=0;y<e.length;y++){var r=e[y];if(!g[r]&&(r&&this.encode&&(r=this.encode(r)),r)){var l=this.a[r[0]];if((l=l&&l[r])&&l.length)f[f.length]=l;else{d=!1;break}g[e[y]]="1"}}if(d&&(1<f.length&&f.sort(A),e=0,d=f[e++])){for(h=f.length;d.length&&e<
h;)g=f[e++],d=F(d,g,e===h?c:0);c&&d.length>c&&(d=d.slice(0,c));h=d}h.length?this.f="":this.f||(this.f=a);this.cache&&this.m.set(a,h);return h};g.prototype.info=function(){if(this.j)for(var a=0;a<this.i;a++)this.l[a].postMessage(a,{info:!0,id:this.id});else{var c=0,b=0,f=0;var h=Object.keys(this.a);for(a=0;a<h.length;a++){var g=""+h[a];var e=this.a[g].length;c+=1*e+2*g.length;b+=e;f+=e*g.length}h=Object.keys(this.b);e=h.length;for(a=0;a<e;a++)c+=2*h[a].length+2;return{id:this.id,memory:c,items:e,sequences:b,
chars:f,status:this.s,cache:this.c.length,matchers:u.length}}};g.prototype.reset=function(){this.D();this.C()};g.prototype.D=function(){this.cache&&this.m.reset();this.m=this.b=this.a=null};var z={icase:function(a){return a.toLowerCase()},simple:function(){var a=b("[^a-z0-9 ]"),c=b("[-/]"),k=b("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),f=b("[\u00e8\u00e9\u00ea\u00eb]"),h=b("[\u00ec\u00ed\u00ee\u00ef]"),g=b("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),e=b("[\u00f9\u00fa\u00fb\u00fc\u0171]"),d=b("[\u00fd\u0177\u00ff]"),
m=b("\u00f1"),l=b("\u00e7"),r=b("\u00df");return function(b){return b.toLowerCase().replace(k,"a").replace(f,"e").replace(h,"i").replace(g,"o").replace(e,"u").replace(d,"y").replace(m,"n").replace(l,"c").replace(r,"s").replace(c," ").replace(a,"")}}(),advanced:function(){var a=b(" "),c=b("ae"),k=b("ai"),f=b("ay"),h=b("ey"),g=b("oe"),e=b("ue"),d=b("ie"),m=b("sz"),l=b("zs"),r=b("ck"),n=b("cc"),t=b("sh"),u=b("dt"),w=b("ph"),x=b("ou"),A=b("uo");return function(b,q){if(!b)return b;b=z.simple(b);2<b.length&&
(b=b.replace(c,"a").replace(k,"ei").replace(f,"ei").replace(h,"ei").replace(g,"o").replace(e,"u").replace(d,"i").replace(m,"s").replace(l,"s").replace(t,"s").replace(r,"k").replace(n,"k").replace(u,"t").replace(w,"f").replace(x,"o").replace(A,"u"));q||(b=b.replace(a,""),1<b.length&&(b=p(b)));return b}}(),extra:function(){var a=b("p"),c=b("[sz]"),k=b("[gq]"),f=b("[jy]"),h=b("n"),g=b("d"),e=b("[vw]"),d=b("[aeiouy]");return function(b){if(!b)return b;b=z.advanced(b,!0);if(1<b.length){b=b.split(" ");
for(var l=0;l<b.length;l++){var m=b[l];1<m.length&&(b[l]=m[0]+m.substring(1).replace(a,"b").replace(c,"c").replace(k,"k").replace(f,"i").replace(h,"m").replace(g,"t").replace(e,"f").replace(d,""))}b=b.join("");b=p(b)}return b}}()},B=function(){var a={};return function(b,g,f){var c=a[f];c&&clearTimeout(c);return a[f]=setTimeout(b,g)}}(),H=function(){function a(){this.cache={}}a.prototype.reset=function(){this.cache={}};a.prototype.set=function(a,b){this.cache[a]=b};a.prototype.get=function(a){return this.cache[a]};
return a}();return g}(function(){var n={},v=!("undefined"===typeof Blob||!URL||!URL.createObjectURL);return function(g,b,p,w){b=v?URL.createObjectURL(new Blob(["("+b.toString()+")()"],{type:"text/javascript"})):"js/worker/"+g+".js";n[g]||(n[g]=[]);n[g][w]=new Worker(b);n[g][w].onmessage=p;console.log("Register Worker@"+g);return{postMessage:function(b,p){n[g][b].postMessage(p)}}}}()));
(function(l,r,f){f||(f=this);var d=f.define,m=f.module;m&&m.exports?m.exports=r:d&&d.amd?d([],function(){return r}):(m=f.modules)?m[l.toLowerCase()]=r:"undefined"!==typeof module?module.G=r:f[l]=r})("FlexSearch",function A(l){function f(a){a||(a=p);this.id=a.id||B++;this.C(a)}function d(a){return new RegExp(a,"g")}function m(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){b[c]||(b[c]="1",a=a[c[0]]||(a[c[0]]={}),a[c]?
a=a[c]:a[c]=a=[],a[a.length]=id)}function x(a){for(var b="",c="",e="",n=0;n<a.length;n++){var k=a[n];k!==c&&(0<n&&"h"===k?(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+=k)):b+=k);e=n===a.length-1?"":a[n+1];c=k}return b}function C(a,b){var c=a.length-b.length;return 0>c?1:0<c?-1:0}function D(a,b){var c=a.length-b.length;return 0>c?-1:0<c?1:0}function E(a,b,c){var e=a.length,n=b.length,k=[];if(e&&n)for(var g=0,h=0;h<e;h++)for(var d=
a[h],f=0;f<n;f++)if(b[f]===d){k[g++]=d;if(c&&g===c)return k;break}return k}function v(a){a.w||(a.w=y(function(){a.w=null;var b=a.async;b&&(a.async=!1);if(a.c.length){for(var c=z(),e;(e=a.c.shift())||0===e;){var n=a.g[e];switch(n[0]){case t.add:a.add(n[1],n[2]);break;case t.update:a.update(n[1],n[2]);break;case t.remove:a.remove(n[1])}a.g[e]=null;delete a.g[e];if(100<z()-c)break}a.c.length&&v(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function z(){return"undefined"!==typeof performance?performance.now():
(new Date).getTime()}function F(a,b,c,e){a=l("flexsearch-"+a,function(){var a,b;self.onmessage=function(c){if(c=c.data)b.debug&&console.log("Worker Job Started: "+c.id),c.search?self.postMessage({result:b.search(c.content,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.debug&&console.log(c)):c.register&&(a=c.id,b=Function(c.register.substring(c.register.indexOf("{")+
1,c.register.lastIndexOf("}")))(),c.options.cache=!1,c.options.async=!0,c.options.worker=!1,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 n=A.toString();c.id=b;a.postMessage(b,{register:n,options:c,id:b});return a}var p={type:"integer",mode:"forward",A:!1,cache:!1,async:!1,j:!1,encode:!1,i:4,debug:!0},u=[],B=0,t={add:0,update:1,remove:2};f.create=function(a){return new this(a)};f.F=function(a){for(var b in a)a.hasOwnProperty(b)&&
(u[u.length]=[d(b),a[b]])};f.prototype.C=function(a){if(a){if(a.worker)if("undefined"===typeof Worker)a.worker=!1;else{var b=this,c=a.threads||p.threads;b.o=-1;b.u=0;b.h=[];b.v=null;b.l=Array(c);for(var e=0;e<c;e++)b.l[e]=F(b.id,e,a||p,function(a,c,e,d){b.u!==b.i&&(b.h=b.h.concat(e),b.u++,d&&b.h.length>=d&&(b.u=b.i),b.v&&b.u===b.i&&(b.h.length?b.f="":b.f||(b.f=c),b.cache&&b.m.set(c,b.h),b.v(b.h),b.h=[]))})}this.mode=a.mode||this.mode||p.mode;this.A="or"===a["boolean"]||this.A||p.A;this.cache=a.cache||
this.cache||p.cache;this.async=a.async||this.async||p.async;this.j=a.worker||this.j||p.j;this.i=a.threads||this.i||p.i;this.B=a.encode&&w[a.encode]||this.B||p.encode&&w[p.encode]||a.encode;this.debug=a.debug||this.debug||p.debug}this.a={};this.b={};this.g={};this.c=[];this.w=null;this.f="";this.s=!0;this.m=this.cache?new G(3E4,50,!0):!1};f.prototype.encode=function(a){this.B&&(a=this.B(a));if(u.length)for(var b=0;b<u.length;b++){var c=u[b];a=a.replace(c[0],c[1])}return a};f.prototype.add=function(a,
b){if("string"===typeof b&&b&&(a||0===a))if(this.b[a])this.update(a,b);else if(this.j)++this.o>=this.l.length&&(this.o=0),this.l[this.o].postMessage(this.o,{add:!0,id:a,content:b}),this.b[a]=""+this.o;else if(this.async)this.g[a]||(this.c[this.c.length]=a),this.g[a]=[t.add,a,b],v(this);else{for(var c={},e=b.split(" "),d=0;d<e.length;d++){var k=e[d];if(k&&(this.encode&&(k=this.encode(k)),k))switch(this.mode){case "inverse":case "both":for(var g="",h=k.length-1;1<=h;h--)g=k[h]+g,q(this.a,c,g);case "forward":g=
"";for(h=0;h<k.length;h++)g+=k[h],q(this.a,c,g);break;case "full":for(h=0;h<k.length;h++)for(var f=k.length;f>h;f--)g=k.substring(h,f),q(this.a,c,g);break;default:q(this.a,c,k)}}this.b[a]="1";this.s=!1}};f.prototype.update=function(a,b){if("string"===typeof b&&(a||0===a)&&this.b[a])if(this.j){var c=parseInt(this.b[a],10);this.l[c].postMessage(c,{update:!0,id:a,content:b})}else this.async?(this.g[a]||(this.c[this.c.length]=a),this.g[a]=[t.update,a,b],v(this)):(this.remove(a),b&&this.add(a,b))};f.prototype.remove=
function(a){if(this.b[a])if(this.j){var b=parseInt(this.b[a],10);this.l[b].postMessage(b,{remove:!0,id:a});delete this.b[a]}else if(this.async)this.g[a]||(this.c[this.c.length]=a),this.g[a]=[t.remove,a],v(this);else{b=Object.keys(this.a);for(var c=0;c<b.length;c++)for(var e=Object.keys(this.a[b[c]]),d=0;d<e.length;d++){var f=e[d],g=this.a[b[c]];if((g=g&&g[f])&&g.length)for(var h=0;h<g.length;h++)if(g[h]===a){g.splice(h,1);break}g.length||delete this.a[b[c]][f]}delete this.b[a];this.s=!1}};var H=d("[ -/]");
f.prototype.search=function(a,b,c){if("string"===typeof a&&a)"function"===typeof b?(c=b,b=1E3):b||(b=1E3);else return[];var e=a;if(!this.s)this.cache&&(this.f="",this.m.reset()),this.s=!0;else if(this.cache){var d=this.m.get(a);if(d)return d}else if(this.f&&-1!==a.indexOf(this.f))return[];if(this.j){this.v=c;this.u=0;this.h=[];for(e=0;e<this.i;e++)this.l[e].postMessage(e,{search:!0,limit:b,content:a});return null}if(c){var f=this;y(function(){c(f.search(a,b));f=null},1,"search-"+this.id);return null}for(d=
0;" "===a[d];)d++;d&&(e=a.substring(d));if(!e)return[];var g=e.split(H);1<g.length&&g.sort(C);d=[];var h=!0;e=[];for(var p={},m=0;m<g.length;m++){var l=g[m];if(!p[l]&&(l&&this.encode&&(l=this.encode(l)),l)){var q=this.a[l[0]];if((q=q&&q[l])&&q.length)e[e.length]=q;else{h=!1;break}p[g[m]]="1"}}if(h&&(1<e.length&&e.sort(D),g=0,h=e[g++])){for(d=e.length;h.length&&g<d;)p=e[g++],h=E(h,p,g===d?b:0);b&&h.length>b&&(h=h.slice(0,b));d=h}d.length?this.f="":this.f||(this.f=a);this.cache&&this.m.set(a,d);return d};
f.prototype.info=function(){if(this.j)for(var a=0;a<this.i;a++)this.l[a].postMessage(a,{info:!0,id:this.id});else{var b=0,c=0,d=0;var f=Object.keys(this.a);for(a=0;a<f.length;a++){var k=""+f[a];var g=this.a[k].length;b+=1*g+2*k.length;c+=g;d+=g*k.length}f=Object.keys(this.b);g=f.length;for(a=0;a<g;a++)b+=2*f[a].length+2;return{id:this.id,memory:b,items:g,sequences:c,chars:d,status:this.s,cache:this.c.length,matchers:u.length}}};f.prototype.reset=function(){this.D();this.C()};f.prototype.D=function(){this.cache&&
this.m.reset();this.m=this.b=this.a=null};var w={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 m(b.toLowerCase(),a)}}(),advanced:function(){var a=
d(" "),b=[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("ou"),"o",d("uo"),"u"];return function(c,d){if(!c)return c;c=w.simple(c);2<c.length&&(c=m(c,b));d||(c=c.replace(a,""),1<c.length&&(c=x(c)));return c}}(),extra:function(){var a=[d("p"),"b",d("[sz]"),"c",d("[gq]"),"k",d("[jy]"),"i",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;
b=w.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]+m(d.substring(1),a))}b=b.join("");b=x(b)}return b}}()},y=function(){var a={};return function(b,c,d){var e=a[d];e&&clearTimeout(e);return a[d]=setTimeout(b,c)}}(),G=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 l={},r=!("undefined"===
typeof Blob||!URL||!URL.createObjectURL);return function(f,d,m,q){d=r?URL.createObjectURL(new Blob(["("+d.toString()+")()"],{type:"text/javascript"})):"js/worker/"+f+".js";l[f]||(l[f]=[]);l[f][q]=new Worker(d);l[f][q].onmessage=m;console.log("Register Worker@"+f);return{postMessage:function(d,m){l[f][d].postMessage(m)}}}}()));
{
"name": "flexsearch",
"version": "0.1.21",
"version": "0.1.22",
"description": "Superfast, lightweight and memory efficient full text search library.",

@@ -21,2 +21,7 @@ "keywords": [],

},
"files": [
"flexsearch.js",
"flexsearch.min.js",
"test/"
],
"homepage": "https://nextapps-de.github.io/xone/",

@@ -23,0 +28,0 @@ "author": "Thomas Wilkerling",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc