You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

bulksearch

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bulksearch - npm Package Compare versions

Comparing version

to
0.1.25

121

bulksearch.js

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

* @preserve https://github.com/nextapps-de/bulksearch
* @version: 0.1.24
* @version: 0.1.25
* @license: Apache 2.0 Licence

@@ -54,4 +54,4 @@ */

// paginate results
paginate: false,
// paging results
paging: false,

@@ -66,7 +66,7 @@ // default chunk size

/**
* @type {Array<Array>}
* @type {Array}
* @private
*/
var custom_matchers = [];
var global_matcher = [];

@@ -156,6 +156,4 @@ /**

custom_matchers[custom_matchers.length] = [
regex(key), matcher[key]
];
global_matcher[global_matcher.length] = regex(key);
global_matcher[global_matcher.length] = matcher[key];
}

@@ -166,3 +164,14 @@ }

/**
* @param {Object<string, number|string|boolean>=} options
* @param {string} name
* @param {function(string):string} encoder
* @export
*/
BulkSearch.register = function(name, encoder){
global_encoder[name] = encoder;
};
/**
* @param {Object<string, number|string|boolean|Object|function(string):string>=} options
* @this {BulkSearch}

@@ -227,7 +236,7 @@ * @export

this.paginate = (
this.paging = (
options['paginate'] ||
this.paginate ||
defaults.paginate
options['paging'] ||
this.paging ||
defaults.paging
);

@@ -249,26 +258,23 @@

/**
* @type {Object<string, number>}
* @private
*/
this._scores = {};
/**
* @type {number}
* @private
*/
this._chunk_size = 10000;
/** @export */
this.encoder = (
(options['encode'] && encoder[options['encode']]) ||
(options['encode'] && global_encoder[options['encode']]) ||
this.encoder ||
(defaults.encode && encoder[defaults.encode]) ||
global_encoder[defaults.encode] ||
options['encode']
);
/** @type {Object<string, number>} */
this._scores = {};
/** @type {number} */
this._chunk_size = /** @type {number} */ (options['size'] || defaults.size);
if(options['matcher']) {
/** @type {Array} */
this._matcher = [];
this.addMatcher(/** @type {Object<string, string>} */ (options['matcher']));
}
}

@@ -278,2 +284,3 @@

this._matcher || (this._matcher = []);
this._index = [create_typed_array(this.type, this._chunk_size)];

@@ -308,10 +315,10 @@ this._marker = {};

if(custom_matchers.length){
if(global_matcher.length){
for(var i = 0; i < custom_matchers.length; i++){
value = replace(value, global_matcher);
}
var matcher = custom_matchers[i];
if(this._matcher.length){
value = value.replace(matcher[0], matcher[1]);
}
value = replace(value, this._matcher);
}

@@ -672,3 +679,3 @@

if(this.paginate){
if(this.paging){

@@ -915,2 +922,19 @@ var page = {

/**
* @param {Object<string, string>} matcher
* @export
*/
BulkSearch.prototype.addMatcher = function(matcher){
for(var key in matcher){
if(matcher.hasOwnProperty(key)){
this._matcher[this._matcher.length] = regex(key);
this._matcher[this._matcher.length] = matcher[key];
}
}
};
/**
* @this {BulkSearch}

@@ -1027,3 +1051,3 @@ * @export

'status': this._status,
'matchers': custom_matchers.length
'matchers': global_matcher.length
};

@@ -1062,11 +1086,12 @@ };

// release references
// unset references
this._index = null;
this._marker = null;
this._fragment = null;
this._bulk = null;
this._register = null;
this._cache = null;
this._scores = null;
this._index =
this._marker =
this._fragment =
this._bulk =
this._register =
this._cache =
this._scores =
this._matcher = null;
};

@@ -1082,3 +1107,3 @@

var encoder = {
var global_encoder = {

@@ -1184,3 +1209,3 @@ // case insensitive search

// perform simple encoding
string = encoder['simple'](string);
string = global_encoder['simple'](string);

@@ -1242,3 +1267,3 @@ // normalize special pairs

// perform advanced encoding
str = encoder['advanced'](str, /* skip post processing? */ true);
str = global_encoder['advanced'](str, /* skip post processing? */ true);

@@ -1245,0 +1270,0 @@ if(str.length > 1){

/*
https://github.com/nextapps-de/bulksearch
@version: 0.1.24
@version: 0.1.25
@license: Apache 2.0 Licence
*/
'use strict';(function(l,q,d){var g;(g=d.define)&&g.amd?g([],function(){return q}):(g=d.modules)?g[l.toLowerCase()]=q:"undefined"!==typeof module?module.exports=q:d[l]=q})("BulkSearch",function(l,q){function d(a){this.id=C++;this.init(a||f);Object.defineProperty(this,"index",{get:function(){return this.a}});Object.defineProperty(this,"length",{get:function(){return Object.keys(this.a).length}})}function g(a,b){return new (("int"===a||"integer"===a?Uint32Array:"short"===a?Uint16Array:"float"===a||
"double"===a?Float64Array:"byte"===a?Uint8Array:Array)||Array)(b)}function c(a){return new RegExp(a,"g")}function x(a,b,e){if("undefined"===typeof e){for(e=0;e<b.length;e+=2)a=a.replace(b[e],b[e+1]);return a}return a.replace(b,e)}function D(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function z(a){for(var b="",e="",h="",m=0;m<a.length;m++){var c=a[m];c!==e&&(0<m&&"h"===c?(h="a"===h||"e"===h||"i"===h||"o"===h||"u"===h||"y"===h,"a"!==e&&"e"!==e&&"i"!==e&&"o"!==e&&"u"!==e&&"y"!==e||!h||(b+=c)):b+=
c);h=m===a.length-1?"":a[m+1];e=c}return b}function A(a){var b={},e=a.split(y);a="";for(var h=0;h<e.length;h++){var c=e[h];c&&(this.encode&&(c=this.encode(c)),c&&!b[c]&&(b[c]="1",a+=c))}return a}var f={type:"integer",result:"id",separator:"~",A:!1,u:!1,j:!1,w:!1,cache:!1,encode:!1,v:!1,size:4E3,depth:0},r=[],C=0;d.new=function(a){return new this(a)};d.create=function(a){return d.new(a)};d.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(r[r.length]=[c(b),a[b]])};d.prototype.init=function(a){a&&
(this.type=a.type||this.type||f.type,this.result=a.result||this.result||f.result,this.separator=a.separator||this.separator||f.separator,this.A=a.strict||this.A||f.A,this.w=a.ordered||this.w||f.w,this.u=a.multi||this.u||f.u,this.j="or"===a["boolean"]||this.j||f.j,this.v=a.paginate||this.v||f.v,this.cache=a.cache||this.cache||f.cache,this.depth=a.depth||this.depth||f.depth,this.h={},this.f=1E4,this.encoder=a.encode&&t[a.encode]||this.encoder||f.encode&&t[f.encode]||a.encode,this.f=a.size||f.size);
this.g=[g(this.type,this.f)];this.a={};this.i={};this.o={};this.b=[""];this.B=0;this.s=!0;this.l=0;this.c=this.cache?new q(3E4,50,!0):!1};d.prototype.encode=function(a){this.encoder&&(a=this.encoder(a));if(r.length)for(var b=0;b<r.length;b++){var e=r[b];a=a.replace(e[0],e[1])}return a};d.prototype.add=function(a,b,e){if("string"===typeof b&&b&&(a||0===a))if(this.a[a])this.update(a,b);else if("string"===typeof e?b=e:b&&(b=A.call(this,b)),b){var h=this.b;e=this.B;var c=this.i[b.length];if(c&&c.length){this.a[a]=
c=c.pop();e=c[0];var n=c[1];var k=h[e];h[e]=k.substring(0,n)+b+k.substring(c[2]);this.l-=b.length}else n=h[e].length,n+b.length>this.f&&(b.length>this.f/2&&(this.f=2*b.length),n&&(this.B=++e),n=0,h[e]="",this.g[e]=g(this.type,this.f)),this.a[a]=c=[e,n,0],h[e]+=b+this.separator;if(this.g[e].constructor===Array)for(h=0;h<b.length;h++)this.g[e][n++]=a;else this.g[e].fill(a,n,n+b.length+1),n+=b.length;c[2]=n;if(this.depth)for(h=this.depth;1<h;h--)a=b.substring(0,h),this.o[a]||(this.o[a]=[]),this.o[a].push(c);
this.s=!1}};d.prototype.update=function(a,b){if("string"===typeof b&&(a||0===a)){var e=this.a[a];if(e){var c=b;b&&(b=A.call(this,b));if(!c||b){var m=e[1],n=e[2],k=n-m,d=b.length-k,p=b;for(0<d&&(b="");b.length<k;)b=(b+" ").substring(0,k);var B=this.b,f=e[0],l=B[f];B[f]=l.substring(0,m)+b+l.substring(n);if(0<d||!c)(b=this.i[k])?b=b.length:(this.i[k]=[],b=0),this.i[k][b]=e,this.l+=k,this.a[a]=null,c&&this.add(a,c,p);this.s=!1}}}};d.prototype.remove=function(a){this.a[a]&&
(this.update(a,""),delete this.a[a],delete this.h[a])};var y=c("[ -/]");d.prototype.search=function(a,b,e){var c=0,m=0;a&&"object"===typeof a&&(e=b,b=a,a=a.query);b&&("function"===typeof b?(e=b,b=1E3):"object"===typeof b&&(b.page&&(m=b.page.split(":"),c=parseInt(m[0],10),m=parseInt(m[1],10)),b.callback&&(e=b.callback,b.callback=!1),b=b.limit));b||(b=1E3);if(e){var n=this;if(c||m)b={page:c+":"+m,limit:b};l(function(){e(n.search(a,b));n=null},1,"search-"+this.id);return null}if(this.v)var k={page:c+
":"+m,next:null,results:[]},d=k.results;else d=[];if(!a||"string"!==typeof a)return k||d;var p=a;if(!this.s)this.cache&&(this.m="",this.c.reset()),this.s=!0;else if(this.cache){var f=this.c.get(a);if(f)return f}else if(this.m&&-1!==a.indexOf(this.m))return k||d;for(f=0;" "===a[f];)f++;f&&(p=a.substring(f));if(!p)return k||d;p=this.u?p.split(y):[p];f=p.length;1<f&&p.sort(D);var q=Array(f);for(this.encode&&p[0]&&(p[0]=this.encode(p[0]));c<this.b.length;c++){var g=m,w=0,r=this.b[c];for(m=0;-1!==(w=r.indexOf(p[0],
g));){g=this.g[c][w];var u=this.a[g];if(u){var t=u[1];w=u[2];u=!0;if(1<f){t=r.substring(t,w);for(var v=1;v<f;v++)if(p[v])if(this.encode&&!q[v]&&(p[v]=this.encode(p[v]),q[v]=!0),-1===t.indexOf(p[v]))if(this.j)u=!1;else{u=!1;break}else if(this.j){u=!0;break}}if(u&&(this.h[g]?this.h[g]++:this.h[g]=1,d[d.length]=g,b&&d.length===b))break}g=w+1}if(b&&d.length===b){k&&c<this.b.length&&w+1<this.b[c].length&&(k.next=c+":"+w);break}}d.length?this.m="":this.m||(this.m=a);this.cache&&this.c.set(a,k||d);return k||
d};d.prototype.optimize=function(){var a=this.b,b=this.a,c=this.c,h=this.h;this.reset();var d=Object.keys(b);d.sort(function(a,b){a=(h[b]||0)-(h[a]||0);return 0>a?-1:0<a?1:0});for(var f=0;f<d.length;f++){var k=d[f],g=b[k];g?this.add(k,a[g[0]].substring(g[1],g[2])):delete b[k]}c&&(this.c=c);this.h=h};d.prototype.info=function(){for(var a=this.l,b=Object.keys(this.a).length,c=Object.keys(this.i).length,d=Object.keys(this.o).length,f=0,g=0,k=0;k<this.b.length;k++)g+=this.b[k].length;g&&(a=(100/g*a*100|
0)/100,f=this.g[0].byteLength||32*g,f+=2*g+24*(b+c+d));return{id:this.id,length:b,chunks:this.b.length,register:d,depth:this.depth,size:this.f,bytes:f,fragments:c,fragmented:a,status:this.s,matchers:r.length}};d.prototype.reset=function(){this.destroy();this.init()};d.prototype.destroy=function(){this.cache&&this.c.reset();this.h=this.c=this.o=this.b=this.i=this.a=this.g=null};var t={icase:function(a){return a.toLowerCase()},simple:function(){var a=[c("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",
c("[\u00e8\u00e9\u00ea\u00eb]"),"e",c("[\u00ec\u00ed\u00ee\u00ef]"),"i",c("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",c("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",c("[\u00fd\u0177\u00ff]"),"y",c("\u00f1"),"n",c("\u00e7"),"c",c("\u00df"),"s",c("[-/]")," ",c("[^a-z0-9 ]"),""];return function(b){return x(b.toLowerCase(),a)}}(),advanced:function(){var a=c(" "),b=[c("ae"),"a",c("ai"),"ei",c("ay"),"ei",c("ey"),"ei",c("oe"),"o",c("ue"),"u",c("ie"),"i",c("sz"),"s",c("zs"),"s",c("sh"),"s",c("ck"),"k",c("cc"),
"k",c("dt"),"t",c("ph"),"f",c("ou"),"o",c("uo"),"u"];return function(c,d){if(!c)return c;c=t.simple(c);2<c.length&&(c=x(c,b));d||(c=c.replace(a,""),1<c.length&&(c=z(c)));return c}}(),extra:function(){var a=[c("p"),"b",c("[sz]"),"c",c("[gq]"),"k",c("[jy]"),"i",c("n"),"m",c("d"),"t",c("[vw]"),"f",c("[aeiouy]"),""];return function(b){if(!b)return b;b=t.advanced(b,!0);if(1<b.length){b=b.split(y);for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+x(d.substring(1),a))}b=b.join("");b=z(b)}return b}}()};
return d}(function(){var l={};return function(q,d,g){var c=l[g];c&&clearTimeout(c);return l[g]=setTimeout(q,d)}}(),function(){function l(){this.cache={}}l.prototype.reset=function(){this.cache={}};l.prototype.set=function(l,d){this.cache[l]=d};l.prototype.get=function(l){return this.cache[l]};return l}()),this);
'use strict';(function(l,r,d){var g;(g=d.define)&&g.amd?g([],function(){return r}):(g=d.modules)?g[l.toLowerCase()]=r:"undefined"!==typeof module?module.exports=r:d[l]=r})("BulkSearch",function(l,r){function d(a){this.id=B++;this.init(a||f);Object.defineProperty(this,"index",{get:function(){return this.a}});Object.defineProperty(this,"length",{get:function(){return Object.keys(this.a).length}})}function g(a,b){return new (("int"===a||"integer"===a?Uint32Array:"short"===a?Uint16Array:"float"===a||
"double"===a?Float64Array:"byte"===a?Uint8Array:Array)||Array)(b)}function c(a){return new RegExp(a,"g")}function v(a,b,e){if("undefined"===typeof e){for(e=0;e<b.length;e+=2)a=a.replace(b[e],b[e+1]);return a}return a.replace(b,e)}function C(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function z(a){for(var b="",e="",h="",t=0;t<a.length;t++){var c=a[t];c!==e&&(0<t&&"h"===c?(h="a"===h||"e"===h||"i"===h||"o"===h||"u"===h||"y"===h,"a"!==e&&"e"!==e&&"i"!==e&&"o"!==e&&"u"!==e&&"y"!==e||!h||(b+=c)):b+=
c);h=t===a.length-1?"":a[t+1];e=c}return b}function A(a){var b={},e=a.split(y);a="";for(var h=0;h<e.length;h++){var c=e[h];c&&(this.encode&&(c=this.encode(c)),c&&!b[c]&&(b[c]="1",a+=c))}return a}var f={type:"integer",result:"id",separator:"~",B:!1,v:!1,l:!1,A:!1,cache:!1,encode:!1,w:!1,size:4E3,depth:0},p=[],B=0;d.new=function(a){return new this(a)};d.create=function(a){return d.new(a)};d.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(p[p.length]=c(b),p[p.length]=a[b])};d.register=function(a,
b){u[a]=b};d.prototype.init=function(a){a&&(this.type=a.type||this.type||f.type,this.result=a.result||this.result||f.result,this.separator=a.separator||this.separator||f.separator,this.B=a.strict||this.B||f.B,this.A=a.ordered||this.A||f.A,this.v=a.multi||this.v||f.v,this.l="or"===a["boolean"]||this.l||f.l,this.w=a.paging||this.w||f.w,this.cache=a.cache||this.cache||f.cache,this.depth=a.depth||this.depth||f.depth,this.encoder=a.encode&&u[a.encode]||this.encoder||u[f.encode]||a.encode,this.h={},this.i=
a.size||f.size,a.matcher&&(this.c=[],this.addMatcher(a.matcher)));this.c||(this.c=[]);this.g=[g(this.type,this.i)];this.a={};this.j={};this.s={};this.b=[""];this.C=0;this.u=!0;this.m=0;this.f=this.cache?new r(3E4,50,!0):!1};d.prototype.encode=function(a){this.encoder&&(a=this.encoder(a));p.length&&(a=v(a,p));this.c.length&&(a=v(a,this.c));return a};d.prototype.add=function(a,b,e){if("string"===typeof b&&b&&(a||0===a))if(this.a[a])this.update(a,b);else if("string"===typeof e?b=e:b&&(b=A.call(this,
b)),b){var h=this.b;e=this.C;var c=this.j[b.length];if(c&&c.length){this.a[a]=c=c.pop();e=c[0];var m=c[1];var k=h[e];h[e]=k.substring(0,m)+b+k.substring(c[2]);this.m-=b.length}else m=h[e].length,m+b.length>this.i&&(b.length>this.i/2&&(this.i=2*b.length),m&&(this.C=++e),m=0,h[e]="",this.g[e]=g(this.type,this.i)),this.a[a]=c=[e,m,0],h[e]+=b+this.separator;if(this.g[e].constructor===Array)for(h=0;h<b.length;h++)this.g[e][m++]=a;else this.g[e].fill(a,m,m+b.length+1),m+=b.length;c[2]=m;if(this.depth)for(h=
this.depth;1<h;h--)a=b.substring(0,h),this.s[a]||(this.s[a]=[]),this.s[a].push(c);this.u=!1}};d.prototype.update=function(a,b){if("string"===typeof b&&(a||0===a)){var e=this.a[a];if(e){var c=b;b&&(b=A.call(this,b));if(!c||b){var t=e[1],m=e[2],k=m-t,d=b.length-k,n=b;for(0<d&&(b="");b.length<k;)b=(b+" ").substring(0,k);var q=this.b,f=e[0],l=q[f];q[f]=l.substring(0,t)+b+l.substring(m);if(0<d||!c)(b=this.j[k])?b=b.length:(this.j[k]=[],b=0),this.j[k][b]=
e,this.m+=k,this.a[a]=null,c&&this.add(a,c,n);this.u=!1}}}};d.prototype.remove=function(a){this.a[a]&&(this.update(a,""),delete this.a[a],delete this.h[a])};var y=c("[ -/]");d.prototype.search=function(a,b,e){var c=0,d=0;a&&"object"===typeof a&&(e=b,b=a,a=a.query);b&&("function"===typeof b?(e=b,b=1E3):"object"===typeof b&&(b.page&&(d=b.page.split(":"),c=parseInt(d[0],10),d=parseInt(d[1],10)),b.callback&&(e=b.callback,b.callback=!1),b=b.limit));b||(b=1E3);if(e){var m=this;if(c||d)b={page:c+":"+d,limit:b};
l(function(){e(m.search(a,b));m=null},1,"search-"+this.id);return null}if(this.w)var k={page:c+":"+d,next:null,results:[]},f=k.results;else f=[];if(!a||"string"!==typeof a)return k||f;var n=a;if(!this.u)this.cache&&(this.o="",this.f.reset()),this.u=!0;else if(this.cache){var q=this.f.get(a);if(q)return q}else if(this.o&&-1!==a.indexOf(this.o))return k||f;for(q=0;" "===a[q];)q++;q&&(n=a.substring(q));if(!n)return k||f;n=this.v?n.split(y):[n];q=n.length;1<q&&n.sort(C);var r=Array(q);for(this.encode&&
n[0]&&(n[0]=this.encode(n[0]));c<this.b.length;c++){var g=d,p=0,v=this.b[c];for(d=0;-1!==(p=v.indexOf(n[0],g));){g=this.g[c][p];var w=this.a[g];if(w){var u=w[1];p=w[2];w=!0;if(1<q){u=v.substring(u,p);for(var x=1;x<q;x++)if(n[x])if(this.encode&&!r[x]&&(n[x]=this.encode(n[x]),r[x]=!0),-1===u.indexOf(n[x]))if(this.l)w=!1;else{w=!1;break}else if(this.l){w=!0;break}}if(w&&(this.h[g]?this.h[g]++:this.h[g]=1,f[f.length]=g,b&&f.length===b))break}g=p+1}if(b&&f.length===b){k&&c<this.b.length&&p+1<this.b[c].length&&
(k.next=c+":"+p);break}}f.length?this.o="":this.o||(this.o=a);this.cache&&this.f.set(a,k||f);return k||f};d.prototype.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(this.c[this.c.length]=c(b),this.c[this.c.length]=a[b])};d.prototype.optimize=function(){var a=this.b,b=this.a,c=this.f,h=this.h;this.reset();var d=Object.keys(b);d.sort(function(a,b){a=(h[b]||0)-(h[a]||0);return 0>a?-1:0<a?1:0});for(var f=0;f<d.length;f++){var k=d[f],g=b[k];g?this.add(k,a[g[0]].substring(g[1],g[2])):delete b[k]}c&&
(this.f=c);this.h=h};d.prototype.info=function(){for(var a=this.m,b=Object.keys(this.a).length,c=Object.keys(this.j).length,d=Object.keys(this.s).length,f=0,g=0,k=0;k<this.b.length;k++)g+=this.b[k].length;g&&(a=(100/g*a*100|0)/100,f=this.g[0].byteLength||32*g,f+=2*g+24*(b+c+d));return{id:this.id,length:b,chunks:this.b.length,register:d,depth:this.depth,size:this.i,bytes:f,fragments:c,fragmented:a,status:this.u,matchers:p.length}};d.prototype.reset=function(){this.destroy();this.init()};d.prototype.destroy=
function(){this.cache&&this.f.reset();this.g=this.a=this.j=this.b=this.s=this.f=this.h=this.c=null};var u={icase:function(a){return a.toLowerCase()},simple:function(){var a=[c("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",c("[\u00e8\u00e9\u00ea\u00eb]"),"e",c("[\u00ec\u00ed\u00ee\u00ef]"),"i",c("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",c("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",c("[\u00fd\u0177\u00ff]"),"y",c("\u00f1"),"n",c("\u00e7"),"c",c("\u00df"),"s",c("[-/]")," ",c("[^a-z0-9 ]"),""];return function(b){return v(b.toLowerCase(),
a)}}(),advanced:function(){var a=c(" "),b=[c("ae"),"a",c("ai"),"ei",c("ay"),"ei",c("ey"),"ei",c("oe"),"o",c("ue"),"u",c("ie"),"i",c("sz"),"s",c("zs"),"s",c("sh"),"s",c("ck"),"k",c("cc"),"k",c("dt"),"t",c("ph"),"f",c("ou"),"o",c("uo"),"u"];return function(c,d){if(!c)return c;c=u.simple(c);2<c.length&&(c=v(c,b));d||(c=c.replace(a,""),1<c.length&&(c=z(c)));return c}}(),extra:function(){var a=[c("p"),"b",c("[sz]"),"c",c("[gq]"),"k",c("[jy]"),"i",c("n"),"m",c("d"),"t",c("[vw]"),"f",c("[aeiouy]"),""];return function(b){if(!b)return b;
b=u.advanced(b,!0);if(1<b.length){b=b.split(y);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=z(b)}return b}}()};return d}(function(){var l={};return function(r,d,g){var c=l[g];c&&clearTimeout(c);return l[g]=setTimeout(r,d)}}(),function(){function l(){this.cache={}}l.prototype.reset=function(){this.cache={}};l.prototype.set=function(l,d){this.cache[l]=d};l.prototype.get=function(l){return this.cache[l]};return l}()),this);
{
"name": "bulksearch",
"version": "0.1.24",
"version": "0.1.25",
"description": "Superfast, lightweight and read-write optimized full text search library.",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -36,3 +36,3 @@ # BulkSearch

Always use latest from CDN:
Use latest from CDN:
```html

@@ -70,3 +70,3 @@ <script src="https://cdn.rawgit.com/nextapps-de/bulksearch/master/bulksearch.min.js"></script>

- <a href="#bulksearch.create">BulkSearch.__create__(\<options\>)</a>
- <a href="#bulksearch.addmatcher">BulkSearch.__addMatcher__(_KEY_VALUE_PAIRS_)</a>
- <a href="#bulksearch.addmatcher">BulkSearch.__addMatcher__({_KEY: VALUE_})</a>
- <a href="#bulksearch.register">BulkSearch.__register__(name, encoder)</a>

@@ -77,3 +77,5 @@ - <a href="#bulksearch.encode">BulkSearch.__encode__(name, string)</a>

- <a href="#index.add">Index.__add__(id, string)</a>
- <a href="#index.search">Index.__search__(string, \<limit|page|options\>, \<callback\>)</a>
- <a href="#index.search1">Index.__search__(string, \<limit\>, \<callback\>)</a>
- <a href="#index.search2">Index.__search__(string, \<page\>, \<callback\>)</a>
- <a href="#index.search3">Index.__search__(options, \<callback\>)</a>
- <a href="#index.update">Index.__update__(id, string)</a>

@@ -86,3 +88,3 @@ - <a href="#index.remove">Index.__remove__(id)</a>

- <a href="#index.info">Index.__info__()</a>
- <a href="#index.addmatcher">Index.__addMatcher__(_KEY_VALUE_PAIRS_)</a>
- <a href="#index.addmatcher">Index.__addMatcher__({_KEY: VALUE_})</a>
- <a href="#index.encode">Index.__encode__(string)</a>

@@ -120,3 +122,3 @@

ordered: false,
paginate: false,
paging: false,
async: false,

@@ -136,6 +138,6 @@ cache: false

```
<a name="index.search"></a>
<a name="index.search1"></a>
#### Search items
> Index.__search(string, \<limit|page|options\>, \<callback\>)__
> Index.__search(string|options, \<limit|page\>, \<callback\>)__

@@ -146,3 +148,3 @@ ```js

##### Limit the result
Limit the result:

@@ -153,3 +155,3 @@ ```js

##### Perform queries asynchronously
Perform queries asynchronously:

@@ -162,2 +164,16 @@ ```js

```
<a name="index.search3"></a>
Pass parameter as an object:
```js
index.search({
query: "John",
page: '1:1234',
limit: 10,
callback: function(result){
// async
}
});
```
<a name="index.update"></a>

@@ -180,3 +196,3 @@ #### Update item from an index

<a name="index.reset"></a>
#### Reset Index
#### Reset index

@@ -187,3 +203,3 @@ ```js

<a name="index.destroy"></a>
#### Destroy Index
#### Destroy index

@@ -194,3 +210,3 @@ ```js

<a name="index.init"></a>
#### Re-Initialize Index
#### Re-Initialize index

@@ -216,3 +232,3 @@ > Index.__init(\<options\>)__

> BulkSearch.__addMatcher(_KEY_VALUE_PAIRS_)__
> BulkSearch.__addMatcher({_KEY: VALUE_})__

@@ -224,4 +240,4 @@ Add global matchers for all instances:

'ä': 'a', // replaces all 'ä' to 'a'
'ö': 'o',
'Ü': 'u'
'ó': 'o',
'û': 'u'
});

@@ -235,4 +251,4 @@ ```

'ä': 'a', // replaces all 'ä' to 'a'
'ö': 'o',
'Ü': 'u'
'ó': 'o',
'û': 'u'
});

@@ -243,3 +259,3 @@ ```

Define a private custom encoder during creation:
Define a private custom encoder during creation/initialization:
```js

@@ -256,24 +272,11 @@ var index = new BulkSearch({

```
<a name="bulksearch.register"></a>
##### Register a global encoder to be used by all instances
Define a custom encoder during initialization:
```js
index.init({
> BulkSearch.__register(name, encoder)__
encode: function(str){
// do something with str ...
return str;
}
});
```
<a name="bulksearch.register"></a>
##### Define a global encoder to be used by all instances:
```js
BulkSearch.register({
BulkSearch.register('whitespace', function(str){
'whitespace': function(str){
return str.replace(/ /g, '');
}
return str.replace(/ /g, '');
});

@@ -287,4 +290,5 @@ ```

<a name="index.encode"></a>
##### Call public/private encoders directly:
##### Call encoders directly
Private encoder:
```js

@@ -294,2 +298,3 @@ var encoded = index.encode("sample text");

<a name="bulksearch.encode"></a>
Global encoder:
```js

@@ -299,2 +304,24 @@ var encoded = BulkSearch.encode("whitespace", "sample text");

##### Mixup/Extend multiple encoders
```js
BulkSearch.register('mixed', function(str){
str = this.encode("icase", str); // built-in
str = this.encode("whitespace", str); // custom
return str;
});
```
```js
BulkSearch.register('extended', function(str){
str = this.encode("custom", str);
// do something additional with str ...
return str;
});
```
<a name="index.info"></a>

@@ -313,3 +340,3 @@ #### Get info

"chunks": 9,
"fragmentation": 0,
"fragmentation": 0, // in %
"fragments": 0,

@@ -334,10 +361,10 @@ "id": 0,

<a name="pagination"></a>
#### Pagination
### Pagination
__Note:__ Pagination can simply boost up query time by a factor of 100. The pagination isn't yet bi-directional, it is only possible to page forward.
__Note:__ Pagination can simply reduce query time by a factor of 100. The pagination isn't yet bi-directional, it is only possible to page forward.
Enable pagination:
Enable pagination on initialization:
```js
var index = BulkSearch.create({ paginate: true });
var index = BulkSearch.create({ paging: true });
```

@@ -357,3 +384,3 @@

"next": "1:16322",
"results": [/* ... */]
"results": []
}

@@ -380,3 +407,3 @@ ```

</table>
<a name="index.search2"></a>
Perform query and pass a pointer to a specific page:

@@ -422,3 +449,3 @@

"extra"<br>
{function}
function(string):string
</td>

@@ -491,3 +518,3 @@ <td>The encoding type. Choose one of the built-ins or pass a custom encoding function.</td>

<tr>
<th align="left">Option</th>
<th align="left">Encoder</th>
<th align="left">Description</th>

@@ -511,3 +538,3 @@ <th align="left">Example</th>

<tr>
<td><b>icase</b></td>
<td><b>"icase"</b></td>
<td>Case in-sensitive encoding</td>

@@ -523,3 +550,3 @@ <td>

<tr>
<td><b>simple</b></td>
<td><b>"simple"</b></td>
<td>Phonetic normalizations</td>

@@ -535,3 +562,3 @@ <td>

<tr>
<td><b>advanced</b></td>
<td><b>"advanced"</b></td>
<td>Phonetic normalizations + Literal transformations</td>

@@ -547,3 +574,3 @@ <td>

<tr>
<td><b>extra</b></td>
<td><b>"extra"</b></td>
<td>Phonetic normalizations + Soundex transformations</td>

@@ -560,3 +587,3 @@ <td>

<a name="compare" id="compare"></a>
### Compare Phonetic Search Results
### Compare Phonetic Search

@@ -684,3 +711,3 @@ Reference String: __"Björn-Phillipp Mayer"__

<a name="memory" id="memory"></a>
## Compare Memory Usage
## Memory Usage

@@ -687,0 +714,0 @@ __Note:__ The data type of passed IDs has to be specified on creation. It is recommended to uses the most lowest possible data range here, e.g. use "short" when IDs are not higher than 65,535.

@@ -70,3 +70,3 @@ if(typeof module !== 'undefined'){

paginate: true,
paging: true,
multi: true

@@ -332,3 +332,3 @@ });

it('Should have been paginated properly', function(){
it('Should have been pagingd properly', function(){

@@ -335,0 +335,0 @@ var query = bulksearch_pager.search("foobar", 2);