1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
|
|
"use strict";function Long(t,o,i){this.low=0|t,this.high=0|o,this.unsigned=!!i}function isLong(t){return!0===(t&&t.__isLong__)}function fromInt(t,o){var i,n,r;return o?(t>>>=0,(r=0<=t&&t<256)&&(n=UINT_CACHE[t])?n:(i=fromBits(t,(0|t)<0?-1:0,!0),r&&(UINT_CACHE[t]=i),i)):(t|=0,(r=-128<=t&&t<128)&&(n=INT_CACHE[t])?n:(i=fromBits(t,t<0?-1:0,!1),r&&(INT_CACHE[t]=i),i))}function fromNumber(t,o){if(isNaN(t))return o?UZERO:ZERO;if(o){if(t<0)return UZERO;if(t>=TWO_PWR_64_DBL)return MAX_UNSIGNED_VALUE}else{if(t<=-TWO_PWR_63_DBL)return MIN_VALUE;if(t+1>=TWO_PWR_63_DBL)return MAX_VALUE}return t<0?fromNumber(-t,o).neg():fromBits(t%TWO_PWR_32_DBL|0,t/TWO_PWR_32_DBL|0,o)}function fromBits(t,o,i){return new Long(t,o,i)}function fromString(t,o,i){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return ZERO;if("number"==typeof o?(i=o,o=!1):o=!!o,(i=i||10)<2||36<i)throw RangeError("radix");var n;if((n=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return fromString(t.substring(1),o,i).neg();for(var r=fromNumber(pow_dbl(i,8)),e=ZERO,s=0;s<t.length;s+=8){var h=Math.min(8,t.length-s),g=parseInt(t.substring(s,s+h),i);if(h<8){var u=fromNumber(pow_dbl(i,h));e=e.mul(u).add(fromNumber(g))}else e=e.mul(r),e=e.add(fromNumber(g))}return e.unsigned=o,e}function fromValue(t,o){return"number"==typeof t?fromNumber(t,o):"string"==typeof t?fromString(t,o):fromBits(t.low,t.high,"boolean"==typeof o?o:t.unsigned)}var wasm=null;Long.prototype.__isLong__,Object.defineProperty(Long.prototype,"__isLong__",{value:!0}),Long.isLong=isLong;var INT_CACHE={},UINT_CACHE={};Long.fromInt=fromInt,Long.fromNumber=fromNumber,Long.fromBits=fromBits;var pow_dbl=Math.pow;Long.fromString=fromString,Long.fromValue=fromValue;var TWO_PWR_16_DBL=65536,TWO_PWR_24_DBL=1<<24,TWO_PWR_32_DBL=TWO_PWR_16_DBL*TWO_PWR_16_DBL,TWO_PWR_64_DBL=TWO_PWR_32_DBL*TWO_PWR_32_DBL,TWO_PWR_63_DBL=TWO_PWR_64_DBL/2,TWO_PWR_24=fromInt(TWO_PWR_24_DBL),ZERO=fromInt(0);Long.ZERO=ZERO;var UZERO=fromInt(0,!0);Long.UZERO=UZERO;var ONE=fromInt(1);Long.ONE=ONE;var UONE=fromInt(1,!0);Long.UONE=UONE;var NEG_ONE=fromInt(-1);Long.NEG_ONE=NEG_ONE;var MAX_VALUE=fromBits(-1,2147483647,!1);Long.MAX_VALUE=MAX_VALUE;var MAX_UNSIGNED_VALUE=fromBits(-1,-1,!0);Long.MAX_UNSIGNED_VALUE=MAX_UNSIGNED_VALUE;var MIN_VALUE=fromBits(0,-2147483648,!1);Long.MIN_VALUE=MIN_VALUE;var LongPrototype=Long.prototype;LongPrototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},LongPrototype.toNumber=function(){return this.unsigned?(this.high>>>0)*TWO_PWR_32_DBL+(this.low>>>0):this.high*TWO_PWR_32_DBL+(this.low>>>0)},LongPrototype.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(MIN_VALUE)){var o=fromNumber(t),i=this.div(o),n=i.mul(o).sub(this);return i.toString(t)+n.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var r=fromNumber(pow_dbl(t,6),this.unsigned),e=this,s="";;){var h=e.div(r),g=e.sub(h.mul(r)).toInt()>>>0,u=g.toString(t);if(e=h,e.isZero())return u+s;for(;u.length<6;)u="0"+u;s=""+u+s}},LongPrototype.getHighBits=function(){return this.high},LongPrototype.getHighBitsUnsigned=function(){return this.high>>>0},LongPrototype.getLowBits=function(){return this.low},LongPrototype.getLowBitsUnsigned=function(){return this.low>>>0},LongPrototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(MIN_VALUE)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,o=31;o>0&&0==(t&1<<o);o--);return 0!=this.high?o+33:o+1},LongPrototype.isZero=function(){return 0===this.high&&0===this.low},LongPrototype.eqz=LongPrototype.isZero,LongPrototype.isNegative=function(){return!this.unsigned&&this.high<0},LongPrototype.isPositive=function(){return this.unsigned||this.high>=0},LongPrototype.isOdd=function(){return 1==(1&this.low)},LongPrototype.isEven=function(){return 0==(1&this.low)},LongPrototype.equals=function(t){return isLong(t)||(t=fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},LongPrototype
|