From 27ab2de00c07d11addd5defc980caf48ba02cebd Mon Sep 17 00:00:00 2001 From: Matthew Topol Date: Fri, 14 Sep 2018 13:52:24 -0400 Subject: [PATCH 1/6] using node-pre-gyp to build and package, looks good --- binding.gyp | 25 +++++++++++++----------- build/lz4.js | 36 +++++++++++++++++------------------ build/lz4.min.js | 4 ++-- lib/binding/lz4_binding.cc | 6 ++++++ lib/binding/xxhash_binding.cc | 19 +++++++++--------- lib/binding/xxhash_binding.h | 12 ++++++++++++ lib/utils.js | 19 +++++++++++------- package.json | 10 +++++++++- 8 files changed, 83 insertions(+), 48 deletions(-) create mode 100644 lib/binding/xxhash_binding.h diff --git a/binding.gyp b/binding.gyp index cb227a47..dfdd93f8 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,21 +1,13 @@ { 'targets': [ { - 'target_name': 'xxhash', + 'target_name': '<(module_name)', 'sources': [ + 'lib/binding/lz4_binding.cc', 'lib/binding/xxhash_binding.cc', + 'lib/binding/xxhash_binding.h', 'deps/lz4/lib/xxhash.h', 'deps/lz4/lib/xxhash.c', - ], - 'include_dirs': [ - '>8&255},e.blockChecksum=function(t){return i(t,n).toNumber()},e.streamChecksum=function(t,r){return null===t?r.digest().toNumber():(null===r&&(r=i(n)),r.update(t))},e.readInt32LE=function(t,r){return t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24},e.bindings=t("./binding")},{"./binding":1,xxhashjs:12}],1:[function(t,r,e){function i(t,r,i,o,a,u){var l=a,y=u-a,m=0;if(t.length>=n)throw new Error("input too large");if(t.length>f){var w=e.compressBound(t.length);if(w>y)throw Error("output too small: "+y+" < "+w);for(var v=1,E=(1<i+h;){var b=t[i+1]<<8|t[i],I=t[i+3]<<8|t[i+2],B=Math.imul(b|I<<16,g)>>>s,R=o[B]-1;if(o[B]=i+1,0>R||i-R>>>16>0||(t[R+3]<<8|t[R+2])!=I||(t[R+1]<<8|t[R])!=b)v=E++>>c,i+=v;else{E=(1<i&&t[i]==t[R];)i++,R++;T=i-T;var C=p>T?T:p;if(U>=d){r[l++]=(d<<_)+C;for(var P=U-d;P>254;P-=255)r[l++]=255;r[l++]=P}else r[l++]=(U<<_)+C;for(var L=0;U>L;L++)r[l++]=t[m+L];if(r[l++]=x,r[l++]=x>>8,T>=p){for(T-=p;T>=255;)T-=255,r[l++]=255;r[l++]=T}m=i}}}if(0==m)return 0;if(U=t.length-m,U>=d){r[l++]=d<<_;for(var S=U-d;S>254;S-=255)r[l++]=255;r[l++]=S}else r[l++]=U<<_;for(i=m;i>>16,i=65535&t,n=r>>>16,h=65535&r;return i*h+(e*h+i*n<<16)|0}),e.uncompress=function(t,r,e,i){e=e||0,i=i||t.length-e;for(var n=e,h=i,o=0;h>n;){var s=t[n++],a=s>>4;if(a>0){for(var u=a+240;255===u;)u=t[n++],a+=u;for(var f=n+a;f>n;)r[o++]=t[n++];if(n===h)return o}var c=t[n++]|t[n++]<<8;if(0===c||c>o)return-(n-2);for(var _=15&s,u=_+240;255===u;)u=t[n++],_+=u;for(var p=o-c,f=o+_+4;f>o;)r[o++]=r[p++]}return o};var n=2113929216,h=4,o=16,s=8*h-o,a=1<n?0:t+t/255+16|0},e.compress=function(t,r,e,n){for(var h=new Array(a),o=0;a>o;o++)h[o]=0;return i(t,r,0,h,e||0,n||r.length)},e.compressHC=e.compress,e.compressDependent=i},{cuint:4}],2:[function(t,r,e){},{}],3:[function(t,r,e){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function r(t){var r=t.charCodeAt(0);return r===o||r===c?62:r===s||r===_?63:a>r?-1:a+10>r?r-a+26+26:f+26>r?r-f:u+26>r?r-u+26:void 0}function e(t){function e(t){u[c++]=t}var i,n,o,s,a,u;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;a="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,u=new h(3*t.length/4-a),o=a>0?t.length-4:t.length;var c=0;for(i=0,n=0;o>i;i+=4,n+=3)s=r(t.charAt(i))<<18|r(t.charAt(i+1))<<12|r(t.charAt(i+2))<<6|r(t.charAt(i+3)),e((16711680&s)>>16),e((65280&s)>>8),e(255&s);return 2===a?(s=r(t.charAt(i))<<2|r(t.charAt(i+1))>>4,e(255&s)):1===a&&(s=r(t.charAt(i))<<10|r(t.charAt(i+1))<<4|r(t.charAt(i+2))>>2,e(s>>8&255),e(255&s)),u}function n(t){function r(t){return i.charAt(t)}function e(t){return r(t>>18&63)+r(t>>12&63)+r(t>>6&63)+r(63&t)}var n,h,o,s=t.length%3,a="";for(n=0,o=t.length-s;o>n;n+=3)h=(t[n]<<16)+(t[n+1]<<8)+t[n+2],a+=e(h);switch(s){case 1:h=t[t.length-1],a+=r(h>>2),a+=r(h<<4&63),a+="==";break;case 2:h=(t[t.length-2]<<8)+t[t.length-1],a+=r(h>>10),a+=r(h>>4&63),a+=r(h<<2&63),a+="="}return a}var h="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),s="/".charCodeAt(0),a="0".charCodeAt(0),u="a".charCodeAt(0),f="A".charCodeAt(0),c="-".charCodeAt(0),_="_".charCodeAt(0);t.toByteArray=e,t.fromByteArray=n}("undefined"==typeof e?this.base64js={}:e)},{}],4:[function(t,r,e){e.UINT32=t("./lib/uint32"),e.UINT64=t("./lib/uint64")},{"./lib/uint32":5,"./lib/uint64":6}],5:[function(t,r,e){!function(t){function e(t,r){return this instanceof e?(this._low=0,this._high=0,this.remainder=null,"undefined"==typeof r?n.call(this,t):"string"==typeof t?h.call(this,t,r):void i.call(this,t,r)):new e(t,r)}function i(t,r){return this._low=0|t,this._high=0|r,this}function n(t){return this._low=65535&t,this._high=t>>>16,this}function h(t,r){var e=parseInt(t,r||10);return this._low=65535&e,this._high=e>>>16,this}({36:e(Math.pow(36,5)),16:e(Math.pow(16,7)),10:e(Math.pow(10,9)),2:e(Math.pow(2,30))}),{36:e(36),16:e(16),10:e(10),2:e(2)};e.prototype.fromBits=i,e.prototype.fromNumber=n,e.prototype.fromString=h,e.prototype.toNumber=function(){return 65536*this._high+this._low},e.prototype.toString=function(t){return this.toNumber().toString(t||10)},e.prototype.add=function(t){var r=this._low+t._low,e=r>>>16;return e+=this._high+t._high,this._low=65535&r,this._high=65535&e,this},e.prototype.subtract=function(t){return this.add(t.clone().negate())},e.prototype.multiply=function(t){var r,e,i=this._high,n=this._low,h=t._high,o=t._low;return e=n*o,r=e>>>16,r+=i*o,r&=65535,r+=n*h,this._low=65535&e,this._high=65535&r,this},e.prototype.div=function(t){if(0==t._low&&0==t._high)throw Error("division by zero");if(0==t._high&&1==t._low)return this.remainder=new e(0),this;if(t.gt(this))return this.remainder=this.clone(),this._low=0,this._high=0,this;if(this.eq(t))return this.remainder=new e(0),this._low=1,this._high=0,this;for(var r=t.clone(),i=-1;!this.lt(r);)r.shiftLeft(1,!0),i++;for(this.remainder=this.clone(),this._low=0,this._high=0;i>=0;i--)r.shiftRight(1),this.remainder.lt(r)||(this.remainder.subtract(r),i>=16?this._high|=1<>>16)&65535,this},e.prototype.equals=e.prototype.eq=function(t){return this._low==t._low&&this._high==t._high},e.prototype.greaterThan=e.prototype.gt=function(t){return this._high>t._high?!0:this._hight._low},e.prototype.lessThan=e.prototype.lt=function(t){return this._hight._high?!1:this._low16?(this._low=this._high>>t-16,this._high=0):16==t?(this._low=this._high,this._high=0):(this._low=this._low>>t|this._high<<16-t&65535,this._high>>=t),this},e.prototype.shiftLeft=e.prototype.shiftl=function(t,r){return t>16?(this._high=this._low<>16-t,this._low=this._low<>>32-t,this._low=65535&r,this._high=r>>>16,this},e.prototype.rotateRight=e.prototype.rotr=function(t){var r=this._high<<16|this._low;return r=r>>>t|r<<32-t,this._low=65535&r,this._high=r>>>16,this},e.prototype.clone=function(){return new e(this._low,this._high)},"undefined"!=typeof define&&define.amd?define([],function(){return e}):"undefined"!=typeof r&&r.exports?r.exports=e:t.UINT32=e}(this)},{}],6:[function(t,r,e){!function(t){function e(t,r,o,s){return this instanceof e?(this.remainder=null,"string"==typeof t?h.call(this,t,r):"undefined"==typeof r?n.call(this,t):void i.apply(this,arguments)):new e(t,r,o,s)}function i(t,r,e,i){return"undefined"==typeof e?(this._a00=65535&t,this._a16=t>>>16,this._a32=65535&r,this._a48=r>>>16,this):(this._a00=0|t,this._a16=0|r,this._a32=0|e,this._a48=0|i,this)}function n(t){return this._a00=65535&t,this._a16=t>>>16,this._a32=0,this._a48=0,this}function h(t,r){r=r||10,this._a00=0,this._a16=0,this._a32=0,this._a48=0;for(var i=o[r]||new e(Math.pow(r,5)),n=0,h=t.length;h>n;n+=5){var s=Math.min(5,h-n),a=parseInt(t.slice(n,n+s),r);this.multiply(5>s?new e(Math.pow(r,s)):i).add(new e(a))}return this}var o={16:e(Math.pow(16,5)),10:e(Math.pow(10,5)),2:e(Math.pow(2,5))},s={16:e(16),10:e(10),2:e(2)};e.prototype.fromBits=i,e.prototype.fromNumber=n,e.prototype.fromString=h,e.prototype.toNumber=function(){return 65536*this._a16+this._a00},e.prototype.toString=function(t){t=t||10;var r=s[t]||new e(t);if(!this.gt(r))return this.toNumber().toString(t);for(var i=this.clone(),n=new Array(64),h=63;h>=0&&(i.div(r),n[h]=i.remainder.toNumber().toString(t),i.gt(r));h--);return n[h-1]=i.toNumber().toString(t),n.join("")},e.prototype.add=function(t){var r=this._a00+t._a00,e=r>>>16;e+=this._a16+t._a16;var i=e>>>16;i+=this._a32+t._a32;var n=i>>>16;return n+=this._a48+t._a48,this._a00=65535&r,this._a16=65535&e,this._a32=65535&i,this._a48=65535&n,this},e.prototype.subtract=function(t){return this.add(t.clone().negate())},e.prototype.multiply=function(t){var r=this._a00,e=this._a16,i=this._a32,n=this._a48,h=t._a00,o=t._a16,s=t._a32,a=t._a48,u=r*h,f=u>>>16;f+=r*o;var c=f>>>16;f&=65535,f+=e*h,c+=f>>>16,c+=r*s;var _=c>>>16;return c&=65535,c+=e*o,_+=c>>>16,c&=65535,c+=i*h,_+=c>>>16,_+=r*a,_&=65535,_+=e*s,_&=65535,_+=i*o,_&=65535,_+=n*h,this._a00=65535&u,this._a16=65535&f,this._a32=65535&c,this._a48=65535&_,this},e.prototype.div=function(t){if(0==t._a16&&0==t._a32&&0==t._a48){if(0==t._a00)throw Error("division by zero");if(1==t._a00)return this.remainder=new e(0),this}if(t.gt(this))return this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0,this;if(this.eq(t))return this.remainder=new e(0),this._a00=1,this._a16=0,this._a32=0,this._a48=0,this;for(var r=t.clone(),i=-1;!this.lt(r);)r.shiftLeft(1,!0),i++;for(this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0;i>=0;i--)r.shiftRight(1),this.remainder.lt(r)||(this.remainder.subtract(r),i>=48?this._a48|=1<=32?this._a32|=1<=16?this._a16|=1<>>16),this._a16=65535&t,t=(65535&~this._a32)+(t>>>16),this._a32=65535&t,this._a48=~this._a48+(t>>>16)&65535,this},e.prototype.equals=e.prototype.eq=function(t){return this._a48==t._a48&&this._a00==t._a00&&this._a32==t._a32&&this._a16==t._a16},e.prototype.greaterThan=e.prototype.gt=function(t){return this._a48>t._a48?!0:this._a48t._a32?!0:this._a32t._a16?!0:this._a16t._a00},e.prototype.lessThan=e.prototype.lt=function(t){return this._a48t._a48?!1:this._a32t._a32?!1:this._a16t._a16?!1:this._a00=48?(this._a00=this._a48>>t-48,this._a16=0,this._a32=0,this._a48=0):t>=32?(t-=32,this._a00=65535&(this._a32>>t|this._a48<<16-t),this._a16=this._a48>>t&65535,this._a32=0,this._a48=0):t>=16?(t-=16,this._a00=65535&(this._a16>>t|this._a32<<16-t),this._a16=65535&(this._a32>>t|this._a48<<16-t),this._a32=this._a48>>t&65535,this._a48=0):(this._a00=65535&(this._a00>>t|this._a16<<16-t),this._a16=65535&(this._a16>>t|this._a32<<16-t),this._a32=65535&(this._a32>>t|this._a48<<16-t),this._a48=this._a48>>t&65535),this},e.prototype.shiftLeft=e.prototype.shiftl=function(t,r){return t%=64,t>=48?(this._a48=this._a00<=32?(t-=32,this._a48=this._a16<>16-t,this._a32=this._a00<=16?(t-=16,this._a48=this._a32<>16-t,this._a32=65535&(this._a16<>16-t),this._a16=this._a00<>16-t,this._a32=65535&(this._a32<>16-t),this._a16=65535&(this._a16<>16-t),this._a00=this._a00<=32){var r=this._a00;if(this._a00=this._a32,this._a32=r,r=this._a48,this._a48=this._a16,this._a16=r,32==t)return this;t-=32}var e=this._a48<<16|this._a32,i=this._a16<<16|this._a00,n=e<>>32-t,h=i<>>32-t;return this._a00=65535&h,this._a16=h>>>16,this._a32=65535&n,this._a48=n>>>16,this},e.prototype.rotateRight=e.prototype.rotr=function(t){if(t%=64,0==t)return this;if(t>=32){var r=this._a00;if(this._a00=this._a32,this._a32=r,r=this._a48,this._a48=this._a16,this._a16=r,32==t)return this;t-=32}var e=this._a48<<16|this._a32,i=this._a16<<16|this._a00,n=e>>>t|i<<32-t,h=i>>>t|e<<32-t;return this._a00=65535&h,this._a16=h>>>16,this._a32=65535&n,this._a48=n>>>16,this},e.prototype.clone=function(){return new e(this._a00,this._a16,this._a32,this._a48)},"undefined"!=typeof define&&define.amd?define([],function(){return e}):"undefined"!=typeof r&&r.exports?r.exports=e:t.UINT64=e}(this)},{}],7:[function(t,r,e){e.read=function(t,r,e,i,n){var h,o,s=8*n-i-1,a=(1<>1,f=-7,c=e?n-1:0,_=e?-1:1,p=t[r+c];for(c+=_,h=p&(1<<-f)-1,p>>=-f,f+=s;f>0;h=256*h+t[r+c],c+=_,f-=8);for(o=h&(1<<-f)-1,h>>=-f,f+=i;f>0;o=256*o+t[r+c],c+=_,f-=8);if(0===h)h=1-u;else{if(h===a)return o?NaN:(p?-1:1)*(1/0);o+=Math.pow(2,i),h-=u}return(p?-1:1)*o*Math.pow(2,h-i)},e.write=function(t,r,e,i,n,h){var o,s,a,u=8*h-n-1,f=(1<>1,_=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:h-1,l=i?1:-1,d=0>r||0===r&&0>1/r?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,o=f):(o=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-o))<1&&(o--,a*=2),r+=o+c>=1?_/a:_*Math.pow(2,1-c),r*a>=2&&(o++,a/=2),o+c>=f?(s=0,o=f):o+c>=1?(s=(r*a-1)*Math.pow(2,n),o+=c):(s=r*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;t[e+p]=255&s,p+=l,s/=256,n-=8);for(o=o<0;t[e+p]=255&o,p+=l,o/=256,u-=8);t[e+p-l]|=128*d}},{}],8:[function(t,r,e){var i={}.toString;r.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},{}],9:[function(t,r,e){arguments[4][4][0].apply(e,arguments)},{"./lib/uint32":10,"./lib/uint64":11,dup:4}],10:[function(t,r,e){arguments[4][5][0].apply(e,arguments)},{dup:5}],11:[function(t,r,e){arguments[4][6][0].apply(e,arguments)},{dup:6}],12:[function(t,r,e){(function(e){!function(i){function n(t){for(var r=[],e=0,i=t.length;i>e;e++){var n=t.charCodeAt(e);128>n?r.push(n):2048>n?r.push(192|n>>6,128|63&n):55296>n||n>=57344?r.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),r.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return new Uint8Array(r)}function h(){return 2==arguments.length?new h(arguments[1]).update(arguments[0]).digest():this instanceof h?void o.call(this,arguments[0]):new h(arguments[0])}function o(t){return this.seed=t instanceof s?t.clone():s(t),this.v1=this.seed.clone().add(p),this.v2=this.seed.clone().add(u),this.v3=this.seed.clone(),this.v4=this.seed.clone().subtract(a),this.total_len=0,this.memsize=0,this.memory=null,this}var s=t("cuint").UINT32;s.prototype.xxh_update=function(t,r){var e,i,n=u._low,h=u._high;i=t*n,e=i>>>16,e+=r*n,e&=65535,e+=t*h;var o=this._low+(65535&i),s=o>>>16;s+=this._high+(65535&e);var f=s<<16|65535&o;f=f<<13|f>>>19,o=65535&f,s=f>>>16,n=a._low,h=a._high,i=o*n,e=i>>>16,e+=s*n,e&=65535,e+=o*h,this._low=65535&i,this._high=65535&e};var a=s("2654435761"),u=s("2246822519"),f=s("3266489917"),c=s("668265263"),_=s("374761393"),p=a.clone().add(u);h.prototype.init=o,h.prototype.update=function(t){var r,i="string"==typeof t;i&&(t=n(t),i=!1,r=!0),"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer&&(r=!0,t=new Uint8Array(t));var h=0,o=t.length,s=h+o;if(0==o)return this;if(this.total_len+=o,0==this.memsize&&(i?this.memory="":r?this.memory=new Uint8Array(16):this.memory=new e(16)),this.memsize+o<16)return i?this.memory+=t:r?this.memory.set(t.subarray(0,o),this.memsize):t.copy(this.memory,this.memsize,0,o),this.memsize+=o,this;if(this.memsize>0){i?this.memory+=t.slice(0,16-this.memsize):r?this.memory.set(t.subarray(0,16-this.memsize),this.memsize):t.copy(this.memory,this.memsize,0,16-this.memsize);var a=0;i?(this.v1.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v2.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v3.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v4.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2))):(this.v1.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v2.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v3.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v4.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2])),h+=16-this.memsize,this.memsize=0,i&&(this.memory="")}if(s-16>=h){var u=s-16;do i?(this.v1.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v2.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v3.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v4.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2))):(this.v1.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v2.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v3.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v4.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2])),h+=4;while(u>=h)}return s>h&&(i?this.memory+=t.slice(h):r?this.memory.set(t.subarray(h,s),this.memsize):t.copy(this.memory,this.memsize,h,s),this.memsize=s-h),this},h.prototype.digest=function(){var t,r,e=this.memory,i="string"==typeof e,n=0,h=this.memsize,o=new s;for(t=this.total_len>=16?this.v1.rotl(1).add(this.v2.rotl(7).add(this.v3.rotl(12).add(this.v4.rotl(18)))):this.seed.add(_),t.add(o.fromNumber(this.total_len));h-4>=n;)i?o.fromBits(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2)):o.fromBits(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2]),t.add(o.multiply(f)).rotl(17).multiply(c),n+=4;for(;h>n;)o.fromBits(i?e.charCodeAt(n++):e[n++],0),t.add(o.multiply(_)).rotl(11).multiply(a);return r=t.clone().shiftRight(15),t.xor(r).multiply(u),r=t.clone().shiftRight(13),t.xor(r).multiply(f),r=t.clone().shiftRight(16),t.xor(r),this.init(this.seed),t},"undefined"!=typeof define&&define.amd?define([],function(){return h}):"undefined"!=typeof r&&r.exports?r.exports=h:i.XXH=h}(this)}).call(this,t("buffer").Buffer)},{buffer:"buffer",cuint:9}],buffer:[function(t,r,e){(function(r){"use strict";function i(){function t(){}try{var r=new Uint8Array(1);return r.foo=function(){return 42},r.constructor=t,42===r.foo()&&r.constructor===t&&"function"==typeof r.subarray&&0===r.subarray(1,1).byteLength}catch(e){return!1}}function n(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(t){return this instanceof h?(h.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?s(this,t,arguments.length>1?arguments[1]:"utf8"):a(this,t)):arguments.length>1?new h(t,arguments[1]):new h(t)}function o(t,r){if(t=d(t,0>r?0:0|g(r)),!h.TYPED_ARRAY_SUPPORT)for(var e=0;r>e;e++)t[e]=0;return t}function s(t,r,e){("string"!=typeof e||""===e)&&(e="utf8");var i=0|m(r,e);return t=d(t,i),t.write(r,e),t}function a(t,r){if(h.isBuffer(r))return u(t,r);if(Q(r))return f(t,r);if(null==r)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(r.buffer instanceof ArrayBuffer)return c(t,r);if(r instanceof ArrayBuffer)return _(t,r)}return r.length?p(t,r):l(t,r)}function u(t,r){var e=0|g(r.length);return t=d(t,e),r.copy(t,0,0,e),t}function f(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function c(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function _(t,r){return h.TYPED_ARRAY_SUPPORT?(r.byteLength,t=h._augment(new Uint8Array(r))):t=c(t,new Uint8Array(r)),t}function p(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function l(t,r){var e,i=0;"Buffer"===r.type&&Q(r.data)&&(e=r.data,i=0|g(e.length)),t=d(t,i);for(var n=0;i>n;n+=1)t[n]=255&e[n];return t}function d(t,r){h.TYPED_ARRAY_SUPPORT?(t=h._augment(new Uint8Array(r)),t.__proto__=h.prototype):(t.length=r,t._isBuffer=!0);var e=0!==r&&r<=h.poolSize>>>1;return e&&(t.parent=V),t}function g(t){if(t>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|t}function y(t,r){if(!(this instanceof y))return new y(t,r);var e=new h(t,r);return delete e.parent,e}function m(t,r){"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var i=!1;;)switch(r){case"ascii":case"binary":case"raw":case"raws":return e;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return H(t).length;default:if(i)return j(t).length;r=(""+r).toLowerCase(),i=!0}}function w(t,r,e){var i=!1;if(r=0|r,e=void 0===e||e===1/0?this.length:0|e,t||(t="utf8"),0>r&&(r=0),e>this.length&&(e=this.length),r>=e)return"";for(;;)switch(t){case"hex":return P(this,r,e);case"utf8":case"utf-8":return U(this,r,e);case"ascii":return T(this,r,e);case"binary":return C(this,r,e);case"base64":return R(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,r,e);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function v(t,r,e,i){e=Number(e)||0;var n=t.length-e;i?(i=Number(i),i>n&&(i=n)):i=n;var h=r.length;if(h%2!==0)throw new Error("Invalid hex string");i>h/2&&(i=h/2);for(var o=0;i>o;o++){var s=parseInt(r.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[e+o]=s}return o}function E(t,r,e,i){return Z(j(r,t.length-e),t,e,i)}function A(t,r,e,i){return Z(X(r),t,e,i)}function b(t,r,e,i){return A(t,r,e,i)}function I(t,r,e,i){return Z(H(r),t,e,i)}function B(t,r,e,i){return Z(J(r,t.length-e),t,e,i)}function R(t,r,e){return 0===r&&e===t.length?G.fromByteArray(t):G.fromByteArray(t.slice(r,e))}function U(t,r,e){e=Math.min(t.length,e);for(var i=[],n=r;e>n;){var h=t[n],o=null,s=h>239?4:h>223?3:h>191?2:1;if(e>=n+s){var a,u,f,c;switch(s){case 1:128>h&&(o=h);break;case 2:a=t[n+1],128===(192&a)&&(c=(31&h)<<6|63&a,c>127&&(o=c));break;case 3:a=t[n+1],u=t[n+2],128===(192&a)&&128===(192&u)&&(c=(15&h)<<12|(63&a)<<6|63&u,c>2047&&(55296>c||c>57343)&&(o=c));break;case 4:a=t[n+1],u=t[n+2],f=t[n+3],128===(192&a)&&128===(192&u)&&128===(192&f)&&(c=(15&h)<<18|(63&a)<<12|(63&u)<<6|63&f,c>65535&&1114112>c&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=s}return x(i)}function x(t){var r=t.length;if(W>=r)return String.fromCharCode.apply(String,t);for(var e="",i=0;r>i;)e+=String.fromCharCode.apply(String,t.slice(i,i+=W));return e}function T(t,r,e){var i="";e=Math.min(t.length,e);for(var n=r;e>n;n++)i+=String.fromCharCode(127&t[n]);return i}function C(t,r,e){var i="";e=Math.min(t.length,e);for(var n=r;e>n;n++)i+=String.fromCharCode(t[n]);return i}function P(t,r,e){var i=t.length;(!r||0>r)&&(r=0),(!e||0>e||e>i)&&(e=i);for(var n="",h=r;e>h;h++)n+=q(t[h]);return n}function L(t,r,e){for(var i=t.slice(r,e),n="",h=0;ht)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function Y(t,r,e,i,n,o){if(!h.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(r>n||o>r)throw new RangeError("value is out of bounds");if(e+i>t.length)throw new RangeError("index out of range")}function M(t,r,e,i){0>r&&(r=65535+r+1);for(var n=0,h=Math.min(t.length-e,2);h>n;n++)t[e+n]=(r&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function D(t,r,e,i){0>r&&(r=4294967295+r+1);for(var n=0,h=Math.min(t.length-e,4);h>n;n++)t[e+n]=r>>>8*(i?n:3-n)&255}function N(t,r,e,i,n,h){if(r>n||h>r)throw new RangeError("value is out of bounds");if(e+i>t.length)throw new RangeError("index out of range");if(0>e)throw new RangeError("index out of range")}function O(t,r,e,i,n){return n||N(t,r,e,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,r,e,i,23,4),e+4}function z(t,r,e,i,n){return n||N(t,r,e,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,r,e,i,52,8),e+8}function F(t){if(t=k(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function k(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return 16>t?"0"+t.toString(16):t.toString(16)}function j(t,r){r=r||1/0;for(var e,i=t.length,n=null,h=[],o=0;i>o;o++){if(e=t.charCodeAt(o),e>55295&&57344>e){if(!n){if(e>56319){(r-=3)>-1&&h.push(239,191,189);continue}if(o+1===i){(r-=3)>-1&&h.push(239,191,189);continue}n=e;continue}if(56320>e){(r-=3)>-1&&h.push(239,191,189),n=e;continue}e=(n-55296<<10|e-56320)+65536}else n&&(r-=3)>-1&&h.push(239,191,189);if(n=null,128>e){if((r-=1)<0)break;h.push(e)}else if(2048>e){if((r-=2)<0)break;h.push(e>>6|192,63&e|128)}else if(65536>e){if((r-=3)<0)break;h.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(1114112>e))throw new Error("Invalid code point");if((r-=4)<0)break;h.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return h}function X(t){for(var r=[],e=0;e>8,n=e%256,h.push(n),h.push(i);return h}function H(t){return G.toByteArray(F(t))}function Z(t,r,e,i){for(var n=0;i>n&&!(n+e>=r.length||n>=t.length);n++)r[n+e]=t[n];return n}var G=t("base64-js"),K=t("ieee754"),Q=t("isarray");e.Buffer=h,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,h.poolSize=8192;var V={};h.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:i(),h.TYPED_ARRAY_SUPPORT?(h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array):(h.prototype.length=void 0,h.prototype.parent=void 0),h.isBuffer=function(t){return!(null==t||!t._isBuffer)},h.compare=function(t,r){if(!h.isBuffer(t)||!h.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,i=r.length,n=0,o=Math.min(e,i);o>n&&t[n]===r[n];)++n;return n!==o&&(e=t[n],i=r[n]),i>e?-1:e>i?1:0},h.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(t,r){if(!Q(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new h(0);var e;if(void 0===r)for(r=0,e=0;e0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},h.prototype.compare=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:h.compare(this,t)},h.prototype.indexOf=function(t,r){function e(t,r,e){for(var i=-1,n=0;e+n2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),r>>=0,0===this.length)return-1;if(r>=this.length)return-1;if(0>r&&(r=Math.max(this.length+r,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,r);if(h.isBuffer(t))return e(this,t,r);if("number"==typeof t)return h.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,r):e(this,[t],r);throw new TypeError("val must be string, number or Buffer")},h.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},h.prototype.set=function(t,r){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,r)},h.prototype.write=function(t,r,e,i){if(void 0===r)i="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)i=r,e=this.length,r=0;else if(isFinite(r))r=0|r,isFinite(e)?(e=0|e,void 0===i&&(i="utf8")):(i=e,e=void 0);else{var n=i;i=r,r=0|e,e=n}var h=this.length-r;if((void 0===e||e>h)&&(e=h),t.length>0&&(0>e||0>r)||r>this.length)throw new RangeError("attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return E(this,t,r,e);case"ascii":return A(this,t,r,e);case"binary":return b(this,t,r,e);case"base64":return I(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r,e);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var W=4096;h.prototype.slice=function(t,r){var e=this.length;t=~~t,r=void 0===r?e:~~r,0>t?(t+=e,0>t&&(t=0)):t>e&&(t=e),0>r?(r+=e,0>r&&(r=0)):r>e&&(r=e),t>r&&(r=t);var i;if(h.TYPED_ARRAY_SUPPORT)i=h._augment(this.subarray(t,r));else{var n=r-t;i=new h(n,void 0);for(var o=0;n>o;o++)i[o]=this[o+t]}return i.length&&(i.parent=this.parent||this),i},h.prototype.readUIntLE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=this[t],n=1,h=0;++h0&&(n*=256);)i+=this[t+--r]*n;return i},h.prototype.readUInt8=function(t,r){return r||S(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,r){return r||S(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,r){return r||S(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,r){return r||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,r){return r||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=this[t],n=1,h=0;++h=n&&(i-=Math.pow(2,8*r)),i},h.prototype.readIntBE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=r,n=1,h=this[t+--i];i>0&&(n*=256);)h+=this[t+--i]*n;return n*=128,h>=n&&(h-=Math.pow(2,8*r)),h},h.prototype.readInt8=function(t,r){return r||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,r){r||S(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},h.prototype.readInt16BE=function(t,r){r||S(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},h.prototype.readInt32LE=function(t,r){return r||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,r){ -return r||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,r){return r||S(t,4,this.length),K.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,r){return r||S(t,4,this.length),K.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,r){return r||S(t,8,this.length),K.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,r){return r||S(t,8,this.length),K.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,r,e,i){t=+t,r=0|r,e=0|e,i||Y(this,t,r,e,Math.pow(2,8*e),0);var n=1,h=0;for(this[r]=255&t;++h=0&&(h*=256);)this[r+n]=t/h&255;return r+e},h.prototype.writeUInt8=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},h.prototype.writeUInt16LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},h.prototype.writeUInt16BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},h.prototype.writeUInt32LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):D(this,t,r,!0),r+4},h.prototype.writeUInt32BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):D(this,t,r,!1),r+4},h.prototype.writeIntLE=function(t,r,e,i){if(t=+t,r=0|r,!i){var n=Math.pow(2,8*e-1);Y(this,t,r,e,n-1,-n)}var h=0,o=1,s=0>t?1:0;for(this[r]=255&t;++h>0)-s&255;return r+e},h.prototype.writeIntBE=function(t,r,e,i){if(t=+t,r=0|r,!i){var n=Math.pow(2,8*e-1);Y(this,t,r,e,n-1,-n)}var h=e-1,o=1,s=0>t?1:0;for(this[r+h]=255&t;--h>=0&&(o*=256);)this[r+h]=(t/o>>0)-s&255;return r+e},h.prototype.writeInt8=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[r]=255&t,r+1},h.prototype.writeInt16LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},h.prototype.writeInt16BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},h.prototype.writeInt32LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):D(this,t,r,!0),r+4},h.prototype.writeInt32BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):D(this,t,r,!1),r+4},h.prototype.writeFloatLE=function(t,r,e){return O(this,t,r,!0,e)},h.prototype.writeFloatBE=function(t,r,e){return O(this,t,r,!1,e)},h.prototype.writeDoubleLE=function(t,r,e){return z(this,t,r,!0,e)},h.prototype.writeDoubleBE=function(t,r,e){return z(this,t,r,!1,e)},h.prototype.copy=function(t,r,e,i){if(e||(e=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&e>i&&(i=e),i===e)return 0;if(0===t.length||0===this.length)return 0;if(0>r)throw new RangeError("targetStart out of bounds");if(0>e||e>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-re&&i>r)for(n=o-1;n>=0;n--)t[n+r]=this[n+e];else if(1e3>o||!h.TYPED_ARRAY_SUPPORT)for(n=0;o>n;n++)t[n+r]=this[n+e];else t._set(this.subarray(e,e+o),r);return o},h.prototype.fill=function(t,r,e){if(t||(t=0),r||(r=0),e||(e=this.length),r>e)throw new RangeError("end < start");if(e!==r&&0!==this.length){if(0>r||r>=this.length)throw new RangeError("start out of bounds");if(0>e||e>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof t)for(i=r;e>i;i++)this[i]=t;else{var n=j(t.toString()),h=n.length;for(i=r;e>i;i++)this[i]=n[i%h]}return this}},h.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(h.TYPED_ARRAY_SUPPORT)return new h(this).buffer;for(var t=new Uint8Array(this.length),r=0,e=t.length;e>r;r+=1)t[r]=this[r];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var $=h.prototype;h._augment=function(t){return t.constructor=h,t._isBuffer=!0,t._set=t.set,t.get=$.get,t.set=$.set,t.write=$.write,t.toString=$.toString,t.toLocaleString=$.toString,t.toJSON=$.toJSON,t.equals=$.equals,t.compare=$.compare,t.indexOf=$.indexOf,t.copy=$.copy,t.slice=$.slice,t.readUIntLE=$.readUIntLE,t.readUIntBE=$.readUIntBE,t.readUInt8=$.readUInt8,t.readUInt16LE=$.readUInt16LE,t.readUInt16BE=$.readUInt16BE,t.readUInt32LE=$.readUInt32LE,t.readUInt32BE=$.readUInt32BE,t.readIntLE=$.readIntLE,t.readIntBE=$.readIntBE,t.readInt8=$.readInt8,t.readInt16LE=$.readInt16LE,t.readInt16BE=$.readInt16BE,t.readInt32LE=$.readInt32LE,t.readInt32BE=$.readInt32BE,t.readFloatLE=$.readFloatLE,t.readFloatBE=$.readFloatBE,t.readDoubleLE=$.readDoubleLE,t.readDoubleBE=$.readDoubleBE,t.writeUInt8=$.writeUInt8,t.writeUIntLE=$.writeUIntLE,t.writeUIntBE=$.writeUIntBE,t.writeUInt16LE=$.writeUInt16LE,t.writeUInt16BE=$.writeUInt16BE,t.writeUInt32LE=$.writeUInt32LE,t.writeUInt32BE=$.writeUInt32BE,t.writeIntLE=$.writeIntLE,t.writeIntBE=$.writeIntBE,t.writeInt8=$.writeInt8,t.writeInt16LE=$.writeInt16LE,t.writeInt16BE=$.writeInt16BE,t.writeInt32LE=$.writeInt32LE,t.writeInt32BE=$.writeInt32BE,t.writeFloatLE=$.writeFloatLE,t.writeFloatBE=$.writeFloatBE,t.writeDoubleLE=$.writeDoubleLE,t.writeDoubleBE=$.writeDoubleBE,t.fill=$.fill,t.inspect=$.inspect,t.toArrayBuffer=$.toArrayBuffer,t};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":3,ieee754:7,isarray:8}]},{},[2]); +require=function t(r,e,i){function n(o,s){if(!e[o]){if(!r[o]){var a="function"==typeof require&&require;if(!s&&a)return a(o,!0);if(h)return h(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=e[o]={exports:{}};r[o][0].call(f.exports,function(t){var e=r[o][1][t];return n(e?e:t)},f,f.exports,t,r,e,i)}return e[o].exports}for(var h="function"==typeof require&&require,o=0;o>8&255},e.blockChecksum=function(t){return i(t,n).toNumber()},e.streamChecksum=function(t,r){return null===t?r.digest().toNumber():(null===r&&(r=i(n)),r.update(t))},e.readUInt32LE=function(t,r){return t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24},e.bindings=t("./binding")},{"./binding":1,xxhashjs:12}],1:[function(t,r,e){function i(t,r,i,o,a,u){var l=a,y=u-a,m=0;if(t.length>=n)throw new Error("input too large");if(t.length>f){var w=e.compressBound(t.length);if(w>y)throw Error("output too small: "+y+" < "+w);for(var v=1,E=(1<i+h;){var b=t[i+1]<<8|t[i],I=t[i+3]<<8|t[i+2],B=Math.imul(b|I<<16,g)>>>s,R=o[B]-1;if(o[B]=i+1,0>R||i-R>>>16>0||(t[R+3]<<8|t[R+2])!=I||(t[R+1]<<8|t[R])!=b)v=E++>>c,i+=v;else{E=(1<i&&t[i]==t[R];)i++,R++;T=i-T;var C=p>T?T:p;if(U>=d){r[l++]=(d<<_)+C;for(var P=U-d;P>254;P-=255)r[l++]=255;r[l++]=P}else r[l++]=(U<<_)+C;for(var L=0;U>L;L++)r[l++]=t[m+L];if(r[l++]=x,r[l++]=x>>8,T>=p){for(T-=p;T>=255;)T-=255,r[l++]=255;r[l++]=T}m=i}}}if(0==m)return 0;if(U=t.length-m,U>=d){r[l++]=d<<_;for(var S=U-d;S>254;S-=255)r[l++]=255;r[l++]=S}else r[l++]=U<<_;for(i=m;i>>16,i=65535&t,n=r>>>16,h=65535&r;return i*h+(e*h+i*n<<16)|0}),e.uncompress=function(t,r,e,i){e=e||0,i=i||t.length-e;for(var n=e,h=i,o=0;h>n;){var s=t[n++],a=s>>4;if(a>0){for(var u=a+240;255===u;)u=t[n++],a+=u;for(var f=n+a;f>n;)r[o++]=t[n++];if(n===h)return o}var c=t[n++]|t[n++]<<8;if(0===c||c>o)return-(n-2);for(var _=15&s,u=_+240;255===u;)u=t[n++],_+=u;for(var p=o-c,f=o+_+4;f>o;)r[o++]=r[p++]}return o};var n=2113929216,h=4,o=16,s=8*h-o,a=1<n?0:t+t/255+16|0},e.compress=function(t,r,e,n){for(var h=new Array(a),o=0;a>o;o++)h[o]=0;return i(t,r,0,h,e||0,n||r.length)},e.compressHC=e.compress,e.compressDependent=i},{cuint:5}],2:[function(t,r,e){},{}],3:[function(t,r,e){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function r(t){var r=t.charCodeAt(0);return r===o||r===c?62:r===s||r===_?63:a>r?-1:a+10>r?r-a+26+26:f+26>r?r-f:u+26>r?r-u+26:void 0}function e(t){function e(t){u[c++]=t}var i,n,o,s,a,u;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;a="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,u=new h(3*t.length/4-a),o=a>0?t.length-4:t.length;var c=0;for(i=0,n=0;o>i;i+=4,n+=3)s=r(t.charAt(i))<<18|r(t.charAt(i+1))<<12|r(t.charAt(i+2))<<6|r(t.charAt(i+3)),e((16711680&s)>>16),e((65280&s)>>8),e(255&s);return 2===a?(s=r(t.charAt(i))<<2|r(t.charAt(i+1))>>4,e(255&s)):1===a&&(s=r(t.charAt(i))<<10|r(t.charAt(i+1))<<4|r(t.charAt(i+2))>>2,e(s>>8&255),e(255&s)),u}function n(t){function r(t){return i.charAt(t)}function e(t){return r(t>>18&63)+r(t>>12&63)+r(t>>6&63)+r(63&t)}var n,h,o,s=t.length%3,a="";for(n=0,o=t.length-s;o>n;n+=3)h=(t[n]<<16)+(t[n+1]<<8)+t[n+2],a+=e(h);switch(s){case 1:h=t[t.length-1],a+=r(h>>2),a+=r(h<<4&63),a+="==";break;case 2:h=(t[t.length-2]<<8)+t[t.length-1],a+=r(h>>10),a+=r(h>>4&63),a+=r(h<<2&63),a+="="}return a}var h="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),s="/".charCodeAt(0),a="0".charCodeAt(0),u="a".charCodeAt(0),f="A".charCodeAt(0),c="-".charCodeAt(0),_="_".charCodeAt(0);t.toByteArray=e,t.fromByteArray=n}("undefined"==typeof e?this.base64js={}:e)},{}],4:[function(t,r,e){var i={}.toString;r.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},{}],5:[function(t,r,e){e.UINT32=t("./lib/uint32"),e.UINT64=t("./lib/uint64")},{"./lib/uint32":6,"./lib/uint64":7}],6:[function(t,r,e){!function(t){function e(t,r){return this instanceof e?(this._low=0,this._high=0,this.remainder=null,"undefined"==typeof r?n.call(this,t):"string"==typeof t?h.call(this,t,r):void i.call(this,t,r)):new e(t,r)}function i(t,r){return this._low=0|t,this._high=0|r,this}function n(t){return this._low=65535&t,this._high=t>>>16,this}function h(t,r){var e=parseInt(t,r||10);return this._low=65535&e,this._high=e>>>16,this}({36:e(Math.pow(36,5)),16:e(Math.pow(16,7)),10:e(Math.pow(10,9)),2:e(Math.pow(2,30))}),{36:e(36),16:e(16),10:e(10),2:e(2)};e.prototype.fromBits=i,e.prototype.fromNumber=n,e.prototype.fromString=h,e.prototype.toNumber=function(){return 65536*this._high+this._low},e.prototype.toString=function(t){return this.toNumber().toString(t||10)},e.prototype.add=function(t){var r=this._low+t._low,e=r>>>16;return e+=this._high+t._high,this._low=65535&r,this._high=65535&e,this},e.prototype.subtract=function(t){return this.add(t.clone().negate())},e.prototype.multiply=function(t){var r,e,i=this._high,n=this._low,h=t._high,o=t._low;return e=n*o,r=e>>>16,r+=i*o,r&=65535,r+=n*h,this._low=65535&e,this._high=65535&r,this},e.prototype.div=function(t){if(0==t._low&&0==t._high)throw Error("division by zero");if(0==t._high&&1==t._low)return this.remainder=new e(0),this;if(t.gt(this))return this.remainder=this.clone(),this._low=0,this._high=0,this;if(this.eq(t))return this.remainder=new e(0),this._low=1,this._high=0,this;for(var r=t.clone(),i=-1;!this.lt(r);)r.shiftLeft(1,!0),i++;for(this.remainder=this.clone(),this._low=0,this._high=0;i>=0;i--)r.shiftRight(1),this.remainder.lt(r)||(this.remainder.subtract(r),i>=16?this._high|=1<>>16)&65535,this},e.prototype.equals=e.prototype.eq=function(t){return this._low==t._low&&this._high==t._high},e.prototype.greaterThan=e.prototype.gt=function(t){return this._high>t._high?!0:this._hight._low},e.prototype.lessThan=e.prototype.lt=function(t){return this._hight._high?!1:this._low16?(this._low=this._high>>t-16,this._high=0):16==t?(this._low=this._high,this._high=0):(this._low=this._low>>t|this._high<<16-t&65535,this._high>>=t),this},e.prototype.shiftLeft=e.prototype.shiftl=function(t,r){return t>16?(this._high=this._low<>16-t,this._low=this._low<>>32-t,this._low=65535&r,this._high=r>>>16,this},e.prototype.rotateRight=e.prototype.rotr=function(t){var r=this._high<<16|this._low;return r=r>>>t|r<<32-t,this._low=65535&r,this._high=r>>>16,this},e.prototype.clone=function(){return new e(this._low,this._high)},"undefined"!=typeof define&&define.amd?define([],function(){return e}):"undefined"!=typeof r&&r.exports?r.exports=e:t.UINT32=e}(this)},{}],7:[function(t,r,e){!function(t){function e(t,r,o,s){return this instanceof e?(this.remainder=null,"string"==typeof t?h.call(this,t,r):"undefined"==typeof r?n.call(this,t):void i.apply(this,arguments)):new e(t,r,o,s)}function i(t,r,e,i){return"undefined"==typeof e?(this._a00=65535&t,this._a16=t>>>16,this._a32=65535&r,this._a48=r>>>16,this):(this._a00=0|t,this._a16=0|r,this._a32=0|e,this._a48=0|i,this)}function n(t){return this._a00=65535&t,this._a16=t>>>16,this._a32=0,this._a48=0,this}function h(t,r){r=r||10,this._a00=0,this._a16=0,this._a32=0,this._a48=0;for(var i=o[r]||new e(Math.pow(r,5)),n=0,h=t.length;h>n;n+=5){var s=Math.min(5,h-n),a=parseInt(t.slice(n,n+s),r);this.multiply(5>s?new e(Math.pow(r,s)):i).add(new e(a))}return this}var o={16:e(Math.pow(16,5)),10:e(Math.pow(10,5)),2:e(Math.pow(2,5))},s={16:e(16),10:e(10),2:e(2)};e.prototype.fromBits=i,e.prototype.fromNumber=n,e.prototype.fromString=h,e.prototype.toNumber=function(){return 65536*this._a16+this._a00},e.prototype.toString=function(t){t=t||10;var r=s[t]||new e(t);if(!this.gt(r))return this.toNumber().toString(t);for(var i=this.clone(),n=new Array(64),h=63;h>=0&&(i.div(r),n[h]=i.remainder.toNumber().toString(t),i.gt(r));h--);return n[h-1]=i.toNumber().toString(t),n.join("")},e.prototype.add=function(t){var r=this._a00+t._a00,e=r>>>16;e+=this._a16+t._a16;var i=e>>>16;i+=this._a32+t._a32;var n=i>>>16;return n+=this._a48+t._a48,this._a00=65535&r,this._a16=65535&e,this._a32=65535&i,this._a48=65535&n,this},e.prototype.subtract=function(t){return this.add(t.clone().negate())},e.prototype.multiply=function(t){var r=this._a00,e=this._a16,i=this._a32,n=this._a48,h=t._a00,o=t._a16,s=t._a32,a=t._a48,u=r*h,f=u>>>16;f+=r*o;var c=f>>>16;f&=65535,f+=e*h,c+=f>>>16,c+=r*s;var _=c>>>16;return c&=65535,c+=e*o,_+=c>>>16,c&=65535,c+=i*h,_+=c>>>16,_+=r*a,_&=65535,_+=e*s,_&=65535,_+=i*o,_&=65535,_+=n*h,this._a00=65535&u,this._a16=65535&f,this._a32=65535&c,this._a48=65535&_,this},e.prototype.div=function(t){if(0==t._a16&&0==t._a32&&0==t._a48){if(0==t._a00)throw Error("division by zero");if(1==t._a00)return this.remainder=new e(0),this}if(t.gt(this))return this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0,this;if(this.eq(t))return this.remainder=new e(0),this._a00=1,this._a16=0,this._a32=0,this._a48=0,this;for(var r=t.clone(),i=-1;!this.lt(r);)r.shiftLeft(1,!0),i++;for(this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0;i>=0;i--)r.shiftRight(1),this.remainder.lt(r)||(this.remainder.subtract(r),i>=48?this._a48|=1<=32?this._a32|=1<=16?this._a16|=1<>>16),this._a16=65535&t,t=(65535&~this._a32)+(t>>>16),this._a32=65535&t,this._a48=~this._a48+(t>>>16)&65535,this},e.prototype.equals=e.prototype.eq=function(t){return this._a48==t._a48&&this._a00==t._a00&&this._a32==t._a32&&this._a16==t._a16},e.prototype.greaterThan=e.prototype.gt=function(t){return this._a48>t._a48?!0:this._a48t._a32?!0:this._a32t._a16?!0:this._a16t._a00},e.prototype.lessThan=e.prototype.lt=function(t){return this._a48t._a48?!1:this._a32t._a32?!1:this._a16t._a16?!1:this._a00=48?(this._a00=this._a48>>t-48,this._a16=0,this._a32=0,this._a48=0):t>=32?(t-=32,this._a00=65535&(this._a32>>t|this._a48<<16-t),this._a16=this._a48>>t&65535,this._a32=0,this._a48=0):t>=16?(t-=16,this._a00=65535&(this._a16>>t|this._a32<<16-t),this._a16=65535&(this._a32>>t|this._a48<<16-t),this._a32=this._a48>>t&65535,this._a48=0):(this._a00=65535&(this._a00>>t|this._a16<<16-t),this._a16=65535&(this._a16>>t|this._a32<<16-t),this._a32=65535&(this._a32>>t|this._a48<<16-t),this._a48=this._a48>>t&65535),this},e.prototype.shiftLeft=e.prototype.shiftl=function(t,r){return t%=64,t>=48?(this._a48=this._a00<=32?(t-=32,this._a48=this._a16<>16-t,this._a32=this._a00<=16?(t-=16,this._a48=this._a32<>16-t,this._a32=65535&(this._a16<>16-t),this._a16=this._a00<>16-t,this._a32=65535&(this._a32<>16-t),this._a16=65535&(this._a16<>16-t),this._a00=this._a00<=32){var r=this._a00;if(this._a00=this._a32,this._a32=r,r=this._a48,this._a48=this._a16,this._a16=r,32==t)return this;t-=32}var e=this._a48<<16|this._a32,i=this._a16<<16|this._a00,n=e<>>32-t,h=i<>>32-t;return this._a00=65535&h,this._a16=h>>>16,this._a32=65535&n,this._a48=n>>>16,this},e.prototype.rotateRight=e.prototype.rotr=function(t){if(t%=64,0==t)return this;if(t>=32){var r=this._a00;if(this._a00=this._a32,this._a32=r,r=this._a48,this._a48=this._a16,this._a16=r,32==t)return this;t-=32}var e=this._a48<<16|this._a32,i=this._a16<<16|this._a00,n=e>>>t|i<<32-t,h=i>>>t|e<<32-t;return this._a00=65535&h,this._a16=h>>>16,this._a32=65535&n,this._a48=n>>>16,this},e.prototype.clone=function(){return new e(this._a00,this._a16,this._a32,this._a48)},"undefined"!=typeof define&&define.amd?define([],function(){return e}):"undefined"!=typeof r&&r.exports?r.exports=e:t.UINT64=e}(this)},{}],8:[function(t,r,e){e.read=function(t,r,e,i,n){var h,o,s=8*n-i-1,a=(1<>1,f=-7,c=e?n-1:0,_=e?-1:1,p=t[r+c];for(c+=_,h=p&(1<<-f)-1,p>>=-f,f+=s;f>0;h=256*h+t[r+c],c+=_,f-=8);for(o=h&(1<<-f)-1,h>>=-f,f+=i;f>0;o=256*o+t[r+c],c+=_,f-=8);if(0===h)h=1-u;else{if(h===a)return o?NaN:(p?-1:1)*(1/0);o+=Math.pow(2,i),h-=u}return(p?-1:1)*o*Math.pow(2,h-i)},e.write=function(t,r,e,i,n,h){var o,s,a,u=8*h-n-1,f=(1<>1,_=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:h-1,l=i?1:-1,d=0>r||0===r&&0>1/r?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,o=f):(o=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-o))<1&&(o--,a*=2),r+=o+c>=1?_/a:_*Math.pow(2,1-c),r*a>=2&&(o++,a/=2),o+c>=f?(s=0,o=f):o+c>=1?(s=(r*a-1)*Math.pow(2,n),o+=c):(s=r*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;t[e+p]=255&s,p+=l,s/=256,n-=8);for(o=o<0;t[e+p]=255&o,p+=l,o/=256,u-=8);t[e+p-l]|=128*d}},{}],9:[function(t,r,e){arguments[4][5][0].apply(e,arguments)},{"./lib/uint32":10,"./lib/uint64":11,dup:5}],10:[function(t,r,e){arguments[4][6][0].apply(e,arguments)},{dup:6}],11:[function(t,r,e){arguments[4][7][0].apply(e,arguments)},{dup:7}],12:[function(t,r,e){(function(e){!function(i){function n(t){for(var r=[],e=0,i=t.length;i>e;e++){var n=t.charCodeAt(e);128>n?r.push(n):2048>n?r.push(192|n>>6,128|63&n):55296>n||n>=57344?r.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),r.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return new Uint8Array(r)}function h(){return 2==arguments.length?new h(arguments[1]).update(arguments[0]).digest():this instanceof h?void o.call(this,arguments[0]):new h(arguments[0])}function o(t){return this.seed=t instanceof s?t.clone():s(t),this.v1=this.seed.clone().add(p),this.v2=this.seed.clone().add(u),this.v3=this.seed.clone(),this.v4=this.seed.clone().subtract(a),this.total_len=0,this.memsize=0,this.memory=null,this}var s=t("cuint").UINT32;s.prototype.xxh_update=function(t,r){var e,i,n=u._low,h=u._high;i=t*n,e=i>>>16,e+=r*n,e&=65535,e+=t*h;var o=this._low+(65535&i),s=o>>>16;s+=this._high+(65535&e);var f=s<<16|65535&o;f=f<<13|f>>>19,o=65535&f,s=f>>>16,n=a._low,h=a._high,i=o*n,e=i>>>16,e+=s*n,e&=65535,e+=o*h,this._low=65535&i,this._high=65535&e};var a=s("2654435761"),u=s("2246822519"),f=s("3266489917"),c=s("668265263"),_=s("374761393"),p=a.clone().add(u);h.prototype.init=o,h.prototype.update=function(t){var r,i="string"==typeof t;i&&(t=n(t),i=!1,r=!0),"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer&&(r=!0,t=new Uint8Array(t));var h=0,o=t.length,s=h+o;if(0==o)return this;if(this.total_len+=o,0==this.memsize&&(i?this.memory="":r?this.memory=new Uint8Array(16):this.memory=new e(16)),this.memsize+o<16)return i?this.memory+=t:r?this.memory.set(t.subarray(0,o),this.memsize):t.copy(this.memory,this.memsize,0,o),this.memsize+=o,this;if(this.memsize>0){i?this.memory+=t.slice(0,16-this.memsize):r?this.memory.set(t.subarray(0,16-this.memsize),this.memsize):t.copy(this.memory,this.memsize,0,16-this.memsize);var a=0;i?(this.v1.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v2.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v3.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v4.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2))):(this.v1.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v2.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v3.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v4.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2])),h+=16-this.memsize,this.memsize=0,i&&(this.memory="")}if(s-16>=h){var u=s-16;do i?(this.v1.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v2.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v3.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v4.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2))):(this.v1.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v2.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v3.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v4.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2])),h+=4;while(u>=h)}return s>h&&(i?this.memory+=t.slice(h):r?this.memory.set(t.subarray(h,s),this.memsize):t.copy(this.memory,this.memsize,h,s),this.memsize=s-h),this},h.prototype.digest=function(){var t,r,e=this.memory,i="string"==typeof e,n=0,h=this.memsize,o=new s;for(t=this.total_len>=16?this.v1.rotl(1).add(this.v2.rotl(7).add(this.v3.rotl(12).add(this.v4.rotl(18)))):this.seed.add(_),t.add(o.fromNumber(this.total_len));h-4>=n;)i?o.fromBits(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2)):o.fromBits(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2]),t.add(o.multiply(f)).rotl(17).multiply(c),n+=4;for(;h>n;)o.fromBits(i?e.charCodeAt(n++):e[n++],0),t.add(o.multiply(_)).rotl(11).multiply(a);return r=t.clone().shiftRight(15),t.xor(r).multiply(u),r=t.clone().shiftRight(13),t.xor(r).multiply(f),r=t.clone().shiftRight(16),t.xor(r),this.init(this.seed),t},"undefined"!=typeof define&&define.amd?define([],function(){return h}):"undefined"!=typeof r&&r.exports?r.exports=h:i.XXH=h}(this)}).call(this,t("buffer").Buffer)},{buffer:"buffer",cuint:9}],buffer:[function(t,r,e){(function(r){"use strict";function i(){function t(){}try{var r=new Uint8Array(1);return r.foo=function(){return 42},r.constructor=t,42===r.foo()&&r.constructor===t&&"function"==typeof r.subarray&&0===r.subarray(1,1).byteLength}catch(e){return!1}}function n(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(t){return this instanceof h?(h.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?s(this,t,arguments.length>1?arguments[1]:"utf8"):a(this,t)):arguments.length>1?new h(t,arguments[1]):new h(t)}function o(t,r){if(t=d(t,0>r?0:0|g(r)),!h.TYPED_ARRAY_SUPPORT)for(var e=0;r>e;e++)t[e]=0;return t}function s(t,r,e){("string"!=typeof e||""===e)&&(e="utf8");var i=0|m(r,e);return t=d(t,i),t.write(r,e),t}function a(t,r){if(h.isBuffer(r))return u(t,r);if(Q(r))return f(t,r);if(null==r)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(r.buffer instanceof ArrayBuffer)return c(t,r);if(r instanceof ArrayBuffer)return _(t,r)}return r.length?p(t,r):l(t,r)}function u(t,r){var e=0|g(r.length);return t=d(t,e),r.copy(t,0,0,e),t}function f(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function c(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function _(t,r){return h.TYPED_ARRAY_SUPPORT?(r.byteLength,t=h._augment(new Uint8Array(r))):t=c(t,new Uint8Array(r)),t}function p(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function l(t,r){var e,i=0;"Buffer"===r.type&&Q(r.data)&&(e=r.data,i=0|g(e.length)),t=d(t,i);for(var n=0;i>n;n+=1)t[n]=255&e[n];return t}function d(t,r){h.TYPED_ARRAY_SUPPORT?(t=h._augment(new Uint8Array(r)),t.__proto__=h.prototype):(t.length=r,t._isBuffer=!0);var e=0!==r&&r<=h.poolSize>>>1;return e&&(t.parent=V),t}function g(t){if(t>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|t}function y(t,r){if(!(this instanceof y))return new y(t,r);var e=new h(t,r);return delete e.parent,e}function m(t,r){"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var i=!1;;)switch(r){case"ascii":case"binary":case"raw":case"raws":return e;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return H(t).length;default:if(i)return j(t).length;r=(""+r).toLowerCase(),i=!0}}function w(t,r,e){var i=!1;if(r=0|r,e=void 0===e||e===1/0?this.length:0|e,t||(t="utf8"),0>r&&(r=0),e>this.length&&(e=this.length),r>=e)return"";for(;;)switch(t){case"hex":return P(this,r,e);case"utf8":case"utf-8":return U(this,r,e);case"ascii":return T(this,r,e);case"binary":return C(this,r,e);case"base64":return R(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,r,e);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function v(t,r,e,i){e=Number(e)||0;var n=t.length-e;i?(i=Number(i),i>n&&(i=n)):i=n;var h=r.length;if(h%2!==0)throw new Error("Invalid hex string");i>h/2&&(i=h/2);for(var o=0;i>o;o++){var s=parseInt(r.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[e+o]=s}return o}function E(t,r,e,i){return Z(j(r,t.length-e),t,e,i)}function A(t,r,e,i){return Z(X(r),t,e,i)}function b(t,r,e,i){return A(t,r,e,i)}function I(t,r,e,i){return Z(H(r),t,e,i)}function B(t,r,e,i){return Z(J(r,t.length-e),t,e,i)}function R(t,r,e){return 0===r&&e===t.length?G.fromByteArray(t):G.fromByteArray(t.slice(r,e))}function U(t,r,e){e=Math.min(t.length,e);for(var i=[],n=r;e>n;){var h=t[n],o=null,s=h>239?4:h>223?3:h>191?2:1;if(e>=n+s){var a,u,f,c;switch(s){case 1:128>h&&(o=h);break;case 2:a=t[n+1],128===(192&a)&&(c=(31&h)<<6|63&a,c>127&&(o=c));break;case 3:a=t[n+1],u=t[n+2],128===(192&a)&&128===(192&u)&&(c=(15&h)<<12|(63&a)<<6|63&u,c>2047&&(55296>c||c>57343)&&(o=c));break;case 4:a=t[n+1],u=t[n+2],f=t[n+3],128===(192&a)&&128===(192&u)&&128===(192&f)&&(c=(15&h)<<18|(63&a)<<12|(63&u)<<6|63&f,c>65535&&1114112>c&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=s}return x(i)}function x(t){var r=t.length;if(W>=r)return String.fromCharCode.apply(String,t);for(var e="",i=0;r>i;)e+=String.fromCharCode.apply(String,t.slice(i,i+=W));return e}function T(t,r,e){var i="";e=Math.min(t.length,e);for(var n=r;e>n;n++)i+=String.fromCharCode(127&t[n]);return i}function C(t,r,e){var i="";e=Math.min(t.length,e);for(var n=r;e>n;n++)i+=String.fromCharCode(t[n]);return i}function P(t,r,e){var i=t.length;(!r||0>r)&&(r=0),(!e||0>e||e>i)&&(e=i);for(var n="",h=r;e>h;h++)n+=q(t[h]);return n}function L(t,r,e){for(var i=t.slice(r,e),n="",h=0;ht)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function Y(t,r,e,i,n,o){if(!h.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(r>n||o>r)throw new RangeError("value is out of bounds");if(e+i>t.length)throw new RangeError("index out of range")}function M(t,r,e,i){0>r&&(r=65535+r+1);for(var n=0,h=Math.min(t.length-e,2);h>n;n++)t[e+n]=(r&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function D(t,r,e,i){0>r&&(r=4294967295+r+1);for(var n=0,h=Math.min(t.length-e,4);h>n;n++)t[e+n]=r>>>8*(i?n:3-n)&255}function N(t,r,e,i,n,h){if(r>n||h>r)throw new RangeError("value is out of bounds");if(e+i>t.length)throw new RangeError("index out of range");if(0>e)throw new RangeError("index out of range")}function O(t,r,e,i,n){return n||N(t,r,e,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,r,e,i,23,4),e+4}function z(t,r,e,i,n){return n||N(t,r,e,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,r,e,i,52,8),e+8}function F(t){if(t=k(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function k(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return 16>t?"0"+t.toString(16):t.toString(16)}function j(t,r){r=r||1/0;for(var e,i=t.length,n=null,h=[],o=0;i>o;o++){if(e=t.charCodeAt(o),e>55295&&57344>e){if(!n){if(e>56319){(r-=3)>-1&&h.push(239,191,189);continue}if(o+1===i){(r-=3)>-1&&h.push(239,191,189);continue}n=e;continue}if(56320>e){(r-=3)>-1&&h.push(239,191,189),n=e;continue}e=(n-55296<<10|e-56320)+65536}else n&&(r-=3)>-1&&h.push(239,191,189);if(n=null,128>e){if((r-=1)<0)break;h.push(e)}else if(2048>e){if((r-=2)<0)break;h.push(e>>6|192,63&e|128)}else if(65536>e){if((r-=3)<0)break;h.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(1114112>e))throw new Error("Invalid code point");if((r-=4)<0)break;h.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return h}function X(t){for(var r=[],e=0;e>8,n=e%256,h.push(n),h.push(i);return h}function H(t){return G.toByteArray(F(t))}function Z(t,r,e,i){for(var n=0;i>n&&!(n+e>=r.length||n>=t.length);n++)r[n+e]=t[n];return n}var G=t("base64-js"),K=t("ieee754"),Q=t("isarray");e.Buffer=h,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,h.poolSize=8192;var V={};h.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:i(),h.TYPED_ARRAY_SUPPORT?(h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array):(h.prototype.length=void 0,h.prototype.parent=void 0),h.isBuffer=function(t){return!(null==t||!t._isBuffer)},h.compare=function(t,r){if(!h.isBuffer(t)||!h.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,i=r.length,n=0,o=Math.min(e,i);o>n&&t[n]===r[n];)++n;return n!==o&&(e=t[n],i=r[n]),i>e?-1:e>i?1:0},h.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(t,r){if(!Q(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new h(0);var e;if(void 0===r)for(r=0,e=0;e0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},h.prototype.compare=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:h.compare(this,t)},h.prototype.indexOf=function(t,r){function e(t,r,e){for(var i=-1,n=0;e+n2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),r>>=0,0===this.length)return-1;if(r>=this.length)return-1;if(0>r&&(r=Math.max(this.length+r,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,r);if(h.isBuffer(t))return e(this,t,r);if("number"==typeof t)return h.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,r):e(this,[t],r);throw new TypeError("val must be string, number or Buffer")},h.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},h.prototype.set=function(t,r){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,r)},h.prototype.write=function(t,r,e,i){if(void 0===r)i="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)i=r,e=this.length,r=0;else if(isFinite(r))r=0|r,isFinite(e)?(e=0|e,void 0===i&&(i="utf8")):(i=e,e=void 0);else{var n=i;i=r,r=0|e,e=n}var h=this.length-r;if((void 0===e||e>h)&&(e=h),t.length>0&&(0>e||0>r)||r>this.length)throw new RangeError("attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return E(this,t,r,e);case"ascii":return A(this,t,r,e);case"binary":return b(this,t,r,e);case"base64":return I(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r,e);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var W=4096;h.prototype.slice=function(t,r){var e=this.length;t=~~t,r=void 0===r?e:~~r,0>t?(t+=e,0>t&&(t=0)):t>e&&(t=e),0>r?(r+=e,0>r&&(r=0)):r>e&&(r=e),t>r&&(r=t);var i;if(h.TYPED_ARRAY_SUPPORT)i=h._augment(this.subarray(t,r));else{var n=r-t;i=new h(n,void 0);for(var o=0;n>o;o++)i[o]=this[o+t]}return i.length&&(i.parent=this.parent||this),i},h.prototype.readUIntLE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=this[t],n=1,h=0;++h0&&(n*=256);)i+=this[t+--r]*n;return i},h.prototype.readUInt8=function(t,r){return r||S(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,r){return r||S(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,r){return r||S(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,r){return r||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,r){return r||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=this[t],n=1,h=0;++h=n&&(i-=Math.pow(2,8*r)),i},h.prototype.readIntBE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=r,n=1,h=this[t+--i];i>0&&(n*=256);)h+=this[t+--i]*n;return n*=128,h>=n&&(h-=Math.pow(2,8*r)),h},h.prototype.readInt8=function(t,r){return r||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,r){r||S(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},h.prototype.readInt16BE=function(t,r){r||S(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},h.prototype.readInt32LE=function(t,r){return r||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,r){ +return r||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,r){return r||S(t,4,this.length),K.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,r){return r||S(t,4,this.length),K.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,r){return r||S(t,8,this.length),K.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,r){return r||S(t,8,this.length),K.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,r,e,i){t=+t,r=0|r,e=0|e,i||Y(this,t,r,e,Math.pow(2,8*e),0);var n=1,h=0;for(this[r]=255&t;++h=0&&(h*=256);)this[r+n]=t/h&255;return r+e},h.prototype.writeUInt8=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},h.prototype.writeUInt16LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},h.prototype.writeUInt16BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},h.prototype.writeUInt32LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):D(this,t,r,!0),r+4},h.prototype.writeUInt32BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):D(this,t,r,!1),r+4},h.prototype.writeIntLE=function(t,r,e,i){if(t=+t,r=0|r,!i){var n=Math.pow(2,8*e-1);Y(this,t,r,e,n-1,-n)}var h=0,o=1,s=0>t?1:0;for(this[r]=255&t;++h>0)-s&255;return r+e},h.prototype.writeIntBE=function(t,r,e,i){if(t=+t,r=0|r,!i){var n=Math.pow(2,8*e-1);Y(this,t,r,e,n-1,-n)}var h=e-1,o=1,s=0>t?1:0;for(this[r+h]=255&t;--h>=0&&(o*=256);)this[r+h]=(t/o>>0)-s&255;return r+e},h.prototype.writeInt8=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[r]=255&t,r+1},h.prototype.writeInt16LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},h.prototype.writeInt16BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},h.prototype.writeInt32LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):D(this,t,r,!0),r+4},h.prototype.writeInt32BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):D(this,t,r,!1),r+4},h.prototype.writeFloatLE=function(t,r,e){return O(this,t,r,!0,e)},h.prototype.writeFloatBE=function(t,r,e){return O(this,t,r,!1,e)},h.prototype.writeDoubleLE=function(t,r,e){return z(this,t,r,!0,e)},h.prototype.writeDoubleBE=function(t,r,e){return z(this,t,r,!1,e)},h.prototype.copy=function(t,r,e,i){if(e||(e=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&e>i&&(i=e),i===e)return 0;if(0===t.length||0===this.length)return 0;if(0>r)throw new RangeError("targetStart out of bounds");if(0>e||e>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-re&&i>r)for(n=o-1;n>=0;n--)t[n+r]=this[n+e];else if(1e3>o||!h.TYPED_ARRAY_SUPPORT)for(n=0;o>n;n++)t[n+r]=this[n+e];else t._set(this.subarray(e,e+o),r);return o},h.prototype.fill=function(t,r,e){if(t||(t=0),r||(r=0),e||(e=this.length),r>e)throw new RangeError("end < start");if(e!==r&&0!==this.length){if(0>r||r>=this.length)throw new RangeError("start out of bounds");if(0>e||e>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof t)for(i=r;e>i;i++)this[i]=t;else{var n=j(t.toString()),h=n.length;for(i=r;e>i;i++)this[i]=n[i%h]}return this}},h.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(h.TYPED_ARRAY_SUPPORT)return new h(this).buffer;for(var t=new Uint8Array(this.length),r=0,e=t.length;e>r;r+=1)t[r]=this[r];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var $=h.prototype;h._augment=function(t){return t.constructor=h,t._isBuffer=!0,t._set=t.set,t.get=$.get,t.set=$.set,t.write=$.write,t.toString=$.toString,t.toLocaleString=$.toString,t.toJSON=$.toJSON,t.equals=$.equals,t.compare=$.compare,t.indexOf=$.indexOf,t.copy=$.copy,t.slice=$.slice,t.readUIntLE=$.readUIntLE,t.readUIntBE=$.readUIntBE,t.readUInt8=$.readUInt8,t.readUInt16LE=$.readUInt16LE,t.readUInt16BE=$.readUInt16BE,t.readUInt32LE=$.readUInt32LE,t.readUInt32BE=$.readUInt32BE,t.readIntLE=$.readIntLE,t.readIntBE=$.readIntBE,t.readInt8=$.readInt8,t.readInt16LE=$.readInt16LE,t.readInt16BE=$.readInt16BE,t.readInt32LE=$.readInt32LE,t.readInt32BE=$.readInt32BE,t.readFloatLE=$.readFloatLE,t.readFloatBE=$.readFloatBE,t.readDoubleLE=$.readDoubleLE,t.readDoubleBE=$.readDoubleBE,t.writeUInt8=$.writeUInt8,t.writeUIntLE=$.writeUIntLE,t.writeUIntBE=$.writeUIntBE,t.writeUInt16LE=$.writeUInt16LE,t.writeUInt16BE=$.writeUInt16BE,t.writeUInt32LE=$.writeUInt32LE,t.writeUInt32BE=$.writeUInt32BE,t.writeIntLE=$.writeIntLE,t.writeIntBE=$.writeIntBE,t.writeInt8=$.writeInt8,t.writeInt16LE=$.writeInt16LE,t.writeInt16BE=$.writeInt16BE,t.writeInt32LE=$.writeInt32LE,t.writeInt32BE=$.writeInt32BE,t.writeFloatLE=$.writeFloatLE,t.writeFloatBE=$.writeFloatBE,t.writeDoubleLE=$.writeDoubleLE,t.writeDoubleBE=$.writeDoubleBE,t.fill=$.fill,t.inspect=$.inspect,t.toArrayBuffer=$.toArrayBuffer,t};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":3,ieee754:8,isarray:4}]},{},[2]); diff --git a/lib/binding/lz4_binding.cc b/lib/binding/lz4_binding.cc index 92021af9..90e0e311 100644 --- a/lib/binding/lz4_binding.cc +++ b/lib/binding/lz4_binding.cc @@ -5,6 +5,7 @@ #include #include +#include "xxhash_binding.h" #include "../../deps/lz4/lib/lz4.h" #include "../../deps/lz4/lib/lz4hc.h" @@ -382,6 +383,11 @@ NAN_MODULE_INIT(init_lz4) { Nan::Export(target, "uncompress", LZ4Uncompress); Nan::Export(target, "uncompress_fast", LZ4Uncompress_fast); + + Nan::Export(target, "xxHash", xxHash); + Nan::Export(target, "init", xxHash_init); + Nan::Export(target, "update", xxHash_update); + Nan::Export(target, "digest", xxHash_digest); } NODE_MODULE(lz4, init_lz4) diff --git a/lib/binding/xxhash_binding.cc b/lib/binding/xxhash_binding.cc index fa6d8fd4..eec1e3f0 100644 --- a/lib/binding/xxhash_binding.cc +++ b/lib/binding/xxhash_binding.cc @@ -1,9 +1,10 @@ #include #include -#include +#include "xxhash_binding.h" +//#include #include -#include +//#include #define XXH_PRIVATE_API #include "../../deps/lz4/lib/xxhash.h" @@ -108,11 +109,11 @@ NAN_METHOD(xxHash_digest) { info.GetReturnValue().Set(res); } -NAN_MODULE_INIT(init_xxhash) { - Nan::Export(target, "xxHash", xxHash); - Nan::Export(target, "init", xxHash_init); - Nan::Export(target, "update", xxHash_update); - Nan::Export(target, "digest", xxHash_digest); -} +// NAN_MODULE_INIT(init_xxhash) { +// Nan::Export(target, "xxHash", xxHash); +// Nan::Export(target, "init", xxHash_init); +// Nan::Export(target, "update", xxHash_update); +// Nan::Export(target, "digest", xxHash_digest); +// } -NODE_MODULE(xxhash, init_xxhash) +// NODE_MODULE(xxhash, init_xxhash) diff --git a/lib/binding/xxhash_binding.h b/lib/binding/xxhash_binding.h new file mode 100644 index 00000000..234cd9b3 --- /dev/null +++ b/lib/binding/xxhash_binding.h @@ -0,0 +1,12 @@ +#ifndef XXHASH_BINDING_H_INCLUDED +#define XXHASH_BINDING_H_INCLUDED + +#include +#include + +void xxHash(const Nan::FunctionCallbackInfo& info); +void xxHash_init(const Nan::FunctionCallbackInfo& info); +void xxHash_update(const Nan::FunctionCallbackInfo& info); +void xxHash_digest(const Nan::FunctionCallbackInfo& info); + +#endif /* XXHASH_BINDING_H_INCLUDED */ diff --git a/lib/utils.js b/lib/utils.js index 8f8b84ea..e91b79af 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,27 +1,32 @@ /** * Native bindings */ -var XXH = require('../build/Release/xxhash') +//var XXH = require('../build/Release/xxhash') +//var bindings = require('../build/Release/lz4') +var binary = require('node-pre-gyp'); +var path = require('path'); +var binding_path = binary.find(path.resolve(path.join(__dirname, '../package.json'))); +var bindings = require(binding_path); var CHECKSUM_SEED = 0 // Header checksum is second byte of xxhash using 0 as a seed exports.descriptorChecksum = function (d) { - return (XXH.xxHash(d, CHECKSUM_SEED) >> 8) & 0xFF + return (bindings.xxHash(d, CHECKSUM_SEED) >> 8) & 0xFF } exports.blockChecksum = function (d) { - return XXH.xxHash(d, CHECKSUM_SEED) + return bindings.xxHash(d, CHECKSUM_SEED) } exports.streamChecksum = function (d, c) { if (c === null) - c = XXH.init(CHECKSUM_SEED) + c = bindings.init(CHECKSUM_SEED) if (d === null) - return XXH.digest(c) + return bindings.digest(c) - XXH.update(c, d) + bindings.update(c, d) return c } @@ -35,4 +40,4 @@ exports.readUInt32LE = function (buffer, offset) { (buffer[offset + 3] * 0x1000000) } -exports.bindings = require('../build/Release/lz4') +exports.bindings = bindings diff --git a/package.json b/package.json index 1b5d27b9..c770ec5a 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,17 @@ "engines": { "node": ">= 0.10" }, + "binary": { + "module_name": "lz4", + "module_path": "./lib/binding/", + "host": "https://github.com/zeroshade/node-lz4/releases/download", + "remote_path": "{version}" + }, "dependencies": { "cuint": "^0.2.0", "nan": "^2.0.9", + "node-pre-gyp": "^0.11.0", + "prebuild": "^8.0.1", "xxhashjs": "^0.1.1" }, "devDependencies": { @@ -51,7 +59,7 @@ }, "scripts": { "test": "mocha", - "install": "node-gyp rebuild", + "install": "node-pre-gyp install --fallback-to-build", "prepublish": "./build.sh" } } From ca897bf51369b4e1035b6901e56c39a7618f32fb Mon Sep 17 00:00:00 2001 From: Matthew Topol Date: Fri, 14 Sep 2018 14:12:16 -0400 Subject: [PATCH 2/6] adding appveyor --- appveyor.yml | 74 + build/lz4.js | 3582 ---------------------------------------------- build/lz4.min.js | 2 - package.json | 10 +- 4 files changed, 80 insertions(+), 3588 deletions(-) create mode 100644 appveyor.yml delete mode 100644 build/lz4.js delete mode 100644 build/lz4.min.js diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..45a53d82 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,74 @@ +environment: + NODE_PRE_GYP_GITHUB_TOKEN: + secure: aJwAbajByhTfjiB0a3NzwZwWqp5jOJqFaSGelxe7TqgROz+L/QOtmjZj4FtUd029 + + matrix: + - nodejs_version: "8" + - nodejs_version: "10" + +os: Visual Studio 2017 + +platform: + - x64 + - x86 + +matrix: + fast_finish: true + +install: + - cmd: git submodule update --init --recursive + - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform; + - ps: >- + npm config set progress false + npm config set spin false + - ps: >- + $env:JOBS = "max"; + $env:PUBLISH = "false"; + $env:GIT_TAG = "$(git describe --tags --always HEAD)"; + $env:package_version = (Get-Content -Raw -Path package.json | ConvertFrom-Json).version; + if ($env:APPVEYOR_REPO_BRANCH -match $env:GIT_TAG) { + $env:PUBLISH = "true"; + } + if ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match "[draft]") { + $env:PUBLISH = "true"; + } + if ($env:APPVEYOR_REPO_TAG -match "true") { + $env:PUBLISH = "true"; + } + true; + - ps: >- + @{ + "APPVEYOR_REPO_BRANCH" = $env:APPVEYOR_REPO_BRANCH + "APPVEYOR_REPO_TAG" = $env:APPVEYOR_REPO_TAG + "APPVEYOR_REPO_COMMIT_MESSAGE" = $env:APPVEYOR_REPO_COMMIT_MESSAGE + "LATEST TAG" = $env:GIT_TAG + "PUBLISHING" = $env:PUBLISH + "PACKAGE_VERSION" = $env:package_version + } | Out-String | Write-Host; + - ps: Update-AppveyorBuild -Version "$env:package_version-$env:APPVEYOR_BUILD_NUMBER" + +build_script: + - npm install --build-from-source + - ps: .\node_modules\.bin\browserify -o build/lz4.js -r ./lib/utils-js.js:./utils -r buffer -r ./lib/lz4.js:lz4 lib/lz4.js; + - ps: .\node_modules\.bin\minify build/lz4.js > build/lz4.min.js; + +test_script: + - npm test + +after_build: + - npm run package + - ps: Get-ChildItem .\build\stage\*\* | %{ Push-AppveyorArtifact $_.FullName -FileName $_.Name } + +deploy: + release: ${package_version} + provider: GitHub + auth_token: + secure: aJwAbajByhTfjiB0a3NzwZwWqp5jOJqFaSGelxe7TqgROz+L/QOtmjZj4FtUd029 + artifact: /.*\.tar\.gz/ + force_update: true + draft: true + prerelease: true + repository: zeroshade/node-lz4 + on: + branch: package + diff --git a/build/lz4.js b/build/lz4.js deleted file mode 100644 index c51725ab..00000000 --- a/build/lz4.js +++ /dev/null @@ -1,3582 +0,0 @@ -require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o> 8) & 0xFF -} - -exports.blockChecksum = function (d) { - return XXH(d, CHECKSUM_SEED).toNumber() -} - -exports.streamChecksum = function (d, c) { - if (d === null) - return c.digest().toNumber() - - if (c === null) - c = XXH(CHECKSUM_SEED) - - return c.update(d) -} - -// Provide simple readUInt32LE as the Buffer ones from node and browserify are incompatible -exports.readUInt32LE = function (buffer, offset) { - return (buffer[offset]) | - (buffer[offset + 1] << 8) | - (buffer[offset + 2] << 16) | - (buffer[offset + 3] << 24) -} - -exports.bindings = require('./binding') - -},{"./binding":1,"xxhashjs":12}],1:[function(require,module,exports){ -/** - Javascript version of the key LZ4 C functions - */ -var uint32 = require('cuint').UINT32 - -if (!Math.imul) Math.imul = function imul(a, b) { - var ah = a >>> 16; - var al = a & 0xffff; - var bh = b >>> 16; - var bl = b & 0xffff; - return (al*bl + ((ah*bl + al*bh) << 16))|0; -}; - -/** - * Decode a block. Assumptions: input contains all sequences of a - * chunk, output is large enough to receive the decoded data. - * If the output buffer is too small, an error will be thrown. - * If the returned value is negative, an error occured at the returned offset. - * - * @param input {Buffer} input data - * @param output {Buffer} output data - * @return {Number} number of decoded bytes - * @private - */ -exports.uncompress = function (input, output, sIdx, eIdx) { - sIdx = sIdx || 0 - eIdx = eIdx || (input.length - sIdx) - // Process each sequence in the incoming data - for (var i = sIdx, n = eIdx, j = 0; i < n;) { - var token = input[i++] - - // Literals - var literals_length = (token >> 4) - if (literals_length > 0) { - // length of literals - var l = literals_length + 240 - while (l === 255) { - l = input[i++] - literals_length += l - } - - // Copy the literals - var end = i + literals_length - while (i < end) output[j++] = input[i++] - - // End of buffer? - if (i === n) return j - } - - // Match copy - // 2 bytes offset (little endian) - var offset = input[i++] | (input[i++] << 8) - - // 0 is an invalid offset value - if (offset === 0 || offset > j) return -(i-2) - - // length of match copy - var match_length = (token & 0xf) - var l = match_length + 240 - while (l === 255) { - l = input[i++] - match_length += l - } - - // Copy the match - var pos = j - offset // position of the match copy in the current output - var end = j + match_length + 4 // minmatch = 4 - while (j < end) output[j++] = output[pos++] - } - - return j -} - -var - maxInputSize = 0x7E000000 -, minMatch = 4 -// uint32() optimization -, hashLog = 16 -, hashShift = (minMatch * 8) - hashLog -, hashSize = 1 << hashLog - -, copyLength = 8 -, lastLiterals = 5 -, mfLimit = copyLength + minMatch -, skipStrength = 6 - -, mlBits = 4 -, mlMask = (1 << mlBits) - 1 -, runBits = 8 - mlBits -, runMask = (1 << runBits) - 1 - -, hasher = 2654435761 - -// CompressBound returns the maximum length of a lz4 block, given it's uncompressed length -exports.compressBound = function (isize) { - return isize > maxInputSize - ? 0 - : (isize + (isize/255) + 16) | 0 -} - -exports.compress = function (src, dst, sIdx, eIdx) { - // V8 optimization: non sparse array with integers - var hashTable = new Array(hashSize) - for (var i = 0; i < hashSize; i++) { - hashTable[i] = 0 - } - return compressBlock(src, dst, 0, hashTable, sIdx || 0, eIdx || dst.length) -} - -exports.compressHC = exports.compress - -exports.compressDependent = compressBlock - -function compressBlock (src, dst, pos, hashTable, sIdx, eIdx) { - var dpos = sIdx - var dlen = eIdx - sIdx - var anchor = 0 - - if (src.length >= maxInputSize) throw new Error("input too large") - - // Minimum of input bytes for compression (LZ4 specs) - if (src.length > mfLimit) { - var n = exports.compressBound(src.length) - if ( dlen < n ) throw Error("output too small: " + dlen + " < " + n) - - var - step = 1 - , findMatchAttempts = (1 << skipStrength) + 3 - // Keep last few bytes incompressible (LZ4 specs): - // last 5 bytes must be literals - , srcLength = src.length - mfLimit - - while (pos + minMatch < srcLength) { - // Find a match - // min match of 4 bytes aka sequence - var sequenceLowBits = src[pos+1]<<8 | src[pos] - var sequenceHighBits = src[pos+3]<<8 | src[pos+2] - // compute hash for the current sequence - var hash = Math.imul(sequenceLowBits | (sequenceHighBits << 16), hasher) >>> hashShift - // get the position of the sequence matching the hash - // NB. since 2 different sequences may have the same hash - // it is double-checked below - // do -1 to distinguish between initialized and uninitialized values - var ref = hashTable[hash] - 1 - // save position of current sequence in hash table - hashTable[hash] = pos + 1 - - // first reference or within 64k limit or current sequence !== hashed one: no match - if ( ref < 0 || - ((pos - ref) >>> 16) > 0 || - ( - ((src[ref+3]<<8 | src[ref+2]) != sequenceHighBits) || - ((src[ref+1]<<8 | src[ref]) != sequenceLowBits ) - ) - ) { - // increase step if nothing found within limit - step = findMatchAttempts++ >> skipStrength - pos += step - continue - } - - findMatchAttempts = (1 << skipStrength) + 3 - - // got a match - var literals_length = pos - anchor - var offset = pos - ref - - // minMatch already verified - pos += minMatch - ref += minMatch - - // move to the end of the match (>=minMatch) - var match_length = pos - while (pos < srcLength && src[pos] == src[ref]) { - pos++ - ref++ - } - - // match length - match_length = pos - match_length - - // token - var token = match_length < mlMask ? match_length : mlMask - - // encode literals length - if (literals_length >= runMask) { - // add match length to the token - dst[dpos++] = (runMask << mlBits) + token - for (var len = literals_length - runMask; len > 254; len -= 255) { - dst[dpos++] = 255 - } - dst[dpos++] = len - } else { - // add match length to the token - dst[dpos++] = (literals_length << mlBits) + token - } - - // write literals - for (var i = 0; i < literals_length; i++) { - dst[dpos++] = src[anchor+i] - } - - // encode offset - dst[dpos++] = offset - dst[dpos++] = (offset >> 8) - - // encode match length - if (match_length >= mlMask) { - match_length -= mlMask - while (match_length >= 255) { - match_length -= 255 - dst[dpos++] = 255 - } - - dst[dpos++] = match_length - } - - anchor = pos - } - } - - // cannot compress input - if (anchor == 0) return 0 - - // Write last literals - // encode literals length - literals_length = src.length - anchor - if (literals_length >= runMask) { - // add match length to the token - dst[dpos++] = (runMask << mlBits) - for (var ln = literals_length - runMask; ln > 254; ln -= 255) { - dst[dpos++] = 255 - } - dst[dpos++] = ln - } else { - // add match length to the token - dst[dpos++] = (literals_length << mlBits) - } - - // write literals - pos = anchor - while (pos < src.length) { - dst[dpos++] = src[pos++] - } - - return dpos -} - -},{"cuint":5}],2:[function(require,module,exports){ - -},{}],3:[function(require,module,exports){ -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - -;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length - - var L = 0 - - function push (v) { - arr[L++] = v - } - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } - - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } - - return arr - } - - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length - - function encode (num) { - return lookup.charAt(num) - } - - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } - - return output - } - - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 -}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) - -},{}],4:[function(require,module,exports){ -var toString = {}.toString; - -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; - -},{}],5:[function(require,module,exports){ -exports.UINT32 = require('./lib/uint32') -exports.UINT64 = require('./lib/uint64') -},{"./lib/uint32":6,"./lib/uint64":7}],6:[function(require,module,exports){ -/** - C-like unsigned 32 bits integers in Javascript - Copyright (C) 2013, Pierre Curto - MIT license - */ -;(function (root) { - - // Local cache for typical radices - var radixPowerCache = { - 36: UINT32( Math.pow(36, 5) ) - , 16: UINT32( Math.pow(16, 7) ) - , 10: UINT32( Math.pow(10, 9) ) - , 2: UINT32( Math.pow(2, 30) ) - } - var radixCache = { - 36: UINT32(36) - , 16: UINT32(16) - , 10: UINT32(10) - , 2: UINT32(2) - } - - /** - * Represents an unsigned 32 bits integer - * @constructor - * @param {Number|String|Number} low bits | integer as a string | integer as a number - * @param {Number|Number|Undefined} high bits | radix (optional, default=10) - * @return - */ - function UINT32 (l, h) { - if ( !(this instanceof UINT32) ) - return new UINT32(l, h) - - this._low = 0 - this._high = 0 - this.remainder = null - if (typeof h == 'undefined') - return fromNumber.call(this, l) - - if (typeof l == 'string') - return fromString.call(this, l, h) - - fromBits.call(this, l, h) - } - - /** - * Set the current _UINT32_ object with its low and high bits - * @method fromBits - * @param {Number} low bits - * @param {Number} high bits - * @return ThisExpression - */ - function fromBits (l, h) { - this._low = l | 0 - this._high = h | 0 - - return this - } - UINT32.prototype.fromBits = fromBits - - /** - * Set the current _UINT32_ object from a number - * @method fromNumber - * @param {Number} number - * @return ThisExpression - */ - function fromNumber (value) { - this._low = value & 0xFFFF - this._high = value >>> 16 - - return this - } - UINT32.prototype.fromNumber = fromNumber - - /** - * Set the current _UINT32_ object from a string - * @method fromString - * @param {String} integer as a string - * @param {Number} radix (optional, default=10) - * @return ThisExpression - */ - function fromString (s, radix) { - var value = parseInt(s, radix || 10) - - this._low = value & 0xFFFF - this._high = value >>> 16 - - return this - } - UINT32.prototype.fromString = fromString - - /** - * Convert this _UINT32_ to a number - * @method toNumber - * @return {Number} the converted UINT32 - */ - UINT32.prototype.toNumber = function () { - return (this._high * 65536) + this._low - } - - /** - * Convert this _UINT32_ to a string - * @method toString - * @param {Number} radix (optional, default=10) - * @return {String} the converted UINT32 - */ - UINT32.prototype.toString = function (radix) { - return this.toNumber().toString(radix || 10) - } - - /** - * Add two _UINT32_. The current _UINT32_ stores the result - * @method add - * @param {Object} other UINT32 - * @return ThisExpression - */ - UINT32.prototype.add = function (other) { - var a00 = this._low + other._low - var a16 = a00 >>> 16 - - a16 += this._high + other._high - - this._low = a00 & 0xFFFF - this._high = a16 & 0xFFFF - - return this - } - - /** - * Subtract two _UINT32_. The current _UINT32_ stores the result - * @method subtract - * @param {Object} other UINT32 - * @return ThisExpression - */ - UINT32.prototype.subtract = function (other) { - //TODO inline - return this.add( other.clone().negate() ) - } - - /** - * Multiply two _UINT32_. The current _UINT32_ stores the result - * @method multiply - * @param {Object} other UINT32 - * @return ThisExpression - */ - UINT32.prototype.multiply = function (other) { - /* - a = a00 + a16 - b = b00 + b16 - a*b = (a00 + a16)(b00 + b16) - = a00b00 + a00b16 + a16b00 + a16b16 - - a16b16 overflows the 32bits - */ - var a16 = this._high - var a00 = this._low - var b16 = other._high - var b00 = other._low - -/* Removed to increase speed under normal circumstances (i.e. not multiplying by 0 or 1) - // this == 0 or other == 1: nothing to do - if ((a00 == 0 && a16 == 0) || (b00 == 1 && b16 == 0)) return this - - // other == 0 or this == 1: this = other - if ((b00 == 0 && b16 == 0) || (a00 == 1 && a16 == 0)) { - this._low = other._low - this._high = other._high - return this - } -*/ - - var c16, c00 - c00 = a00 * b00 - c16 = c00 >>> 16 - - c16 += a16 * b00 - c16 &= 0xFFFF // Not required but improves performance - c16 += a00 * b16 - - this._low = c00 & 0xFFFF - this._high = c16 & 0xFFFF - - return this - } - - /** - * Divide two _UINT32_. The current _UINT32_ stores the result. - * The remainder is made available as the _remainder_ property on - * the _UINT32_ object. It can be null, meaning there are no remainder. - * @method div - * @param {Object} other UINT32 - * @return ThisExpression - */ - UINT32.prototype.div = function (other) { - if ( (other._low == 0) && (other._high == 0) ) throw Error('division by zero') - - // other == 1 - if (other._high == 0 && other._low == 1) { - this.remainder = new UINT32(0) - return this - } - - // other > this: 0 - if ( other.gt(this) ) { - this.remainder = this.clone() - this._low = 0 - this._high = 0 - return this - } - // other == this: 1 - if ( this.eq(other) ) { - this.remainder = new UINT32(0) - this._low = 1 - this._high = 0 - return this - } - - // Shift the divisor left until it is higher than the dividend - var _other = other.clone() - var i = -1 - while ( !this.lt(_other) ) { - // High bit can overflow the default 16bits - // Its ok since we right shift after this loop - // The overflown bit must be kept though - _other.shiftLeft(1, true) - i++ - } - - // Set the remainder - this.remainder = this.clone() - // Initialize the current result to 0 - this._low = 0 - this._high = 0 - for (; i >= 0; i--) { - _other.shiftRight(1) - // If shifted divisor is smaller than the dividend - // then subtract it from the dividend - if ( !this.remainder.lt(_other) ) { - this.remainder.subtract(_other) - // Update the current result - if (i >= 16) { - this._high |= 1 << (i - 16) - } else { - this._low |= 1 << i - } - } - } - - return this - } - - /** - * Negate the current _UINT32_ - * @method negate - * @return ThisExpression - */ - UINT32.prototype.negate = function () { - var v = ( ~this._low & 0xFFFF ) + 1 - this._low = v & 0xFFFF - this._high = (~this._high + (v >>> 16)) & 0xFFFF - - return this - } - - /** - * Equals - * @method eq - * @param {Object} other UINT32 - * @return {Boolean} - */ - UINT32.prototype.equals = UINT32.prototype.eq = function (other) { - return (this._low == other._low) && (this._high == other._high) - } - - /** - * Greater than (strict) - * @method gt - * @param {Object} other UINT32 - * @return {Boolean} - */ - UINT32.prototype.greaterThan = UINT32.prototype.gt = function (other) { - if (this._high > other._high) return true - if (this._high < other._high) return false - return this._low > other._low - } - - /** - * Less than (strict) - * @method lt - * @param {Object} other UINT32 - * @return {Boolean} - */ - UINT32.prototype.lessThan = UINT32.prototype.lt = function (other) { - if (this._high < other._high) return true - if (this._high > other._high) return false - return this._low < other._low - } - - /** - * Bitwise OR - * @method or - * @param {Object} other UINT32 - * @return ThisExpression - */ - UINT32.prototype.or = function (other) { - this._low |= other._low - this._high |= other._high - - return this - } - - /** - * Bitwise AND - * @method and - * @param {Object} other UINT32 - * @return ThisExpression - */ - UINT32.prototype.and = function (other) { - this._low &= other._low - this._high &= other._high - - return this - } - - /** - * Bitwise NOT - * @method not - * @return ThisExpression - */ - UINT32.prototype.not = function() { - this._low = ~this._low & 0xFFFF - this._high = ~this._high & 0xFFFF - - return this - } - - /** - * Bitwise XOR - * @method xor - * @param {Object} other UINT32 - * @return ThisExpression - */ - UINT32.prototype.xor = function (other) { - this._low ^= other._low - this._high ^= other._high - - return this - } - - /** - * Bitwise shift right - * @method shiftRight - * @param {Number} number of bits to shift - * @return ThisExpression - */ - UINT32.prototype.shiftRight = UINT32.prototype.shiftr = function (n) { - if (n > 16) { - this._low = this._high >> (n - 16) - this._high = 0 - } else if (n == 16) { - this._low = this._high - this._high = 0 - } else { - this._low = (this._low >> n) | ( (this._high << (16-n)) & 0xFFFF ) - this._high >>= n - } - - return this - } - - /** - * Bitwise shift left - * @method shiftLeft - * @param {Number} number of bits to shift - * @param {Boolean} allow overflow - * @return ThisExpression - */ - UINT32.prototype.shiftLeft = UINT32.prototype.shiftl = function (n, allowOverflow) { - if (n > 16) { - this._high = this._low << (n - 16) - this._low = 0 - if (!allowOverflow) { - this._high &= 0xFFFF - } - } else if (n == 16) { - this._high = this._low - this._low = 0 - } else { - this._high = (this._high << n) | (this._low >> (16-n)) - this._low = (this._low << n) & 0xFFFF - if (!allowOverflow) { - // Overflow only allowed on the high bits... - this._high &= 0xFFFF - } - } - - return this - } - - /** - * Bitwise rotate left - * @method rotl - * @param {Number} number of bits to rotate - * @return ThisExpression - */ - UINT32.prototype.rotateLeft = UINT32.prototype.rotl = function (n) { - var v = (this._high << 16) | this._low - v = (v << n) | (v >>> (32 - n)) - this._low = v & 0xFFFF - this._high = v >>> 16 - - return this - } - - /** - * Bitwise rotate right - * @method rotr - * @param {Number} number of bits to rotate - * @return ThisExpression - */ - UINT32.prototype.rotateRight = UINT32.prototype.rotr = function (n) { - var v = (this._high << 16) | this._low - v = (v >>> n) | (v << (32 - n)) - this._low = v & 0xFFFF - this._high = v >>> 16 - - return this - } - - /** - * Clone the current _UINT32_ - * @method clone - * @return {Object} cloned UINT32 - */ - UINT32.prototype.clone = function () { - return new UINT32(this._low, this._high) - } - - if (typeof define != 'undefined' && define.amd) { - // AMD / RequireJS - define([], function () { - return UINT32 - }) - } else if (typeof module != 'undefined' && module.exports) { - // Node.js - module.exports = UINT32 - } else { - // Browser - root['UINT32'] = UINT32 - } - -})(this) - -},{}],7:[function(require,module,exports){ -/** - C-like unsigned 64 bits integers in Javascript - Copyright (C) 2013, Pierre Curto - MIT license - */ -;(function (root) { - - // Local cache for typical radices - var radixPowerCache = { - 16: UINT64( Math.pow(16, 5) ) - , 10: UINT64( Math.pow(10, 5) ) - , 2: UINT64( Math.pow(2, 5) ) - } - var radixCache = { - 16: UINT64(16) - , 10: UINT64(10) - , 2: UINT64(2) - } - - /** - * Represents an unsigned 64 bits integer - * @constructor - * @param {Number} first low bits (8) - * @param {Number} second low bits (8) - * @param {Number} first high bits (8) - * @param {Number} second high bits (8) - * or - * @param {Number} low bits (32) - * @param {Number} high bits (32) - * or - * @param {String|Number} integer as a string | integer as a number - * @param {Number|Undefined} radix (optional, default=10) - * @return - */ - function UINT64 (a00, a16, a32, a48) { - if ( !(this instanceof UINT64) ) - return new UINT64(a00, a16, a32, a48) - - this.remainder = null - if (typeof a00 == 'string') - return fromString.call(this, a00, a16) - - if (typeof a16 == 'undefined') - return fromNumber.call(this, a00) - - fromBits.apply(this, arguments) - } - - /** - * Set the current _UINT64_ object with its low and high bits - * @method fromBits - * @param {Number} first low bits (8) - * @param {Number} second low bits (8) - * @param {Number} first high bits (8) - * @param {Number} second high bits (8) - * or - * @param {Number} low bits (32) - * @param {Number} high bits (32) - * @return ThisExpression - */ - function fromBits (a00, a16, a32, a48) { - if (typeof a32 == 'undefined') { - this._a00 = a00 & 0xFFFF - this._a16 = a00 >>> 16 - this._a32 = a16 & 0xFFFF - this._a48 = a16 >>> 16 - return this - } - - this._a00 = a00 | 0 - this._a16 = a16 | 0 - this._a32 = a32 | 0 - this._a48 = a48 | 0 - - return this - } - UINT64.prototype.fromBits = fromBits - - /** - * Set the current _UINT64_ object from a number - * @method fromNumber - * @param {Number} number - * @return ThisExpression - */ - function fromNumber (value) { - this._a00 = value & 0xFFFF - this._a16 = value >>> 16 - this._a32 = 0 - this._a48 = 0 - - return this - } - UINT64.prototype.fromNumber = fromNumber - - /** - * Set the current _UINT64_ object from a string - * @method fromString - * @param {String} integer as a string - * @param {Number} radix (optional, default=10) - * @return ThisExpression - */ - function fromString (s, radix) { - radix = radix || 10 - - this._a00 = 0 - this._a16 = 0 - this._a32 = 0 - this._a48 = 0 - - /* - In Javascript, bitwise operators only operate on the first 32 bits - of a number, even though parseInt() encodes numbers with a 53 bits - mantissa. - Therefore UINT64() can only work on 32 bits. - The radix maximum value is 36 (as per ECMA specs) (26 letters + 10 digits) - maximum input value is m = 32bits as 1 = 2^32 - 1 - So the maximum substring length n is: - 36^(n+1) - 1 = 2^32 - 1 - 36^(n+1) = 2^32 - (n+1)ln(36) = 32ln(2) - n = 32ln(2)/ln(36) - 1 - n = 5.189644915687692 - n = 5 - */ - var radixUint = radixPowerCache[radix] || new UINT64( Math.pow(radix, 5) ) - - for (var i = 0, len = s.length; i < len; i += 5) { - var size = Math.min(5, len - i) - var value = parseInt( s.slice(i, i + size), radix ) - this.multiply( - size < 5 - ? new UINT64( Math.pow(radix, size) ) - : radixUint - ) - .add( new UINT64(value) ) - } - - return this - } - UINT64.prototype.fromString = fromString - - /** - * Convert this _UINT64_ to a number (last 32 bits are dropped) - * @method toNumber - * @return {Number} the converted UINT64 - */ - UINT64.prototype.toNumber = function () { - return (this._a16 * 65536) + this._a00 - } - - /** - * Convert this _UINT64_ to a string - * @method toString - * @param {Number} radix (optional, default=10) - * @return {String} the converted UINT64 - */ - UINT64.prototype.toString = function (radix) { - radix = radix || 10 - var radixUint = radixCache[radix] || new UINT64(radix) - - if ( !this.gt(radixUint) ) return this.toNumber().toString(radix) - - var self = this.clone() - var res = new Array(64) - for (var i = 63; i >= 0; i--) { - self.div(radixUint) - res[i] = self.remainder.toNumber().toString(radix) - if ( !self.gt(radixUint) ) break - } - res[i-1] = self.toNumber().toString(radix) - - return res.join('') - } - - /** - * Add two _UINT64_. The current _UINT64_ stores the result - * @method add - * @param {Object} other UINT64 - * @return ThisExpression - */ - UINT64.prototype.add = function (other) { - var a00 = this._a00 + other._a00 - - var a16 = a00 >>> 16 - a16 += this._a16 + other._a16 - - var a32 = a16 >>> 16 - a32 += this._a32 + other._a32 - - var a48 = a32 >>> 16 - a48 += this._a48 + other._a48 - - this._a00 = a00 & 0xFFFF - this._a16 = a16 & 0xFFFF - this._a32 = a32 & 0xFFFF - this._a48 = a48 & 0xFFFF - - return this - } - - /** - * Subtract two _UINT64_. The current _UINT64_ stores the result - * @method subtract - * @param {Object} other UINT64 - * @return ThisExpression - */ - UINT64.prototype.subtract = function (other) { - return this.add( other.clone().negate() ) - } - - /** - * Multiply two _UINT64_. The current _UINT64_ stores the result - * @method multiply - * @param {Object} other UINT64 - * @return ThisExpression - */ - UINT64.prototype.multiply = function (other) { - /* - a = a00 + a16 + a32 + a48 - b = b00 + b16 + b32 + b48 - a*b = (a00 + a16 + a32 + a48)(b00 + b16 + b32 + b48) - = a00b00 + a00b16 + a00b32 + a00b48 - + a16b00 + a16b16 + a16b32 + a16b48 - + a32b00 + a32b16 + a32b32 + a32b48 - + a48b00 + a48b16 + a48b32 + a48b48 - - a16b48, a32b32, a48b16, a48b32 and a48b48 overflow the 64 bits - so it comes down to: - a*b = a00b00 + a00b16 + a00b32 + a00b48 - + a16b00 + a16b16 + a16b32 - + a32b00 + a32b16 - + a48b00 - = a00b00 - + a00b16 + a16b00 - + a00b32 + a16b16 + a32b00 - + a00b48 + a16b32 + a32b16 + a48b00 - */ - var a00 = this._a00 - var a16 = this._a16 - var a32 = this._a32 - var a48 = this._a48 - var b00 = other._a00 - var b16 = other._a16 - var b32 = other._a32 - var b48 = other._a48 - - var c00 = a00 * b00 - - var c16 = c00 >>> 16 - c16 += a00 * b16 - var c32 = c16 >>> 16 - c16 &= 0xFFFF - c16 += a16 * b00 - - c32 += c16 >>> 16 - c32 += a00 * b32 - var c48 = c32 >>> 16 - c32 &= 0xFFFF - c32 += a16 * b16 - c48 += c32 >>> 16 - c32 &= 0xFFFF - c32 += a32 * b00 - - c48 += c32 >>> 16 - c48 += a00 * b48 - c48 &= 0xFFFF - c48 += a16 * b32 - c48 &= 0xFFFF - c48 += a32 * b16 - c48 &= 0xFFFF - c48 += a48 * b00 - - this._a00 = c00 & 0xFFFF - this._a16 = c16 & 0xFFFF - this._a32 = c32 & 0xFFFF - this._a48 = c48 & 0xFFFF - - return this - } - - /** - * Divide two _UINT64_. The current _UINT64_ stores the result. - * The remainder is made available as the _remainder_ property on - * the _UINT64_ object. It can be null, meaning there are no remainder. - * @method div - * @param {Object} other UINT64 - * @return ThisExpression - */ - UINT64.prototype.div = function (other) { - if ( (other._a16 == 0) && (other._a32 == 0) && (other._a48 == 0) ) { - if (other._a00 == 0) throw Error('division by zero') - - // other == 1: this - if (other._a00 == 1) { - this.remainder = new UINT64(0) - return this - } - } - - // other > this: 0 - if ( other.gt(this) ) { - this.remainder = this.clone() - this._a00 = 0 - this._a16 = 0 - this._a32 = 0 - this._a48 = 0 - return this - } - // other == this: 1 - if ( this.eq(other) ) { - this.remainder = new UINT64(0) - this._a00 = 1 - this._a16 = 0 - this._a32 = 0 - this._a48 = 0 - return this - } - - // Shift the divisor left until it is higher than the dividend - var _other = other.clone() - var i = -1 - while ( !this.lt(_other) ) { - // High bit can overflow the default 16bits - // Its ok since we right shift after this loop - // The overflown bit must be kept though - _other.shiftLeft(1, true) - i++ - } - - // Set the remainder - this.remainder = this.clone() - // Initialize the current result to 0 - this._a00 = 0 - this._a16 = 0 - this._a32 = 0 - this._a48 = 0 - for (; i >= 0; i--) { - _other.shiftRight(1) - // If shifted divisor is smaller than the dividend - // then subtract it from the dividend - if ( !this.remainder.lt(_other) ) { - this.remainder.subtract(_other) - // Update the current result - if (i >= 48) { - this._a48 |= 1 << (i - 48) - } else if (i >= 32) { - this._a32 |= 1 << (i - 32) - } else if (i >= 16) { - this._a16 |= 1 << (i - 16) - } else { - this._a00 |= 1 << i - } - } - } - - return this - } - - /** - * Negate the current _UINT64_ - * @method negate - * @return ThisExpression - */ - UINT64.prototype.negate = function () { - var v = ( ~this._a00 & 0xFFFF ) + 1 - this._a00 = v & 0xFFFF - v = (~this._a16 & 0xFFFF) + (v >>> 16) - this._a16 = v & 0xFFFF - v = (~this._a32 & 0xFFFF) + (v >>> 16) - this._a32 = v & 0xFFFF - this._a48 = (~this._a48 + (v >>> 16)) & 0xFFFF - - return this - } - - /** - - * @method eq - * @param {Object} other UINT64 - * @return {Boolean} - */ - UINT64.prototype.equals = UINT64.prototype.eq = function (other) { - return (this._a48 == other._a48) && (this._a00 == other._a00) - && (this._a32 == other._a32) && (this._a16 == other._a16) - } - - /** - * Greater than (strict) - * @method gt - * @param {Object} other UINT64 - * @return {Boolean} - */ - UINT64.prototype.greaterThan = UINT64.prototype.gt = function (other) { - if (this._a48 > other._a48) return true - if (this._a48 < other._a48) return false - if (this._a32 > other._a32) return true - if (this._a32 < other._a32) return false - if (this._a16 > other._a16) return true - if (this._a16 < other._a16) return false - return this._a00 > other._a00 - } - - /** - * Less than (strict) - * @method lt - * @param {Object} other UINT64 - * @return {Boolean} - */ - UINT64.prototype.lessThan = UINT64.prototype.lt = function (other) { - if (this._a48 < other._a48) return true - if (this._a48 > other._a48) return false - if (this._a32 < other._a32) return true - if (this._a32 > other._a32) return false - if (this._a16 < other._a16) return true - if (this._a16 > other._a16) return false - return this._a00 < other._a00 - } - - /** - * Bitwise OR - * @method or - * @param {Object} other UINT64 - * @return ThisExpression - */ - UINT64.prototype.or = function (other) { - this._a00 |= other._a00 - this._a16 |= other._a16 - this._a32 |= other._a32 - this._a48 |= other._a48 - - return this - } - - /** - * Bitwise AND - * @method and - * @param {Object} other UINT64 - * @return ThisExpression - */ - UINT64.prototype.and = function (other) { - this._a00 &= other._a00 - this._a16 &= other._a16 - this._a32 &= other._a32 - this._a48 &= other._a48 - - return this - } - - /** - * Bitwise XOR - * @method xor - * @param {Object} other UINT64 - * @return ThisExpression - */ - UINT64.prototype.xor = function (other) { - this._a00 ^= other._a00 - this._a16 ^= other._a16 - this._a32 ^= other._a32 - this._a48 ^= other._a48 - - return this - } - - /** - * Bitwise NOT - * @method not - * @return ThisExpression - */ - UINT64.prototype.not = function() { - this._a00 = ~this._a00 & 0xFFFF - this._a16 = ~this._a16 & 0xFFFF - this._a32 = ~this._a32 & 0xFFFF - this._a48 = ~this._a48 & 0xFFFF - - return this - } - - /** - * Bitwise shift right - * @method shiftRight - * @param {Number} number of bits to shift - * @return ThisExpression - */ - UINT64.prototype.shiftRight = UINT64.prototype.shiftr = function (n) { - n %= 64 - if (n >= 48) { - this._a00 = this._a48 >> (n - 48) - this._a16 = 0 - this._a32 = 0 - this._a48 = 0 - } else if (n >= 32) { - n -= 32 - this._a00 = ( (this._a32 >> n) | (this._a48 << (16-n)) ) & 0xFFFF - this._a16 = (this._a48 >> n) & 0xFFFF - this._a32 = 0 - this._a48 = 0 - } else if (n >= 16) { - n -= 16 - this._a00 = ( (this._a16 >> n) | (this._a32 << (16-n)) ) & 0xFFFF - this._a16 = ( (this._a32 >> n) | (this._a48 << (16-n)) ) & 0xFFFF - this._a32 = (this._a48 >> n) & 0xFFFF - this._a48 = 0 - } else { - this._a00 = ( (this._a00 >> n) | (this._a16 << (16-n)) ) & 0xFFFF - this._a16 = ( (this._a16 >> n) | (this._a32 << (16-n)) ) & 0xFFFF - this._a32 = ( (this._a32 >> n) | (this._a48 << (16-n)) ) & 0xFFFF - this._a48 = (this._a48 >> n) & 0xFFFF - } - - return this - } - - /** - * Bitwise shift left - * @method shiftLeft - * @param {Number} number of bits to shift - * @param {Boolean} allow overflow - * @return ThisExpression - */ - UINT64.prototype.shiftLeft = UINT64.prototype.shiftl = function (n, allowOverflow) { - n %= 64 - if (n >= 48) { - this._a48 = this._a00 << (n - 48) - this._a32 = 0 - this._a16 = 0 - this._a00 = 0 - } else if (n >= 32) { - n -= 32 - this._a48 = (this._a16 << n) | (this._a00 >> (16-n)) - this._a32 = (this._a00 << n) & 0xFFFF - this._a16 = 0 - this._a00 = 0 - } else if (n >= 16) { - n -= 16 - this._a48 = (this._a32 << n) | (this._a16 >> (16-n)) - this._a32 = ( (this._a16 << n) | (this._a00 >> (16-n)) ) & 0xFFFF - this._a16 = (this._a00 << n) & 0xFFFF - this._a00 = 0 - } else { - this._a48 = (this._a48 << n) | (this._a32 >> (16-n)) - this._a32 = ( (this._a32 << n) | (this._a16 >> (16-n)) ) & 0xFFFF - this._a16 = ( (this._a16 << n) | (this._a00 >> (16-n)) ) & 0xFFFF - this._a00 = (this._a00 << n) & 0xFFFF - } - if (!allowOverflow) { - this._a48 &= 0xFFFF - } - - return this - } - - /** - * Bitwise rotate left - * @method rotl - * @param {Number} number of bits to rotate - * @return ThisExpression - */ - UINT64.prototype.rotateLeft = UINT64.prototype.rotl = function (n) { - n %= 64 - if (n == 0) return this - if (n >= 32) { - // A.B.C.D - // B.C.D.A rotl(16) - // C.D.A.B rotl(32) - var v = this._a00 - this._a00 = this._a32 - this._a32 = v - v = this._a48 - this._a48 = this._a16 - this._a16 = v - if (n == 32) return this - n -= 32 - } - - var high = (this._a48 << 16) | this._a32 - var low = (this._a16 << 16) | this._a00 - - var _high = (high << n) | (low >>> (32 - n)) - var _low = (low << n) | (high >>> (32 - n)) - - this._a00 = _low & 0xFFFF - this._a16 = _low >>> 16 - this._a32 = _high & 0xFFFF - this._a48 = _high >>> 16 - - return this - } - - /** - * Bitwise rotate right - * @method rotr - * @param {Number} number of bits to rotate - * @return ThisExpression - */ - UINT64.prototype.rotateRight = UINT64.prototype.rotr = function (n) { - n %= 64 - if (n == 0) return this - if (n >= 32) { - // A.B.C.D - // D.A.B.C rotr(16) - // C.D.A.B rotr(32) - var v = this._a00 - this._a00 = this._a32 - this._a32 = v - v = this._a48 - this._a48 = this._a16 - this._a16 = v - if (n == 32) return this - n -= 32 - } - - var high = (this._a48 << 16) | this._a32 - var low = (this._a16 << 16) | this._a00 - - var _high = (high >>> n) | (low << (32 - n)) - var _low = (low >>> n) | (high << (32 - n)) - - this._a00 = _low & 0xFFFF - this._a16 = _low >>> 16 - this._a32 = _high & 0xFFFF - this._a48 = _high >>> 16 - - return this - } - - /** - * Clone the current _UINT64_ - * @method clone - * @return {Object} cloned UINT64 - */ - UINT64.prototype.clone = function () { - return new UINT64(this._a00, this._a16, this._a32, this._a48) - } - - if (typeof define != 'undefined' && define.amd) { - // AMD / RequireJS - define([], function () { - return UINT64 - }) - } else if (typeof module != 'undefined' && module.exports) { - // Node.js - module.exports = UINT64 - } else { - // Browser - root['UINT64'] = UINT64 - } - -})(this) - -},{}],8:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - -},{}],9:[function(require,module,exports){ -arguments[4][5][0].apply(exports,arguments) -},{"./lib/uint32":10,"./lib/uint64":11,"dup":5}],10:[function(require,module,exports){ -arguments[4][6][0].apply(exports,arguments) -},{"dup":6}],11:[function(require,module,exports){ -arguments[4][7][0].apply(exports,arguments) -},{"dup":7}],12:[function(require,module,exports){ -(function (Buffer){ -/** - xxHash implementation in pure Javascript - - Copyright (C) 2013, Pierre Curto - MIT license - */ -;(function (root) { - - var UINT32 = require('cuint').UINT32 - - /* - Merged this sequence of method calls as it speeds up - the calculations by a factor of 2 - */ - // this.v1.add( other.multiply(PRIME32_2) ).rotl(13).multiply(PRIME32_1); - UINT32.prototype.xxh_update = function (low, high) { - var b00 = PRIME32_2._low - var b16 = PRIME32_2._high - - var c16, c00 - c00 = low * b00 - c16 = c00 >>> 16 - - c16 += high * b00 - c16 &= 0xFFFF // Not required but improves performance - c16 += low * b16 - - var a00 = this._low + (c00 & 0xFFFF) - var a16 = a00 >>> 16 - - a16 += this._high + (c16 & 0xFFFF) - - var v = (a16 << 16) | (a00 & 0xFFFF) - v = (v << 13) | (v >>> 19) - - a00 = v & 0xFFFF - a16 = v >>> 16 - - b00 = PRIME32_1._low - b16 = PRIME32_1._high - - c00 = a00 * b00 - c16 = c00 >>> 16 - - c16 += a16 * b00 - c16 &= 0xFFFF // Not required but improves performance - c16 += a00 * b16 - - this._low = c00 & 0xFFFF - this._high = c16 & 0xFFFF - } - - /* - * Constants - */ - var PRIME32_1 = UINT32( '2654435761' ) - var PRIME32_2 = UINT32( '2246822519' ) - var PRIME32_3 = UINT32( '3266489917' ) - var PRIME32_4 = UINT32( '668265263' ) - var PRIME32_5 = UINT32( '374761393' ) - - var PRIME32_1plus2 = PRIME32_1.clone().add(PRIME32_2) - - /** - * Convert string to proper UTF-8 array - * @param str Input string - * @returns {Uint8Array} UTF8 array is returned as uint8 array - */ - function toUTF8Array (str) { - var utf8 = [] - for (var i=0, n=str.length; i < n; i++) { - var charcode = str.charCodeAt(i) - if (charcode < 0x80) utf8.push(charcode) - else if (charcode < 0x800) { - utf8.push(0xc0 | (charcode >> 6), - 0x80 | (charcode & 0x3f)) - } - else if (charcode < 0xd800 || charcode >= 0xe000) { - utf8.push(0xe0 | (charcode >> 12), - 0x80 | ((charcode>>6) & 0x3f), - 0x80 | (charcode & 0x3f)) - } - // surrogate pair - else { - i++; - // UTF-16 encodes 0x10000-0x10FFFF by - // subtracting 0x10000 and splitting the - // 20 bits of 0x0-0xFFFFF into two halves - charcode = 0x10000 + (((charcode & 0x3ff)<<10) - | (str.charCodeAt(i) & 0x3ff)) - utf8.push(0xf0 | (charcode >>18), - 0x80 | ((charcode>>12) & 0x3f), - 0x80 | ((charcode>>6) & 0x3f), - 0x80 | (charcode & 0x3f)) - } - } - - return new Uint8Array(utf8) - } - - /** - * XXH object used as a constructor or a function - * @constructor - * or - * @param {Object|String} input data - * @param {Number|UINT32} seed - * @return ThisExpression - * or - * @return {UINT32} xxHash - */ - function XXH () { - if (arguments.length == 2) - return new XXH( arguments[1] ).update( arguments[0] ).digest() - - if (!(this instanceof XXH)) - return new XXH( arguments[0] ) - - init.call(this, arguments[0]) - } - - /** - * Initialize the XXH instance with the given seed - * @method init - * @param {Number|Object} seed as a number or an unsigned 32 bits integer - * @return ThisExpression - */ - function init (seed) { - this.seed = seed instanceof UINT32 ? seed.clone() : UINT32(seed) - this.v1 = this.seed.clone().add(PRIME32_1plus2) - this.v2 = this.seed.clone().add(PRIME32_2) - this.v3 = this.seed.clone() - this.v4 = this.seed.clone().subtract(PRIME32_1) - this.total_len = 0 - this.memsize = 0 - this.memory = null - - return this - } - XXH.prototype.init = init - - /** - * Add data to be computed for the XXH hash - * @method update - * @param {String|Buffer|ArrayBuffer} input as a string or nodejs Buffer or ArrayBuffer - * @return ThisExpression - */ - XXH.prototype.update = function (input) { - var isString = typeof input == 'string' - var isArrayBuffer - - // Convert all strings to utf-8 first (issue #5) - if (isString) { - input = toUTF8Array(input) - isString = false - isArrayBuffer = true - } - - if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer) - { - isArrayBuffer = true - input = new Uint8Array(input); - } - - var p = 0 - var len = input.length - var bEnd = p + len - - if (len == 0) return this - - this.total_len += len - - if (this.memsize == 0) - { - if (isString) { - this.memory = '' - } else if (isArrayBuffer) { - this.memory = new Uint8Array(16) - } else { - this.memory = new Buffer(16) - } - } - - if (this.memsize + len < 16) // fill in tmp buffer - { - // XXH_memcpy(this.memory + this.memsize, input, len) - if (isString) { - this.memory += input - } else if (isArrayBuffer) { - this.memory.set( input.subarray(0, len), this.memsize ) - } else { - input.copy( this.memory, this.memsize, 0, len ) - } - - this.memsize += len - return this - } - - if (this.memsize > 0) // some data left from previous update - { - // XXH_memcpy(this.memory + this.memsize, input, 16-this.memsize); - if (isString) { - this.memory += input.slice(0, 16 - this.memsize) - } else if (isArrayBuffer) { - this.memory.set( input.subarray(0, 16 - this.memsize), this.memsize ) - } else { - input.copy( this.memory, this.memsize, 0, 16 - this.memsize ) - } - - var p32 = 0 - if (isString) { - this.v1.xxh_update( - (this.memory.charCodeAt(p32+1) << 8) | this.memory.charCodeAt(p32) - , (this.memory.charCodeAt(p32+3) << 8) | this.memory.charCodeAt(p32+2) - ) - p32 += 4 - this.v2.xxh_update( - (this.memory.charCodeAt(p32+1) << 8) | this.memory.charCodeAt(p32) - , (this.memory.charCodeAt(p32+3) << 8) | this.memory.charCodeAt(p32+2) - ) - p32 += 4 - this.v3.xxh_update( - (this.memory.charCodeAt(p32+1) << 8) | this.memory.charCodeAt(p32) - , (this.memory.charCodeAt(p32+3) << 8) | this.memory.charCodeAt(p32+2) - ) - p32 += 4 - this.v4.xxh_update( - (this.memory.charCodeAt(p32+1) << 8) | this.memory.charCodeAt(p32) - , (this.memory.charCodeAt(p32+3) << 8) | this.memory.charCodeAt(p32+2) - ) - } else { - this.v1.xxh_update( - (this.memory[p32+1] << 8) | this.memory[p32] - , (this.memory[p32+3] << 8) | this.memory[p32+2] - ) - p32 += 4 - this.v2.xxh_update( - (this.memory[p32+1] << 8) | this.memory[p32] - , (this.memory[p32+3] << 8) | this.memory[p32+2] - ) - p32 += 4 - this.v3.xxh_update( - (this.memory[p32+1] << 8) | this.memory[p32] - , (this.memory[p32+3] << 8) | this.memory[p32+2] - ) - p32 += 4 - this.v4.xxh_update( - (this.memory[p32+1] << 8) | this.memory[p32] - , (this.memory[p32+3] << 8) | this.memory[p32+2] - ) - } - - p += 16 - this.memsize - this.memsize = 0 - if (isString) this.memory = '' - } - - if (p <= bEnd - 16) - { - var limit = bEnd - 16 - - do - { - if (isString) { - this.v1.xxh_update( - (input.charCodeAt(p+1) << 8) | input.charCodeAt(p) - , (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) - ) - p += 4 - this.v2.xxh_update( - (input.charCodeAt(p+1) << 8) | input.charCodeAt(p) - , (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) - ) - p += 4 - this.v3.xxh_update( - (input.charCodeAt(p+1) << 8) | input.charCodeAt(p) - , (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) - ) - p += 4 - this.v4.xxh_update( - (input.charCodeAt(p+1) << 8) | input.charCodeAt(p) - , (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) - ) - } else { - this.v1.xxh_update( - (input[p+1] << 8) | input[p] - , (input[p+3] << 8) | input[p+2] - ) - p += 4 - this.v2.xxh_update( - (input[p+1] << 8) | input[p] - , (input[p+3] << 8) | input[p+2] - ) - p += 4 - this.v3.xxh_update( - (input[p+1] << 8) | input[p] - , (input[p+3] << 8) | input[p+2] - ) - p += 4 - this.v4.xxh_update( - (input[p+1] << 8) | input[p] - , (input[p+3] << 8) | input[p+2] - ) - } - p += 4 - } while (p <= limit) - } - - if (p < bEnd) - { - // XXH_memcpy(this.memory, p, bEnd-p); - if (isString) { - this.memory += input.slice(p) - } else if (isArrayBuffer) { - this.memory.set( input.subarray(p, bEnd), this.memsize ) - } else { - input.copy( this.memory, this.memsize, p, bEnd ) - } - - this.memsize = bEnd - p - } - - return this - } - - /** - * Finalize the XXH computation. The XXH instance is ready for reuse for the given seed - * @method digest - * @return {UINT32} xxHash - */ - XXH.prototype.digest = function () { - var input = this.memory - var isString = typeof input == 'string' - var p = 0 - var bEnd = this.memsize - var h32, h - var u = new UINT32 - - if (this.total_len >= 16) - { - h32 = this.v1.rotl(1).add( this.v2.rotl(7).add( this.v3.rotl(12).add( this.v4.rotl(18) ) ) ) - } - else - { - h32 = this.seed.add( PRIME32_5 ) - } - - h32.add( u.fromNumber(this.total_len) ) - - while (p <= bEnd - 4) - { - if (isString) { - u.fromBits( - (input.charCodeAt(p+1) << 8) | input.charCodeAt(p) - , (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) - ) - } else { - u.fromBits( - (input[p+1] << 8) | input[p] - , (input[p+3] << 8) | input[p+2] - ) - } - h32 - .add( u.multiply(PRIME32_3) ) - .rotl(17) - .multiply( PRIME32_4 ) - p += 4 - } - - while (p < bEnd) - { - u.fromBits( isString ? input.charCodeAt(p++) : input[p++], 0 ) - h32 - .add( u.multiply(PRIME32_5) ) - .rotl(11) - .multiply(PRIME32_1) - } - - h = h32.clone().shiftRight(15) - h32.xor(h).multiply(PRIME32_2) - - h = h32.clone().shiftRight(13) - h32.xor(h).multiply(PRIME32_3) - - h = h32.clone().shiftRight(16) - h32.xor(h) - - // Reset the state - this.init( this.seed ) - - return h32 - } - - if (typeof define != 'undefined' && define.amd) { - // AMD / RequireJS - define([], function () { - return XXH - }) - } else if (typeof module != 'undefined' && module.exports) { - // Node.js - module.exports = XXH - } else { - // Browser - root['XXH'] = XXH - } - -})(this) - -}).call(this,require("buffer").Buffer) -},{"buffer":"buffer","cuint":9}],"buffer":[function(require,module,exports){ -(function (global){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -var base64 = require('base64-js') -var ieee754 = require('ieee754') -var isArray = require('isarray') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 -Buffer.poolSize = 8192 // not used by this implementation - -var rootParent = {} - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Due to various browser bugs, sometimes the Object implementation will be used even - * when the browser supports typed arrays. - * - * Note: - * - * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property - * on objects. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they - * get the Object implementation, which is slower but behaves correctly. - */ -Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined - ? global.TYPED_ARRAY_SUPPORT - : typedArraySupport() - -function typedArraySupport () { - function Bar () {} - try { - var arr = new Uint8Array(1) - arr.foo = function () { return 42 } - arr.constructor = Bar - return arr.foo() === 42 && // typed array instances can be augmented - arr.constructor === Bar && // constructor can be set - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } -} - -function kMaxLength () { - return Buffer.TYPED_ARRAY_SUPPORT - ? 0x7fffffff - : 0x3fffffff -} - -/** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ -function Buffer (arg) { - if (!(this instanceof Buffer)) { - // Avoid going through an ArgumentsAdaptorTrampoline in the common case. - if (arguments.length > 1) return new Buffer(arg, arguments[1]) - return new Buffer(arg) - } - - if (!Buffer.TYPED_ARRAY_SUPPORT) { - this.length = 0 - this.parent = undefined - } - - // Common case. - if (typeof arg === 'number') { - return fromNumber(this, arg) - } - - // Slightly less common case. - if (typeof arg === 'string') { - return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') - } - - // Unusual. - return fromObject(this, arg) -} - -function fromNumber (that, length) { - that = allocate(that, length < 0 ? 0 : checked(length) | 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < length; i++) { - that[i] = 0 - } - } - return that -} - -function fromString (that, string, encoding) { - if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' - - // Assumption: byteLength() return value is always < kMaxLength. - var length = byteLength(string, encoding) | 0 - that = allocate(that, length) - - that.write(string, encoding) - return that -} - -function fromObject (that, object) { - if (Buffer.isBuffer(object)) return fromBuffer(that, object) - - if (isArray(object)) return fromArray(that, object) - - if (object == null) { - throw new TypeError('must start with number, buffer, array or string') - } - - if (typeof ArrayBuffer !== 'undefined') { - if (object.buffer instanceof ArrayBuffer) { - return fromTypedArray(that, object) - } - if (object instanceof ArrayBuffer) { - return fromArrayBuffer(that, object) - } - } - - if (object.length) return fromArrayLike(that, object) - - return fromJsonObject(that, object) -} - -function fromBuffer (that, buffer) { - var length = checked(buffer.length) | 0 - that = allocate(that, length) - buffer.copy(that, 0, 0, length) - return that -} - -function fromArray (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that -} - -// Duplicate of fromArray() to keep fromArray() monomorphic. -function fromTypedArray (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - // Truncating the elements is probably not what people expect from typed - // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior - // of the old Buffer constructor. - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that -} - -function fromArrayBuffer (that, array) { - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - array.byteLength - that = Buffer._augment(new Uint8Array(array)) - } else { - // Fallback: Return an object instance of the Buffer class - that = fromTypedArray(that, new Uint8Array(array)) - } - return that -} - -function fromArrayLike (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that -} - -// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. -// Returns a zero-length buffer for inputs that don't conform to the spec. -function fromJsonObject (that, object) { - var array - var length = 0 - - if (object.type === 'Buffer' && isArray(object.data)) { - array = object.data - length = checked(array.length) | 0 - } - that = allocate(that, length) - - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that -} - -if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array -} else { - // pre-set for values that may exist in the future - Buffer.prototype.length = undefined - Buffer.prototype.parent = undefined -} - -function allocate (that, length) { - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = Buffer._augment(new Uint8Array(length)) - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - that.length = length - that._isBuffer = true - } - - var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 - if (fromPool) that.parent = rootParent - - return that -} - -function checked (length) { - // Note: cannot use `length < kMaxLength` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= kMaxLength()) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength().toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (subject, encoding) { - if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) - - var buf = new Buffer(subject, encoding) - delete buf.parent - return buf -} - -Buffer.isBuffer = function isBuffer (b) { - return !!(b != null && b._isBuffer) -} - -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - var i = 0 - var len = Math.min(x, y) - while (i < len) { - if (a[i] !== b[i]) break - - ++i - } - - if (i !== len) { - x = a[i] - y = b[i] - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'raw': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') - - if (list.length === 0) { - return new Buffer(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; i++) { - length += list[i].length - } - } - - var buf = new Buffer(length) - var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length - } - return buf -} - -function byteLength (string, encoding) { - if (typeof string !== 'string') string = '' + string - - var len = string.length - if (len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'binary': - // Deprecated - case 'raw': - case 'raws': - return len - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - start = start | 0 - end = end === undefined || end === Infinity ? this.length : end | 0 - - if (!encoding) encoding = 'utf8' - if (start < 0) start = 0 - if (end > this.length) end = this.length - if (end <= start) return '' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'binary': - return binarySlice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toString = function toString () { - var length = this.length | 0 - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' -} - -Buffer.prototype.compare = function compare (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return 0 - return Buffer.compare(this, b) -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset) { - if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff - else if (byteOffset < -0x80000000) byteOffset = -0x80000000 - byteOffset >>= 0 - - if (this.length === 0) return -1 - if (byteOffset >= this.length) return -1 - - // Negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) - - if (typeof val === 'string') { - if (val.length === 0) return -1 // special case: looking for empty string always fails - return String.prototype.indexOf.call(this, val, byteOffset) - } - if (Buffer.isBuffer(val)) { - return arrayIndexOf(this, val, byteOffset) - } - if (typeof val === 'number') { - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { - return Uint8Array.prototype.indexOf.call(this, val, byteOffset) - } - return arrayIndexOf(this, [ val ], byteOffset) - } - - function arrayIndexOf (arr, val, byteOffset) { - var foundIndex = -1 - for (var i = 0; byteOffset + i < arr.length; i++) { - if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex - } else { - foundIndex = -1 - } - } - return -1 - } - - throw new TypeError('val must be string, number or Buffer') -} - -// `get` is deprecated -Buffer.prototype.get = function get (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) -} - -// `set` is deprecated -Buffer.prototype.set = function set (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - if (strLen % 2 !== 0) throw new Error('Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; i++) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) throw new Error('Invalid hex string') - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function binaryWrite (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset | 0 - if (isFinite(length)) { - length = length | 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - // legacy write(string, encoding, offset, length) - remove in v0.13 - } else { - var swap = encoding - encoding = offset - offset = length | 0 - length = swap - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'binary': - return binaryWrite(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function binarySlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; i++) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = Buffer._augment(this.subarray(start, end)) - } else { - var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start] - } - } - - if (newBuf.length) newBuf.parent = this.parent || this - - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = (value & 0xff) - return offset + 1 -} - -function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 -} - -function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = value < 0 ? 1 : 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = value < 0 ? 1 : 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') - if (offset < 0) throw new RangeError('index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - var i - - if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (i = len - 1; i >= 0; i--) { - target[i + targetStart] = this[i + start] - } - } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - // ascending copy from start - for (i = 0; i < len; i++) { - target[i + targetStart] = this[i + start] - } - } else { - target._set(this.subarray(start, start + len), targetStart) - } - - return len -} - -// fill(value, start=0, end=buffer.length) -Buffer.prototype.fill = function fill (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length - - if (end < start) throw new RangeError('end < start') - - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return - - if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') - if (end < 0 || end > this.length) throw new RangeError('end out of bounds') - - var i - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value - } - } else { - var bytes = utf8ToBytes(value.toString()) - var len = bytes.length - for (i = start; i < end; i++) { - this[i] = bytes[i % len] - } - } - - return this -} - -/** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ -Buffer.prototype.toArrayBuffer = function toArrayBuffer () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new TypeError('Buffer.toArrayBuffer not supported in this browser') - } -} - -// HELPER FUNCTIONS -// ================ - -var BP = Buffer.prototype - -/** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ -Buffer._augment = function _augment (arr) { - arr.constructor = Buffer - arr._isBuffer = true - - // save reference to original Uint8Array set method before overwriting - arr._set = arr.set - - // deprecated - arr.get = BP.get - arr.set = BP.set - - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.equals = BP.equals - arr.compare = BP.compare - arr.indexOf = BP.indexOf - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUIntLE = BP.readUIntLE - arr.readUIntBE = BP.readUIntBE - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readIntLE = BP.readIntLE - arr.readIntBE = BP.readIntBE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUIntLE = BP.writeUIntLE - arr.writeUIntBE = BP.writeUIntBE - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeIntLE = BP.writeIntLE - arr.writeIntBE = BP.writeIntBE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer - - return arr -} - -var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; i++) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; i++) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"base64-js":3,"ieee754":8,"isarray":4}]},{},[2]); diff --git a/build/lz4.min.js b/build/lz4.min.js deleted file mode 100644 index ae798f9b..00000000 --- a/build/lz4.min.js +++ /dev/null @@ -1,2 +0,0 @@ -require=function t(r,e,i){function n(o,s){if(!e[o]){if(!r[o]){var a="function"==typeof require&&require;if(!s&&a)return a(o,!0);if(h)return h(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=e[o]={exports:{}};r[o][0].call(f.exports,function(t){var e=r[o][1][t];return n(e?e:t)},f,f.exports,t,r,e,i)}return e[o].exports}for(var h="function"==typeof require&&require,o=0;o>8&255},e.blockChecksum=function(t){return i(t,n).toNumber()},e.streamChecksum=function(t,r){return null===t?r.digest().toNumber():(null===r&&(r=i(n)),r.update(t))},e.readUInt32LE=function(t,r){return t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24},e.bindings=t("./binding")},{"./binding":1,xxhashjs:12}],1:[function(t,r,e){function i(t,r,i,o,a,u){var l=a,y=u-a,m=0;if(t.length>=n)throw new Error("input too large");if(t.length>f){var w=e.compressBound(t.length);if(w>y)throw Error("output too small: "+y+" < "+w);for(var v=1,E=(1<i+h;){var b=t[i+1]<<8|t[i],I=t[i+3]<<8|t[i+2],B=Math.imul(b|I<<16,g)>>>s,R=o[B]-1;if(o[B]=i+1,0>R||i-R>>>16>0||(t[R+3]<<8|t[R+2])!=I||(t[R+1]<<8|t[R])!=b)v=E++>>c,i+=v;else{E=(1<i&&t[i]==t[R];)i++,R++;T=i-T;var C=p>T?T:p;if(U>=d){r[l++]=(d<<_)+C;for(var P=U-d;P>254;P-=255)r[l++]=255;r[l++]=P}else r[l++]=(U<<_)+C;for(var L=0;U>L;L++)r[l++]=t[m+L];if(r[l++]=x,r[l++]=x>>8,T>=p){for(T-=p;T>=255;)T-=255,r[l++]=255;r[l++]=T}m=i}}}if(0==m)return 0;if(U=t.length-m,U>=d){r[l++]=d<<_;for(var S=U-d;S>254;S-=255)r[l++]=255;r[l++]=S}else r[l++]=U<<_;for(i=m;i>>16,i=65535&t,n=r>>>16,h=65535&r;return i*h+(e*h+i*n<<16)|0}),e.uncompress=function(t,r,e,i){e=e||0,i=i||t.length-e;for(var n=e,h=i,o=0;h>n;){var s=t[n++],a=s>>4;if(a>0){for(var u=a+240;255===u;)u=t[n++],a+=u;for(var f=n+a;f>n;)r[o++]=t[n++];if(n===h)return o}var c=t[n++]|t[n++]<<8;if(0===c||c>o)return-(n-2);for(var _=15&s,u=_+240;255===u;)u=t[n++],_+=u;for(var p=o-c,f=o+_+4;f>o;)r[o++]=r[p++]}return o};var n=2113929216,h=4,o=16,s=8*h-o,a=1<n?0:t+t/255+16|0},e.compress=function(t,r,e,n){for(var h=new Array(a),o=0;a>o;o++)h[o]=0;return i(t,r,0,h,e||0,n||r.length)},e.compressHC=e.compress,e.compressDependent=i},{cuint:5}],2:[function(t,r,e){},{}],3:[function(t,r,e){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function r(t){var r=t.charCodeAt(0);return r===o||r===c?62:r===s||r===_?63:a>r?-1:a+10>r?r-a+26+26:f+26>r?r-f:u+26>r?r-u+26:void 0}function e(t){function e(t){u[c++]=t}var i,n,o,s,a,u;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;a="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,u=new h(3*t.length/4-a),o=a>0?t.length-4:t.length;var c=0;for(i=0,n=0;o>i;i+=4,n+=3)s=r(t.charAt(i))<<18|r(t.charAt(i+1))<<12|r(t.charAt(i+2))<<6|r(t.charAt(i+3)),e((16711680&s)>>16),e((65280&s)>>8),e(255&s);return 2===a?(s=r(t.charAt(i))<<2|r(t.charAt(i+1))>>4,e(255&s)):1===a&&(s=r(t.charAt(i))<<10|r(t.charAt(i+1))<<4|r(t.charAt(i+2))>>2,e(s>>8&255),e(255&s)),u}function n(t){function r(t){return i.charAt(t)}function e(t){return r(t>>18&63)+r(t>>12&63)+r(t>>6&63)+r(63&t)}var n,h,o,s=t.length%3,a="";for(n=0,o=t.length-s;o>n;n+=3)h=(t[n]<<16)+(t[n+1]<<8)+t[n+2],a+=e(h);switch(s){case 1:h=t[t.length-1],a+=r(h>>2),a+=r(h<<4&63),a+="==";break;case 2:h=(t[t.length-2]<<8)+t[t.length-1],a+=r(h>>10),a+=r(h>>4&63),a+=r(h<<2&63),a+="="}return a}var h="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),s="/".charCodeAt(0),a="0".charCodeAt(0),u="a".charCodeAt(0),f="A".charCodeAt(0),c="-".charCodeAt(0),_="_".charCodeAt(0);t.toByteArray=e,t.fromByteArray=n}("undefined"==typeof e?this.base64js={}:e)},{}],4:[function(t,r,e){var i={}.toString;r.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},{}],5:[function(t,r,e){e.UINT32=t("./lib/uint32"),e.UINT64=t("./lib/uint64")},{"./lib/uint32":6,"./lib/uint64":7}],6:[function(t,r,e){!function(t){function e(t,r){return this instanceof e?(this._low=0,this._high=0,this.remainder=null,"undefined"==typeof r?n.call(this,t):"string"==typeof t?h.call(this,t,r):void i.call(this,t,r)):new e(t,r)}function i(t,r){return this._low=0|t,this._high=0|r,this}function n(t){return this._low=65535&t,this._high=t>>>16,this}function h(t,r){var e=parseInt(t,r||10);return this._low=65535&e,this._high=e>>>16,this}({36:e(Math.pow(36,5)),16:e(Math.pow(16,7)),10:e(Math.pow(10,9)),2:e(Math.pow(2,30))}),{36:e(36),16:e(16),10:e(10),2:e(2)};e.prototype.fromBits=i,e.prototype.fromNumber=n,e.prototype.fromString=h,e.prototype.toNumber=function(){return 65536*this._high+this._low},e.prototype.toString=function(t){return this.toNumber().toString(t||10)},e.prototype.add=function(t){var r=this._low+t._low,e=r>>>16;return e+=this._high+t._high,this._low=65535&r,this._high=65535&e,this},e.prototype.subtract=function(t){return this.add(t.clone().negate())},e.prototype.multiply=function(t){var r,e,i=this._high,n=this._low,h=t._high,o=t._low;return e=n*o,r=e>>>16,r+=i*o,r&=65535,r+=n*h,this._low=65535&e,this._high=65535&r,this},e.prototype.div=function(t){if(0==t._low&&0==t._high)throw Error("division by zero");if(0==t._high&&1==t._low)return this.remainder=new e(0),this;if(t.gt(this))return this.remainder=this.clone(),this._low=0,this._high=0,this;if(this.eq(t))return this.remainder=new e(0),this._low=1,this._high=0,this;for(var r=t.clone(),i=-1;!this.lt(r);)r.shiftLeft(1,!0),i++;for(this.remainder=this.clone(),this._low=0,this._high=0;i>=0;i--)r.shiftRight(1),this.remainder.lt(r)||(this.remainder.subtract(r),i>=16?this._high|=1<>>16)&65535,this},e.prototype.equals=e.prototype.eq=function(t){return this._low==t._low&&this._high==t._high},e.prototype.greaterThan=e.prototype.gt=function(t){return this._high>t._high?!0:this._hight._low},e.prototype.lessThan=e.prototype.lt=function(t){return this._hight._high?!1:this._low16?(this._low=this._high>>t-16,this._high=0):16==t?(this._low=this._high,this._high=0):(this._low=this._low>>t|this._high<<16-t&65535,this._high>>=t),this},e.prototype.shiftLeft=e.prototype.shiftl=function(t,r){return t>16?(this._high=this._low<>16-t,this._low=this._low<>>32-t,this._low=65535&r,this._high=r>>>16,this},e.prototype.rotateRight=e.prototype.rotr=function(t){var r=this._high<<16|this._low;return r=r>>>t|r<<32-t,this._low=65535&r,this._high=r>>>16,this},e.prototype.clone=function(){return new e(this._low,this._high)},"undefined"!=typeof define&&define.amd?define([],function(){return e}):"undefined"!=typeof r&&r.exports?r.exports=e:t.UINT32=e}(this)},{}],7:[function(t,r,e){!function(t){function e(t,r,o,s){return this instanceof e?(this.remainder=null,"string"==typeof t?h.call(this,t,r):"undefined"==typeof r?n.call(this,t):void i.apply(this,arguments)):new e(t,r,o,s)}function i(t,r,e,i){return"undefined"==typeof e?(this._a00=65535&t,this._a16=t>>>16,this._a32=65535&r,this._a48=r>>>16,this):(this._a00=0|t,this._a16=0|r,this._a32=0|e,this._a48=0|i,this)}function n(t){return this._a00=65535&t,this._a16=t>>>16,this._a32=0,this._a48=0,this}function h(t,r){r=r||10,this._a00=0,this._a16=0,this._a32=0,this._a48=0;for(var i=o[r]||new e(Math.pow(r,5)),n=0,h=t.length;h>n;n+=5){var s=Math.min(5,h-n),a=parseInt(t.slice(n,n+s),r);this.multiply(5>s?new e(Math.pow(r,s)):i).add(new e(a))}return this}var o={16:e(Math.pow(16,5)),10:e(Math.pow(10,5)),2:e(Math.pow(2,5))},s={16:e(16),10:e(10),2:e(2)};e.prototype.fromBits=i,e.prototype.fromNumber=n,e.prototype.fromString=h,e.prototype.toNumber=function(){return 65536*this._a16+this._a00},e.prototype.toString=function(t){t=t||10;var r=s[t]||new e(t);if(!this.gt(r))return this.toNumber().toString(t);for(var i=this.clone(),n=new Array(64),h=63;h>=0&&(i.div(r),n[h]=i.remainder.toNumber().toString(t),i.gt(r));h--);return n[h-1]=i.toNumber().toString(t),n.join("")},e.prototype.add=function(t){var r=this._a00+t._a00,e=r>>>16;e+=this._a16+t._a16;var i=e>>>16;i+=this._a32+t._a32;var n=i>>>16;return n+=this._a48+t._a48,this._a00=65535&r,this._a16=65535&e,this._a32=65535&i,this._a48=65535&n,this},e.prototype.subtract=function(t){return this.add(t.clone().negate())},e.prototype.multiply=function(t){var r=this._a00,e=this._a16,i=this._a32,n=this._a48,h=t._a00,o=t._a16,s=t._a32,a=t._a48,u=r*h,f=u>>>16;f+=r*o;var c=f>>>16;f&=65535,f+=e*h,c+=f>>>16,c+=r*s;var _=c>>>16;return c&=65535,c+=e*o,_+=c>>>16,c&=65535,c+=i*h,_+=c>>>16,_+=r*a,_&=65535,_+=e*s,_&=65535,_+=i*o,_&=65535,_+=n*h,this._a00=65535&u,this._a16=65535&f,this._a32=65535&c,this._a48=65535&_,this},e.prototype.div=function(t){if(0==t._a16&&0==t._a32&&0==t._a48){if(0==t._a00)throw Error("division by zero");if(1==t._a00)return this.remainder=new e(0),this}if(t.gt(this))return this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0,this;if(this.eq(t))return this.remainder=new e(0),this._a00=1,this._a16=0,this._a32=0,this._a48=0,this;for(var r=t.clone(),i=-1;!this.lt(r);)r.shiftLeft(1,!0),i++;for(this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0;i>=0;i--)r.shiftRight(1),this.remainder.lt(r)||(this.remainder.subtract(r),i>=48?this._a48|=1<=32?this._a32|=1<=16?this._a16|=1<>>16),this._a16=65535&t,t=(65535&~this._a32)+(t>>>16),this._a32=65535&t,this._a48=~this._a48+(t>>>16)&65535,this},e.prototype.equals=e.prototype.eq=function(t){return this._a48==t._a48&&this._a00==t._a00&&this._a32==t._a32&&this._a16==t._a16},e.prototype.greaterThan=e.prototype.gt=function(t){return this._a48>t._a48?!0:this._a48t._a32?!0:this._a32t._a16?!0:this._a16t._a00},e.prototype.lessThan=e.prototype.lt=function(t){return this._a48t._a48?!1:this._a32t._a32?!1:this._a16t._a16?!1:this._a00=48?(this._a00=this._a48>>t-48,this._a16=0,this._a32=0,this._a48=0):t>=32?(t-=32,this._a00=65535&(this._a32>>t|this._a48<<16-t),this._a16=this._a48>>t&65535,this._a32=0,this._a48=0):t>=16?(t-=16,this._a00=65535&(this._a16>>t|this._a32<<16-t),this._a16=65535&(this._a32>>t|this._a48<<16-t),this._a32=this._a48>>t&65535,this._a48=0):(this._a00=65535&(this._a00>>t|this._a16<<16-t),this._a16=65535&(this._a16>>t|this._a32<<16-t),this._a32=65535&(this._a32>>t|this._a48<<16-t),this._a48=this._a48>>t&65535),this},e.prototype.shiftLeft=e.prototype.shiftl=function(t,r){return t%=64,t>=48?(this._a48=this._a00<=32?(t-=32,this._a48=this._a16<>16-t,this._a32=this._a00<=16?(t-=16,this._a48=this._a32<>16-t,this._a32=65535&(this._a16<>16-t),this._a16=this._a00<>16-t,this._a32=65535&(this._a32<>16-t),this._a16=65535&(this._a16<>16-t),this._a00=this._a00<=32){var r=this._a00;if(this._a00=this._a32,this._a32=r,r=this._a48,this._a48=this._a16,this._a16=r,32==t)return this;t-=32}var e=this._a48<<16|this._a32,i=this._a16<<16|this._a00,n=e<>>32-t,h=i<>>32-t;return this._a00=65535&h,this._a16=h>>>16,this._a32=65535&n,this._a48=n>>>16,this},e.prototype.rotateRight=e.prototype.rotr=function(t){if(t%=64,0==t)return this;if(t>=32){var r=this._a00;if(this._a00=this._a32,this._a32=r,r=this._a48,this._a48=this._a16,this._a16=r,32==t)return this;t-=32}var e=this._a48<<16|this._a32,i=this._a16<<16|this._a00,n=e>>>t|i<<32-t,h=i>>>t|e<<32-t;return this._a00=65535&h,this._a16=h>>>16,this._a32=65535&n,this._a48=n>>>16,this},e.prototype.clone=function(){return new e(this._a00,this._a16,this._a32,this._a48)},"undefined"!=typeof define&&define.amd?define([],function(){return e}):"undefined"!=typeof r&&r.exports?r.exports=e:t.UINT64=e}(this)},{}],8:[function(t,r,e){e.read=function(t,r,e,i,n){var h,o,s=8*n-i-1,a=(1<>1,f=-7,c=e?n-1:0,_=e?-1:1,p=t[r+c];for(c+=_,h=p&(1<<-f)-1,p>>=-f,f+=s;f>0;h=256*h+t[r+c],c+=_,f-=8);for(o=h&(1<<-f)-1,h>>=-f,f+=i;f>0;o=256*o+t[r+c],c+=_,f-=8);if(0===h)h=1-u;else{if(h===a)return o?NaN:(p?-1:1)*(1/0);o+=Math.pow(2,i),h-=u}return(p?-1:1)*o*Math.pow(2,h-i)},e.write=function(t,r,e,i,n,h){var o,s,a,u=8*h-n-1,f=(1<>1,_=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:h-1,l=i?1:-1,d=0>r||0===r&&0>1/r?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,o=f):(o=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-o))<1&&(o--,a*=2),r+=o+c>=1?_/a:_*Math.pow(2,1-c),r*a>=2&&(o++,a/=2),o+c>=f?(s=0,o=f):o+c>=1?(s=(r*a-1)*Math.pow(2,n),o+=c):(s=r*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;t[e+p]=255&s,p+=l,s/=256,n-=8);for(o=o<0;t[e+p]=255&o,p+=l,o/=256,u-=8);t[e+p-l]|=128*d}},{}],9:[function(t,r,e){arguments[4][5][0].apply(e,arguments)},{"./lib/uint32":10,"./lib/uint64":11,dup:5}],10:[function(t,r,e){arguments[4][6][0].apply(e,arguments)},{dup:6}],11:[function(t,r,e){arguments[4][7][0].apply(e,arguments)},{dup:7}],12:[function(t,r,e){(function(e){!function(i){function n(t){for(var r=[],e=0,i=t.length;i>e;e++){var n=t.charCodeAt(e);128>n?r.push(n):2048>n?r.push(192|n>>6,128|63&n):55296>n||n>=57344?r.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),r.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return new Uint8Array(r)}function h(){return 2==arguments.length?new h(arguments[1]).update(arguments[0]).digest():this instanceof h?void o.call(this,arguments[0]):new h(arguments[0])}function o(t){return this.seed=t instanceof s?t.clone():s(t),this.v1=this.seed.clone().add(p),this.v2=this.seed.clone().add(u),this.v3=this.seed.clone(),this.v4=this.seed.clone().subtract(a),this.total_len=0,this.memsize=0,this.memory=null,this}var s=t("cuint").UINT32;s.prototype.xxh_update=function(t,r){var e,i,n=u._low,h=u._high;i=t*n,e=i>>>16,e+=r*n,e&=65535,e+=t*h;var o=this._low+(65535&i),s=o>>>16;s+=this._high+(65535&e);var f=s<<16|65535&o;f=f<<13|f>>>19,o=65535&f,s=f>>>16,n=a._low,h=a._high,i=o*n,e=i>>>16,e+=s*n,e&=65535,e+=o*h,this._low=65535&i,this._high=65535&e};var a=s("2654435761"),u=s("2246822519"),f=s("3266489917"),c=s("668265263"),_=s("374761393"),p=a.clone().add(u);h.prototype.init=o,h.prototype.update=function(t){var r,i="string"==typeof t;i&&(t=n(t),i=!1,r=!0),"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer&&(r=!0,t=new Uint8Array(t));var h=0,o=t.length,s=h+o;if(0==o)return this;if(this.total_len+=o,0==this.memsize&&(i?this.memory="":r?this.memory=new Uint8Array(16):this.memory=new e(16)),this.memsize+o<16)return i?this.memory+=t:r?this.memory.set(t.subarray(0,o),this.memsize):t.copy(this.memory,this.memsize,0,o),this.memsize+=o,this;if(this.memsize>0){i?this.memory+=t.slice(0,16-this.memsize):r?this.memory.set(t.subarray(0,16-this.memsize),this.memsize):t.copy(this.memory,this.memsize,0,16-this.memsize);var a=0;i?(this.v1.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v2.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v3.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2)),a+=4,this.v4.xxh_update(this.memory.charCodeAt(a+1)<<8|this.memory.charCodeAt(a),this.memory.charCodeAt(a+3)<<8|this.memory.charCodeAt(a+2))):(this.v1.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v2.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v3.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2]),a+=4,this.v4.xxh_update(this.memory[a+1]<<8|this.memory[a],this.memory[a+3]<<8|this.memory[a+2])),h+=16-this.memsize,this.memsize=0,i&&(this.memory="")}if(s-16>=h){var u=s-16;do i?(this.v1.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v2.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v3.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2)),h+=4,this.v4.xxh_update(t.charCodeAt(h+1)<<8|t.charCodeAt(h),t.charCodeAt(h+3)<<8|t.charCodeAt(h+2))):(this.v1.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v2.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v3.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2]),h+=4,this.v4.xxh_update(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2])),h+=4;while(u>=h)}return s>h&&(i?this.memory+=t.slice(h):r?this.memory.set(t.subarray(h,s),this.memsize):t.copy(this.memory,this.memsize,h,s),this.memsize=s-h),this},h.prototype.digest=function(){var t,r,e=this.memory,i="string"==typeof e,n=0,h=this.memsize,o=new s;for(t=this.total_len>=16?this.v1.rotl(1).add(this.v2.rotl(7).add(this.v3.rotl(12).add(this.v4.rotl(18)))):this.seed.add(_),t.add(o.fromNumber(this.total_len));h-4>=n;)i?o.fromBits(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2)):o.fromBits(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2]),t.add(o.multiply(f)).rotl(17).multiply(c),n+=4;for(;h>n;)o.fromBits(i?e.charCodeAt(n++):e[n++],0),t.add(o.multiply(_)).rotl(11).multiply(a);return r=t.clone().shiftRight(15),t.xor(r).multiply(u),r=t.clone().shiftRight(13),t.xor(r).multiply(f),r=t.clone().shiftRight(16),t.xor(r),this.init(this.seed),t},"undefined"!=typeof define&&define.amd?define([],function(){return h}):"undefined"!=typeof r&&r.exports?r.exports=h:i.XXH=h}(this)}).call(this,t("buffer").Buffer)},{buffer:"buffer",cuint:9}],buffer:[function(t,r,e){(function(r){"use strict";function i(){function t(){}try{var r=new Uint8Array(1);return r.foo=function(){return 42},r.constructor=t,42===r.foo()&&r.constructor===t&&"function"==typeof r.subarray&&0===r.subarray(1,1).byteLength}catch(e){return!1}}function n(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(t){return this instanceof h?(h.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?s(this,t,arguments.length>1?arguments[1]:"utf8"):a(this,t)):arguments.length>1?new h(t,arguments[1]):new h(t)}function o(t,r){if(t=d(t,0>r?0:0|g(r)),!h.TYPED_ARRAY_SUPPORT)for(var e=0;r>e;e++)t[e]=0;return t}function s(t,r,e){("string"!=typeof e||""===e)&&(e="utf8");var i=0|m(r,e);return t=d(t,i),t.write(r,e),t}function a(t,r){if(h.isBuffer(r))return u(t,r);if(Q(r))return f(t,r);if(null==r)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(r.buffer instanceof ArrayBuffer)return c(t,r);if(r instanceof ArrayBuffer)return _(t,r)}return r.length?p(t,r):l(t,r)}function u(t,r){var e=0|g(r.length);return t=d(t,e),r.copy(t,0,0,e),t}function f(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function c(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function _(t,r){return h.TYPED_ARRAY_SUPPORT?(r.byteLength,t=h._augment(new Uint8Array(r))):t=c(t,new Uint8Array(r)),t}function p(t,r){var e=0|g(r.length);t=d(t,e);for(var i=0;e>i;i+=1)t[i]=255&r[i];return t}function l(t,r){var e,i=0;"Buffer"===r.type&&Q(r.data)&&(e=r.data,i=0|g(e.length)),t=d(t,i);for(var n=0;i>n;n+=1)t[n]=255&e[n];return t}function d(t,r){h.TYPED_ARRAY_SUPPORT?(t=h._augment(new Uint8Array(r)),t.__proto__=h.prototype):(t.length=r,t._isBuffer=!0);var e=0!==r&&r<=h.poolSize>>>1;return e&&(t.parent=V),t}function g(t){if(t>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|t}function y(t,r){if(!(this instanceof y))return new y(t,r);var e=new h(t,r);return delete e.parent,e}function m(t,r){"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var i=!1;;)switch(r){case"ascii":case"binary":case"raw":case"raws":return e;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return H(t).length;default:if(i)return j(t).length;r=(""+r).toLowerCase(),i=!0}}function w(t,r,e){var i=!1;if(r=0|r,e=void 0===e||e===1/0?this.length:0|e,t||(t="utf8"),0>r&&(r=0),e>this.length&&(e=this.length),r>=e)return"";for(;;)switch(t){case"hex":return P(this,r,e);case"utf8":case"utf-8":return U(this,r,e);case"ascii":return T(this,r,e);case"binary":return C(this,r,e);case"base64":return R(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,r,e);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function v(t,r,e,i){e=Number(e)||0;var n=t.length-e;i?(i=Number(i),i>n&&(i=n)):i=n;var h=r.length;if(h%2!==0)throw new Error("Invalid hex string");i>h/2&&(i=h/2);for(var o=0;i>o;o++){var s=parseInt(r.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[e+o]=s}return o}function E(t,r,e,i){return Z(j(r,t.length-e),t,e,i)}function A(t,r,e,i){return Z(X(r),t,e,i)}function b(t,r,e,i){return A(t,r,e,i)}function I(t,r,e,i){return Z(H(r),t,e,i)}function B(t,r,e,i){return Z(J(r,t.length-e),t,e,i)}function R(t,r,e){return 0===r&&e===t.length?G.fromByteArray(t):G.fromByteArray(t.slice(r,e))}function U(t,r,e){e=Math.min(t.length,e);for(var i=[],n=r;e>n;){var h=t[n],o=null,s=h>239?4:h>223?3:h>191?2:1;if(e>=n+s){var a,u,f,c;switch(s){case 1:128>h&&(o=h);break;case 2:a=t[n+1],128===(192&a)&&(c=(31&h)<<6|63&a,c>127&&(o=c));break;case 3:a=t[n+1],u=t[n+2],128===(192&a)&&128===(192&u)&&(c=(15&h)<<12|(63&a)<<6|63&u,c>2047&&(55296>c||c>57343)&&(o=c));break;case 4:a=t[n+1],u=t[n+2],f=t[n+3],128===(192&a)&&128===(192&u)&&128===(192&f)&&(c=(15&h)<<18|(63&a)<<12|(63&u)<<6|63&f,c>65535&&1114112>c&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=s}return x(i)}function x(t){var r=t.length;if(W>=r)return String.fromCharCode.apply(String,t);for(var e="",i=0;r>i;)e+=String.fromCharCode.apply(String,t.slice(i,i+=W));return e}function T(t,r,e){var i="";e=Math.min(t.length,e);for(var n=r;e>n;n++)i+=String.fromCharCode(127&t[n]);return i}function C(t,r,e){var i="";e=Math.min(t.length,e);for(var n=r;e>n;n++)i+=String.fromCharCode(t[n]);return i}function P(t,r,e){var i=t.length;(!r||0>r)&&(r=0),(!e||0>e||e>i)&&(e=i);for(var n="",h=r;e>h;h++)n+=q(t[h]);return n}function L(t,r,e){for(var i=t.slice(r,e),n="",h=0;ht)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function Y(t,r,e,i,n,o){if(!h.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(r>n||o>r)throw new RangeError("value is out of bounds");if(e+i>t.length)throw new RangeError("index out of range")}function M(t,r,e,i){0>r&&(r=65535+r+1);for(var n=0,h=Math.min(t.length-e,2);h>n;n++)t[e+n]=(r&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function D(t,r,e,i){0>r&&(r=4294967295+r+1);for(var n=0,h=Math.min(t.length-e,4);h>n;n++)t[e+n]=r>>>8*(i?n:3-n)&255}function N(t,r,e,i,n,h){if(r>n||h>r)throw new RangeError("value is out of bounds");if(e+i>t.length)throw new RangeError("index out of range");if(0>e)throw new RangeError("index out of range")}function O(t,r,e,i,n){return n||N(t,r,e,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,r,e,i,23,4),e+4}function z(t,r,e,i,n){return n||N(t,r,e,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,r,e,i,52,8),e+8}function F(t){if(t=k(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function k(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return 16>t?"0"+t.toString(16):t.toString(16)}function j(t,r){r=r||1/0;for(var e,i=t.length,n=null,h=[],o=0;i>o;o++){if(e=t.charCodeAt(o),e>55295&&57344>e){if(!n){if(e>56319){(r-=3)>-1&&h.push(239,191,189);continue}if(o+1===i){(r-=3)>-1&&h.push(239,191,189);continue}n=e;continue}if(56320>e){(r-=3)>-1&&h.push(239,191,189),n=e;continue}e=(n-55296<<10|e-56320)+65536}else n&&(r-=3)>-1&&h.push(239,191,189);if(n=null,128>e){if((r-=1)<0)break;h.push(e)}else if(2048>e){if((r-=2)<0)break;h.push(e>>6|192,63&e|128)}else if(65536>e){if((r-=3)<0)break;h.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(1114112>e))throw new Error("Invalid code point");if((r-=4)<0)break;h.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return h}function X(t){for(var r=[],e=0;e>8,n=e%256,h.push(n),h.push(i);return h}function H(t){return G.toByteArray(F(t))}function Z(t,r,e,i){for(var n=0;i>n&&!(n+e>=r.length||n>=t.length);n++)r[n+e]=t[n];return n}var G=t("base64-js"),K=t("ieee754"),Q=t("isarray");e.Buffer=h,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,h.poolSize=8192;var V={};h.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:i(),h.TYPED_ARRAY_SUPPORT?(h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array):(h.prototype.length=void 0,h.prototype.parent=void 0),h.isBuffer=function(t){return!(null==t||!t._isBuffer)},h.compare=function(t,r){if(!h.isBuffer(t)||!h.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,i=r.length,n=0,o=Math.min(e,i);o>n&&t[n]===r[n];)++n;return n!==o&&(e=t[n],i=r[n]),i>e?-1:e>i?1:0},h.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(t,r){if(!Q(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new h(0);var e;if(void 0===r)for(r=0,e=0;e0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},h.prototype.compare=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:h.compare(this,t)},h.prototype.indexOf=function(t,r){function e(t,r,e){for(var i=-1,n=0;e+n2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),r>>=0,0===this.length)return-1;if(r>=this.length)return-1;if(0>r&&(r=Math.max(this.length+r,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,r);if(h.isBuffer(t))return e(this,t,r);if("number"==typeof t)return h.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,r):e(this,[t],r);throw new TypeError("val must be string, number or Buffer")},h.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},h.prototype.set=function(t,r){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,r)},h.prototype.write=function(t,r,e,i){if(void 0===r)i="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)i=r,e=this.length,r=0;else if(isFinite(r))r=0|r,isFinite(e)?(e=0|e,void 0===i&&(i="utf8")):(i=e,e=void 0);else{var n=i;i=r,r=0|e,e=n}var h=this.length-r;if((void 0===e||e>h)&&(e=h),t.length>0&&(0>e||0>r)||r>this.length)throw new RangeError("attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return E(this,t,r,e);case"ascii":return A(this,t,r,e);case"binary":return b(this,t,r,e);case"base64":return I(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r,e);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var W=4096;h.prototype.slice=function(t,r){var e=this.length;t=~~t,r=void 0===r?e:~~r,0>t?(t+=e,0>t&&(t=0)):t>e&&(t=e),0>r?(r+=e,0>r&&(r=0)):r>e&&(r=e),t>r&&(r=t);var i;if(h.TYPED_ARRAY_SUPPORT)i=h._augment(this.subarray(t,r));else{var n=r-t;i=new h(n,void 0);for(var o=0;n>o;o++)i[o]=this[o+t]}return i.length&&(i.parent=this.parent||this),i},h.prototype.readUIntLE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=this[t],n=1,h=0;++h0&&(n*=256);)i+=this[t+--r]*n;return i},h.prototype.readUInt8=function(t,r){return r||S(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,r){return r||S(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,r){return r||S(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,r){return r||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,r){return r||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=this[t],n=1,h=0;++h=n&&(i-=Math.pow(2,8*r)),i},h.prototype.readIntBE=function(t,r,e){t=0|t,r=0|r,e||S(t,r,this.length);for(var i=r,n=1,h=this[t+--i];i>0&&(n*=256);)h+=this[t+--i]*n;return n*=128,h>=n&&(h-=Math.pow(2,8*r)),h},h.prototype.readInt8=function(t,r){return r||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,r){r||S(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},h.prototype.readInt16BE=function(t,r){r||S(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},h.prototype.readInt32LE=function(t,r){return r||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,r){ -return r||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,r){return r||S(t,4,this.length),K.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,r){return r||S(t,4,this.length),K.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,r){return r||S(t,8,this.length),K.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,r){return r||S(t,8,this.length),K.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,r,e,i){t=+t,r=0|r,e=0|e,i||Y(this,t,r,e,Math.pow(2,8*e),0);var n=1,h=0;for(this[r]=255&t;++h=0&&(h*=256);)this[r+n]=t/h&255;return r+e},h.prototype.writeUInt8=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},h.prototype.writeUInt16LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},h.prototype.writeUInt16BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},h.prototype.writeUInt32LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):D(this,t,r,!0),r+4},h.prototype.writeUInt32BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):D(this,t,r,!1),r+4},h.prototype.writeIntLE=function(t,r,e,i){if(t=+t,r=0|r,!i){var n=Math.pow(2,8*e-1);Y(this,t,r,e,n-1,-n)}var h=0,o=1,s=0>t?1:0;for(this[r]=255&t;++h>0)-s&255;return r+e},h.prototype.writeIntBE=function(t,r,e,i){if(t=+t,r=0|r,!i){var n=Math.pow(2,8*e-1);Y(this,t,r,e,n-1,-n)}var h=e-1,o=1,s=0>t?1:0;for(this[r+h]=255&t;--h>=0&&(o*=256);)this[r+h]=(t/o>>0)-s&255;return r+e},h.prototype.writeInt8=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[r]=255&t,r+1},h.prototype.writeInt16LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},h.prototype.writeInt16BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},h.prototype.writeInt32LE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):D(this,t,r,!0),r+4},h.prototype.writeInt32BE=function(t,r,e){return t=+t,r=0|r,e||Y(this,t,r,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):D(this,t,r,!1),r+4},h.prototype.writeFloatLE=function(t,r,e){return O(this,t,r,!0,e)},h.prototype.writeFloatBE=function(t,r,e){return O(this,t,r,!1,e)},h.prototype.writeDoubleLE=function(t,r,e){return z(this,t,r,!0,e)},h.prototype.writeDoubleBE=function(t,r,e){return z(this,t,r,!1,e)},h.prototype.copy=function(t,r,e,i){if(e||(e=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&e>i&&(i=e),i===e)return 0;if(0===t.length||0===this.length)return 0;if(0>r)throw new RangeError("targetStart out of bounds");if(0>e||e>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-re&&i>r)for(n=o-1;n>=0;n--)t[n+r]=this[n+e];else if(1e3>o||!h.TYPED_ARRAY_SUPPORT)for(n=0;o>n;n++)t[n+r]=this[n+e];else t._set(this.subarray(e,e+o),r);return o},h.prototype.fill=function(t,r,e){if(t||(t=0),r||(r=0),e||(e=this.length),r>e)throw new RangeError("end < start");if(e!==r&&0!==this.length){if(0>r||r>=this.length)throw new RangeError("start out of bounds");if(0>e||e>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof t)for(i=r;e>i;i++)this[i]=t;else{var n=j(t.toString()),h=n.length;for(i=r;e>i;i++)this[i]=n[i%h]}return this}},h.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(h.TYPED_ARRAY_SUPPORT)return new h(this).buffer;for(var t=new Uint8Array(this.length),r=0,e=t.length;e>r;r+=1)t[r]=this[r];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var $=h.prototype;h._augment=function(t){return t.constructor=h,t._isBuffer=!0,t._set=t.set,t.get=$.get,t.set=$.set,t.write=$.write,t.toString=$.toString,t.toLocaleString=$.toString,t.toJSON=$.toJSON,t.equals=$.equals,t.compare=$.compare,t.indexOf=$.indexOf,t.copy=$.copy,t.slice=$.slice,t.readUIntLE=$.readUIntLE,t.readUIntBE=$.readUIntBE,t.readUInt8=$.readUInt8,t.readUInt16LE=$.readUInt16LE,t.readUInt16BE=$.readUInt16BE,t.readUInt32LE=$.readUInt32LE,t.readUInt32BE=$.readUInt32BE,t.readIntLE=$.readIntLE,t.readIntBE=$.readIntBE,t.readInt8=$.readInt8,t.readInt16LE=$.readInt16LE,t.readInt16BE=$.readInt16BE,t.readInt32LE=$.readInt32LE,t.readInt32BE=$.readInt32BE,t.readFloatLE=$.readFloatLE,t.readFloatBE=$.readFloatBE,t.readDoubleLE=$.readDoubleLE,t.readDoubleBE=$.readDoubleBE,t.writeUInt8=$.writeUInt8,t.writeUIntLE=$.writeUIntLE,t.writeUIntBE=$.writeUIntBE,t.writeUInt16LE=$.writeUInt16LE,t.writeUInt16BE=$.writeUInt16BE,t.writeUInt32LE=$.writeUInt32LE,t.writeUInt32BE=$.writeUInt32BE,t.writeIntLE=$.writeIntLE,t.writeIntBE=$.writeIntBE,t.writeInt8=$.writeInt8,t.writeInt16LE=$.writeInt16LE,t.writeInt16BE=$.writeInt16BE,t.writeInt32LE=$.writeInt32LE,t.writeInt32BE=$.writeInt32BE,t.writeFloatLE=$.writeFloatLE,t.writeFloatBE=$.writeFloatBE,t.writeDoubleLE=$.writeDoubleLE,t.writeDoubleBE=$.writeDoubleBE,t.fill=$.fill,t.inspect=$.inspect,t.toArrayBuffer=$.toArrayBuffer,t};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":3,ieee754:8,isarray:4}]},{},[2]); diff --git a/package.json b/package.json index c770ec5a..fc69d966 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "homepage": "http://github.com/pierrec/node-lz4", "repository": { "type": "git", - "url": "git://github.com/pierrec/node-lz4.git" + "url": "https://github.com/zeroshade/node-lz4.git" }, "main": "./lib/lz4.js", "browser": "./build/lz4.js", @@ -34,14 +34,16 @@ "binary": { "module_name": "lz4", "module_path": "./lib/binding/", - "host": "https://github.com/zeroshade/node-lz4/releases/download", + "host": "https://github.com/zeroshade/node-lz4/releases/download/", "remote_path": "{version}" }, "dependencies": { + "@octokit/rest": "^15.12.1", "cuint": "^0.2.0", "nan": "^2.0.9", "node-pre-gyp": "^0.11.0", - "prebuild": "^8.0.1", + "node-pre-gyp-github": "^1.4.2", + "prebuild": "^8.1.0", "xxhashjs": "^0.1.1" }, "devDependencies": { @@ -60,6 +62,6 @@ "scripts": { "test": "mocha", "install": "node-pre-gyp install --fallback-to-build", - "prepublish": "./build.sh" + "package": "node-pre-gyp build && node-pre-gyp package" } } From 8efa11e426b1a1badcb01045250b5e7ae3679497 Mon Sep 17 00:00:00 2001 From: Matthew Topol Date: Thu, 4 Oct 2018 14:21:17 -0400 Subject: [PATCH 3/6] Cleaning up the appveyor, fixing warnings in lz4_binding.cc, updating package script --- appveyor.yml | 17 +---------------- lib/binding/lz4_binding.cc | 30 ++++++++++++++++-------------- package.json | 3 +-- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 45a53d82..7735d7d1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,4 @@ environment: - NODE_PRE_GYP_GITHUB_TOKEN: - secure: aJwAbajByhTfjiB0a3NzwZwWqp5jOJqFaSGelxe7TqgROz+L/QOtmjZj4FtUd029 - matrix: - nodejs_version: "8" - nodejs_version: "10" @@ -23,18 +20,8 @@ install: npm config set spin false - ps: >- $env:JOBS = "max"; - $env:PUBLISH = "false"; $env:GIT_TAG = "$(git describe --tags --always HEAD)"; $env:package_version = (Get-Content -Raw -Path package.json | ConvertFrom-Json).version; - if ($env:APPVEYOR_REPO_BRANCH -match $env:GIT_TAG) { - $env:PUBLISH = "true"; - } - if ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match "[draft]") { - $env:PUBLISH = "true"; - } - if ($env:APPVEYOR_REPO_TAG -match "true") { - $env:PUBLISH = "true"; - } true; - ps: >- @{ @@ -42,7 +29,6 @@ install: "APPVEYOR_REPO_TAG" = $env:APPVEYOR_REPO_TAG "APPVEYOR_REPO_COMMIT_MESSAGE" = $env:APPVEYOR_REPO_COMMIT_MESSAGE "LATEST TAG" = $env:GIT_TAG - "PUBLISHING" = $env:PUBLISH "PACKAGE_VERSION" = $env:package_version } | Out-String | Write-Host; - ps: Update-AppveyorBuild -Version "$env:package_version-$env:APPVEYOR_BUILD_NUMBER" @@ -66,9 +52,8 @@ deploy: secure: aJwAbajByhTfjiB0a3NzwZwWqp5jOJqFaSGelxe7TqgROz+L/QOtmjZj4FtUd029 artifact: /.*\.tar\.gz/ force_update: true - draft: true prerelease: true repository: zeroshade/node-lz4 on: - branch: package + branch: master diff --git a/lib/binding/lz4_binding.cc b/lib/binding/lz4_binding.cc index 90e0e311..55a30bf9 100644 --- a/lib/binding/lz4_binding.cc +++ b/lib/binding/lz4_binding.cc @@ -49,7 +49,7 @@ NAN_METHOD(LZ4Compress) { } sIdx = info[2]->Uint32Value(); eIdx = info[3]->Uint32Value(); - result = Nan::New(LZ4_compress_limitedOutput(Buffer::Data(input), + result = Nan::New(LZ4_compress_default(Buffer::Data(input), Buffer::Data(output) + sIdx, Buffer::Length(input), eIdx - sIdx) @@ -62,9 +62,10 @@ NAN_METHOD(LZ4Compress) { } sIdx = info[2]->Uint32Value(); case 2: - result = Nan::New(LZ4_compress(Buffer::Data(input), - Buffer::Data(output) + sIdx, - Buffer::Length(input)) + result = Nan::New(LZ4_compress_default(Buffer::Data(input), + Buffer::Data(output) + sIdx, + Buffer::Length(input), + eIdx - sIdx) ); } @@ -88,9 +89,10 @@ NAN_METHOD(LZ4CompressHC) { Local input = info[0]->ToObject(); Local output = info[1]->ToObject(); - Local result = Nan::New(LZ4_compressHC(Buffer::Data(input), + Local result = Nan::New(LZ4_compress_HC(Buffer::Data(input), Buffer::Data(output), - Buffer::Length(input)) + Buffer::Length(input), + LZ4_compressBound(Buffer::Length(input)), 0) ); info.GetReturnValue().Set(result); } @@ -141,10 +143,10 @@ NAN_METHOD(LZ4CompressLimited) { Local output = info[1]->ToObject(); uint32_t size = info[2]->Uint32Value(); - Local result = Nan::New(LZ4_compress_limitedOutput(Buffer::Data(input), - Buffer::Data(output), - Buffer::Length(input), - size) + Local result = Nan::New(LZ4_compress_default(Buffer::Data(input), + Buffer::Data(output), + Buffer::Length(input), + size) ); info.GetReturnValue().Set(result); } @@ -172,10 +174,10 @@ NAN_METHOD(LZ4CompressHCLimited) { Local output = info[1]->ToObject(); uint32_t size = info[2]->Uint32Value(); - Local result = Nan::New(LZ4_compressHC_limitedOutput(Buffer::Data(input), - Buffer::Data(output), - Buffer::Length(input), - size) + Local result = Nan::New(LZ4_compress_HC(Buffer::Data(input), + Buffer::Data(output), + Buffer::Length(input), + size, 0) ); info.GetReturnValue().Set(result); } diff --git a/package.json b/package.json index fc69d966..aa986c0a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "cuint": "^0.2.0", "nan": "^2.0.9", "node-pre-gyp": "^0.11.0", - "node-pre-gyp-github": "^1.4.2", "prebuild": "^8.1.0", "xxhashjs": "^0.1.1" }, @@ -62,6 +61,6 @@ "scripts": { "test": "mocha", "install": "node-pre-gyp install --fallback-to-build", - "package": "node-pre-gyp build && node-pre-gyp package" + "package": "node-pre-gyp configure && node-pre-gyp build && node-pre-gyp package" } } From 622214695208662f1a362d21b484809b64f61ef7 Mon Sep 17 00:00:00 2001 From: Matthew Topol Date: Thu, 4 Oct 2018 14:32:32 -0400 Subject: [PATCH 4/6] moving browserify and minify to postinstall --- appveyor.yml | 2 -- package.json | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7735d7d1..bda45a3f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,8 +35,6 @@ install: build_script: - npm install --build-from-source - - ps: .\node_modules\.bin\browserify -o build/lz4.js -r ./lib/utils-js.js:./utils -r buffer -r ./lib/lz4.js:lz4 lib/lz4.js; - - ps: .\node_modules\.bin\minify build/lz4.js > build/lz4.min.js; test_script: - npm test diff --git a/package.json b/package.json index aa986c0a..f14a1932 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "scripts": { "test": "mocha", "install": "node-pre-gyp install --fallback-to-build", + "postinstall": "browserify -o build/lz4.js -r ./lib/utils-js.js:./utils -r buffer -r ./lib/lz4.js:lz4 lib/lz4.js && minify build/lz4.js > build/lz4.min.js", "package": "node-pre-gyp configure && node-pre-gyp build && node-pre-gyp package" } } From 682dc4037aaad6ca5d3b87a264ea84a235300183 Mon Sep 17 00:00:00 2001 From: Matthew Topol Date: Thu, 4 Oct 2018 15:32:22 -0400 Subject: [PATCH 5/6] updating some dependencies due to vulnerabilities --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f14a1932..142dd030 100644 --- a/package.json +++ b/package.json @@ -49,14 +49,14 @@ "benchmark": "^1.0.0", "browserify": "^9.0.7", "jasmine-core": "^2.2.0", - "karma": "^0.12.31", + "karma": "^3.0.0", "karma-chrome-launcher": "^0.1.7", "karma-cli": "0.0.4", "karma-firefox-launcher": "^0.1.4", "karma-jasmine": "^0.3.5", "karma-mocha": "^0.1.10", - "minify": "^1.4.10", - "mocha": "^2.2.4" + "minify": "^3.0.5", + "mocha": "^5.2.0" }, "scripts": { "test": "mocha", From 7424730c3ebf22006681380e5b24e47dd80562c4 Mon Sep 17 00:00:00 2001 From: Matthew Topol Date: Thu, 4 Oct 2018 15:35:01 -0400 Subject: [PATCH 6/6] setting values back to point at parent repo --- appveyor.yml | 3 +-- package.json | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bda45a3f..d44ca919 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -47,11 +47,10 @@ deploy: release: ${package_version} provider: GitHub auth_token: - secure: aJwAbajByhTfjiB0a3NzwZwWqp5jOJqFaSGelxe7TqgROz+L/QOtmjZj4FtUd029 + secure: ENCRYPTED_TOKEN artifact: /.*\.tar\.gz/ force_update: true prerelease: true - repository: zeroshade/node-lz4 on: branch: master diff --git a/package.json b/package.json index 142dd030..5d01b284 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "homepage": "http://github.com/pierrec/node-lz4", "repository": { "type": "git", - "url": "https://github.com/zeroshade/node-lz4.git" + "url": "https://github.com/pierrec/node-lz4.git" }, "main": "./lib/lz4.js", "browser": "./build/lz4.js", @@ -34,7 +34,7 @@ "binary": { "module_name": "lz4", "module_path": "./lib/binding/", - "host": "https://github.com/zeroshade/node-lz4/releases/download/", + "host": "https://github.com/pierrec/node-lz4/releases/download/", "remote_path": "{version}" }, "dependencies": {