2 lines
42 KiB
JavaScript
2 lines
42 KiB
JavaScript
|
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.XXH=r():t.XXH=r()}("undefined"!=typeof self?self:this,function(){return function(t){function r(e){if(i[e])return i[e].exports;var o=i[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var i={};return r.m=t,r.c=i,r.d=function(t,i,e){r.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(i,"a",i),i},r.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},r.p="",r(r.s=2)}([function(t,r,i){"use strict";(function(t){function e(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,r){if(e()<r)throw new RangeError("Invalid typed array length");return h.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=h.prototype):(null===t&&(t=new h(r)),t.length=r),t}function h(t,r,i){if(!(h.TYPED_ARRAY_SUPPORT||this instanceof h))return new h(t,r,i);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return u(this,t)}return n(this,t,r,i)}function n(t,r,i,e){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?c(t,r,i,e):"string"==typeof r?f(t,r,i):p(t,r)}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function a(t,r,i,e){return s(r),r<=0?o(t,r):void 0!==i?"string"==typeof e?o(t,r).fill(i,e):o(t,r).fill(i):o(t,r)}function u(t,r){if(s(r),t=o(t,r<0?0:0|m(r)),!h.TYPED_ARRAY_SUPPORT)for(var i=0;i<r;++i)t[i]=0;return t}function f(t,r,i){if("string"==typeof i&&""!==i||(i="utf8"),!h.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var e=0|_(r,i);t=o(t,e);var n=t.write(r,i);return n!==e&&(t=t.slice(0,n)),t}function l(t,r){var i=r.length<0?0:0|m(r.length);t=o(t,i);for(var e=0;e<i;e+=1)t[e]=255&r[e];return t}function c(t,r,i,e){if(r.byteLength,i<0||r.byteLength<i)throw new RangeError("'offset' is out of bounds");if(r.byteLength<i+(e||0))throw new RangeError("'length' is out of bounds");return r=void 0===i&&void 0===e?new Uint8Array(r):void 0===e?new Uint8Array(r,i):new Uint8Array(r,i,e),h.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=h.prototype):t=l(t,r),t}function p(t,r){if(h.isBuffer(r)){var i=0|m(r.length);return t=o(t,i),0===t.length?t:(r.copy(t,0,0,i),t)}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||G(r.length)?o(t,0):l(t,r);if("Buffer"===r.type&&W(r.data))return l(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function m(t){if(t>=e())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e().toString(16)+" bytes");return 0|t}function y(t){return+t!=t&&(t=0),h.alloc(+t)}function _(t,r){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var e=!1;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return X(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return J(t).length;default:if(e)return X(t).length;r=(""+r).toLowerCase(),e=!0}}function d(t,r,i){var e=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if(i>>>=0,r>>>=0,i<=r)return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,r,i);case"utf8":case"utf-8":return T(this,r,i);case"ascii":return U(this,r,i);case"latin1":case"binary":return S(this,r,i);case"base64":return B(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-1
|
||
|
;for(var i=this.clone(),e=new Array(64),o=63;o>=0&&(i.div(r),e[o]=i.remainder.toNumber().toString(t),i.gt(r));o--);return e[o-1]=i.toNumber().toString(t),e.join("")},h.prototype.add=function(t){var r=this._a00+t._a00,i=r>>>16;i+=this._a16+t._a16;var e=i>>>16;e+=this._a32+t._a32;var o=e>>>16;return o+=this._a48+t._a48,this._a00=65535&r,this._a16=65535&i,this._a32=65535&e,this._a48=65535&o,this},h.prototype.subtract=function(t){return this.add(t.clone().negate())},h.prototype.multiply=function(t){var r=this._a00,i=this._a16,e=this._a32,o=this._a48,h=t._a00,n=t._a16,s=t._a32,a=t._a48,u=r*h,f=u>>>16;f+=r*n;var l=f>>>16;f&=65535,f+=i*h,l+=f>>>16,l+=r*s;var c=l>>>16;return l&=65535,l+=i*n,c+=l>>>16,l&=65535,l+=e*h,c+=l>>>16,c+=r*a,c&=65535,c+=i*s,c&=65535,c+=e*n,c&=65535,c+=o*h,this._a00=65535&u,this._a16=65535&f,this._a32=65535&l,this._a48=65535&c,this},h.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 h(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 h(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<<i-48:i>=32?this._a32|=1<<i-32:i>=16?this._a16|=1<<i-16:this._a00|=1<<i);return this},h.prototype.negate=function(){var t=1+(65535&~this._a00);return this._a00=65535&t,t=(65535&~this._a16)+(t>>>16),this._a16=65535&t,t=(65535&~this._a32)+(t>>>16),this._a32=65535&t,this._a48=~this._a48+(t>>>16)&65535,this},h.prototype.equals=h.prototype.eq=function(t){return this._a48==t._a48&&this._a00==t._a00&&this._a32==t._a32&&this._a16==t._a16},h.prototype.greaterThan=h.prototype.gt=function(t){return this._a48>t._a48||!(this._a48<t._a48)&&(this._a32>t._a32||!(this._a32<t._a32)&&(this._a16>t._a16||!(this._a16<t._a16)&&this._a00>t._a00))},h.prototype.lessThan=h.prototype.lt=function(t){return this._a48<t._a48||!(this._a48>t._a48)&&(this._a32<t._a32||!(this._a32>t._a32)&&(this._a16<t._a16||!(this._a16>t._a16)&&this._a00<t._a00))},h.prototype.or=function(t){return this._a00|=t._a00,this._a16|=t._a16,this._a32|=t._a32,this._a48|=t._a48,this},h.prototype.and=function(t){return this._a00&=t._a00,this._a16&=t._a16,this._a32&=t._a32,this._a48&=t._a48,this},h.prototype.xor=function(t){return this._a00^=t._a00,this._a16^=t._a16,this._a32^=t._a32,this._a48^=t._a48,this},h.prototype.not=function(){return this._a00=65535&~this._a00,this._a16=65535&~this._a16,this._a32=65535&~this._a32,this._a48=65535&~this._a48,this},h.prototype.shiftRight=h.prototype.shiftr=function(t){return t%=64,t>=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},h.prototype.shiftLeft=h.prototype.shiftl=function(t,r){return t%=64,t>=48?(this._a48=this._a00<<t-48,this._a32=0,this._a16=0,this._a00=0):t>=32?(t-=32,this._a48=this._a16<<t|this._a00>>16-t,this._a32=this._a00<<t&65535,this._a16=0,this._a00=0):t>=16?(t-=16,this._a48=this._a32<<t|this._a16>>16-t,this._a32=65535&(this._a16<<t|this._a00>>16-t),this._a16=this._a00<<t&65535,this._a00=0):(this._a48=this._a48<<t|this._a32>>16-t,this._a32=65535&(this._a32<<t|this._a16>>16-t),this._a16=65535&(this._a16<<t|this._a00>>16-t),this._a00=this._a00<<t&65535),r||(this._a48&=65535),this},h.prototype.rotateLeft=h.prototype.rotl=function(t){if(0==(t%=64))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
|