Comparing version 3.0.0 to 3.0.1
242
dist/long.js
@@ -19,5 +19,5 @@ /* | ||
/** | ||
* @license Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io> | ||
* @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io> | ||
* Released under the Apache License, Version 2.0 | ||
* see: https://github.com/dcodeIO/Long.js for details | ||
* see: https://github.com/dcodeIO/long.js for details | ||
*/ | ||
@@ -134,6 +134,6 @@ (function(global, factory) { | ||
Long.fromInt = function fromInt(value, unsigned) { | ||
var obj, cachedObj; | ||
var obj, cachedObj, cache; | ||
if (!unsigned) { | ||
value = value | 0; | ||
if (-128 <= value && value < 128) { | ||
if (cache = (-128 <= value && value < 128)) { | ||
cachedObj = INT_CACHE[value]; | ||
@@ -144,3 +144,3 @@ if (cachedObj) | ||
obj = new Long(value, value < 0 ? -1 : 0, false); | ||
if (-128 <= value && value < 128) | ||
if (cache) | ||
INT_CACHE[value] = obj; | ||
@@ -150,3 +150,3 @@ return obj; | ||
value = value >>> 0; | ||
if (0 <= value && value < 256) { | ||
if (cache = (0 <= value && value < 256)) { | ||
cachedObj = UINT_CACHE[value]; | ||
@@ -157,3 +157,3 @@ if (cachedObj) | ||
obj = new Long(value, (value | 0) < 0 ? -1 : 0, true); | ||
if (0 <= value && value < 256) | ||
if (cache) | ||
UINT_CACHE[value] = obj; | ||
@@ -182,3 +182,3 @@ return obj; | ||
if (value < 0) | ||
return Long.fromNumber(-value, unsigned).negate(); | ||
return Long.fromNumber(-value, unsigned).neg(); | ||
return new Long((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); | ||
@@ -224,3 +224,3 @@ }; | ||
else if (p === 0) | ||
return Long.fromString(str.substring(1), unsigned, radix).negate(); | ||
return Long.fromString(str.substring(1), unsigned, radix).neg(); | ||
@@ -237,5 +237,5 @@ // Do several (8) digits each time through the loop, so as to | ||
var power = Long.fromNumber(Math.pow(radix, size)); | ||
result = result.multiply(power).add(Long.fromNumber(value)); | ||
result = result.mul(power).add(Long.fromNumber(value)); | ||
} else { | ||
result = result.multiply(radixToPower); | ||
result = result.mul(radixToPower); | ||
result = result.add(Long.fromNumber(value)); | ||
@@ -350,3 +350,3 @@ } | ||
*/ | ||
Long.MAX_VALUE = Long.fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false); | ||
Long.MAX_VALUE = new Long(0xFFFFFFFF|0, 0x7FFFFFFF|0, false); | ||
@@ -358,3 +358,3 @@ /** | ||
*/ | ||
Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xFFFFFFFF|0, 0xFFFFFFFF|0, true); | ||
Long.MAX_UNSIGNED_VALUE = new Long(0xFFFFFFFF|0, 0xFFFFFFFF|0, true); | ||
@@ -366,5 +366,11 @@ /** | ||
*/ | ||
Long.MIN_VALUE = Long.fromBits(0, 0x80000000|0, false); | ||
Long.MIN_VALUE = new Long(0, 0x80000000|0, false); | ||
/** | ||
* @alias Long.prototype | ||
* @inner | ||
*/ | ||
var LongPrototype = Long.prototype; | ||
/** | ||
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. | ||
@@ -374,3 +380,3 @@ * @returns {number} | ||
*/ | ||
Long.prototype.toInt = function toInt() { | ||
LongPrototype.toInt = function toInt() { | ||
return this.unsigned ? this.low >>> 0 : this.low; | ||
@@ -384,3 +390,3 @@ }; | ||
*/ | ||
Long.prototype.toNumber = function toNumber() { | ||
LongPrototype.toNumber = function toNumber() { | ||
if (this.unsigned) { | ||
@@ -400,3 +406,3 @@ return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0); | ||
*/ | ||
Long.prototype.toString = function toString(radix) { | ||
LongPrototype.toString = function toString(radix) { | ||
radix = radix || 10; | ||
@@ -409,11 +415,11 @@ if (radix < 2 || 36 < radix) | ||
if (this.isNegative()) { // Unsigned Longs are never negative | ||
if (this.equals(Long.MIN_VALUE)) { | ||
if (this.eq(Long.MIN_VALUE)) { | ||
// We need to change the Long value before it can be negated, so we remove | ||
// the bottom-most digit in this base and then recurse to do the rest. | ||
var radixLong = Long.fromNumber(radix); | ||
var div = this.divide(radixLong); | ||
rem = div.multiply(radixLong).subtract(this); | ||
var div = this.div(radixLong); | ||
rem = div.mul(radixLong).sub(this); | ||
return div.toString(radix) + rem.toInt().toString(radix); | ||
} else | ||
return '-' + this.negate().toString(radix); | ||
return '-' + this.neg().toString(radix); | ||
} | ||
@@ -427,4 +433,4 @@ | ||
while (true) { | ||
var remDiv = rem.divide(radixToPower), | ||
intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0, | ||
var remDiv = rem.div(radixToPower), | ||
intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0, | ||
digits = intval.toString(radix); | ||
@@ -447,3 +453,3 @@ rem = remDiv; | ||
*/ | ||
Long.prototype.getHighBits = function getHighBits() { | ||
LongPrototype.getHighBits = function getHighBits() { | ||
return this.high; | ||
@@ -457,3 +463,3 @@ }; | ||
*/ | ||
Long.prototype.getHighBitsUnsigned = function getHighBitsUnsigned() { | ||
LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() { | ||
return this.high >>> 0; | ||
@@ -467,3 +473,3 @@ }; | ||
*/ | ||
Long.prototype.getLowBits = function getLowBits() { | ||
LongPrototype.getLowBits = function getLowBits() { | ||
return this.low; | ||
@@ -477,3 +483,3 @@ }; | ||
*/ | ||
Long.prototype.getLowBitsUnsigned = function getLowBitsUnsigned() { | ||
LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() { | ||
return this.low >>> 0; | ||
@@ -487,5 +493,5 @@ }; | ||
*/ | ||
Long.prototype.getNumBitsAbs = function getNumBitsAbs() { | ||
LongPrototype.getNumBitsAbs = function getNumBitsAbs() { | ||
if (this.isNegative()) // Unsigned Longs are never negative | ||
return this.equals(Long.MIN_VALUE) ? 64 : this.negate().getNumBitsAbs(); | ||
return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); | ||
var val = this.high != 0 ? this.high : this.low; | ||
@@ -503,3 +509,3 @@ for (var bit = 31; bit > 0; bit--) | ||
*/ | ||
Long.prototype.isZero = function isZero() { | ||
LongPrototype.isZero = function isZero() { | ||
return this.high === 0 && this.low === 0; | ||
@@ -513,3 +519,3 @@ }; | ||
*/ | ||
Long.prototype.isNegative = function isNegative() { | ||
LongPrototype.isNegative = function isNegative() { | ||
return !this.unsigned && this.high < 0; | ||
@@ -523,3 +529,3 @@ }; | ||
*/ | ||
Long.prototype.isPositive = function isPositive() { | ||
LongPrototype.isPositive = function isPositive() { | ||
return this.unsigned || this.high >= 0; | ||
@@ -533,3 +539,3 @@ }; | ||
*/ | ||
Long.prototype.isOdd = function isOdd() { | ||
LongPrototype.isOdd = function isOdd() { | ||
return (this.low & 1) === 1; | ||
@@ -543,3 +549,3 @@ }; | ||
*/ | ||
Long.prototype.isEven = function isEven() { | ||
LongPrototype.isEven = function isEven() { | ||
return (this.low & 1) === 0; | ||
@@ -554,3 +560,3 @@ }; | ||
*/ | ||
Long.prototype.equals = function equals(other) { | ||
LongPrototype.equals = function equals(other) { | ||
if (!Long.isLong(other)) | ||
@@ -570,3 +576,3 @@ other = Long.fromValue(other); | ||
*/ | ||
Long.eq = Long.prototype.equals; | ||
LongPrototype.eq = LongPrototype.equals; | ||
@@ -579,4 +585,4 @@ /** | ||
*/ | ||
Long.prototype.notEquals = function notEquals(other) { | ||
return !this.equals(/* validates */ other); | ||
LongPrototype.notEquals = function notEquals(other) { | ||
return !this.eq(/* validates */ other); | ||
}; | ||
@@ -591,3 +597,3 @@ | ||
*/ | ||
Long.neq = Long.prototype.notEquals; | ||
LongPrototype.neq = LongPrototype.notEquals; | ||
@@ -600,3 +606,3 @@ /** | ||
*/ | ||
Long.prototype.lessThan = function lessThan(other) { | ||
LongPrototype.lessThan = function lessThan(other) { | ||
return this.compare(/* validates */ other) < 0; | ||
@@ -612,3 +618,3 @@ }; | ||
*/ | ||
Long.prototype.lt = Long.prototype.lessThan; | ||
LongPrototype.lt = LongPrototype.lessThan; | ||
@@ -621,3 +627,3 @@ /** | ||
*/ | ||
Long.prototype.lessThanOrEqual = function lessThanOrEqual(other) { | ||
LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) { | ||
return this.compare(/* validates */ other) <= 0; | ||
@@ -633,3 +639,3 @@ }; | ||
*/ | ||
Long.prototype.lte = Long.prototype.lessThanOrEqual; | ||
LongPrototype.lte = LongPrototype.lessThanOrEqual; | ||
@@ -642,3 +648,3 @@ /** | ||
*/ | ||
Long.prototype.greaterThan = function greaterThan(other) { | ||
LongPrototype.greaterThan = function greaterThan(other) { | ||
return this.compare(/* validates */ other) > 0; | ||
@@ -654,3 +660,3 @@ }; | ||
*/ | ||
Long.prototype.gt = Long.prototype.greaterThan; | ||
LongPrototype.gt = LongPrototype.greaterThan; | ||
@@ -663,3 +669,3 @@ /** | ||
*/ | ||
Long.prototype.greaterThanOrEqual = function greaterThanOrEqual(other) { | ||
LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) { | ||
return this.compare(/* validates */ other) >= 0; | ||
@@ -675,3 +681,3 @@ }; | ||
*/ | ||
Long.prototype.gte = Long.prototype.greaterThanOrEqual; | ||
LongPrototype.gte = LongPrototype.greaterThanOrEqual; | ||
@@ -685,6 +691,6 @@ /** | ||
*/ | ||
Long.prototype.compare = function compare(other) { | ||
LongPrototype.compare = function compare(other) { | ||
if (!Long.isLong(other)) | ||
other = Long.fromValue(other); | ||
if (this.equals(other)) | ||
if (this.eq(other)) | ||
return 0; | ||
@@ -699,3 +705,3 @@ var thisNeg = this.isNegative(), | ||
if (!this.unsigned) | ||
return this.subtract(other).isNegative() ? -1 : 1; | ||
return this.sub(other).isNegative() ? -1 : 1; | ||
// Both are positive if at least one is unsigned | ||
@@ -706,2 +712,12 @@ return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1; | ||
/** | ||
* Compares this Long's value with the specified's. This is an alias of {@link Long#compare}. | ||
* @function | ||
* @param {!Long|number|string} other Other value | ||
* @returns {number} 0 if they are the same, 1 if the this is greater and -1 | ||
* if the given one is greater | ||
* @expose | ||
*/ | ||
LongPrototype.comp = LongPrototype.compare; | ||
/** | ||
* Negates this Long's value. | ||
@@ -711,4 +727,4 @@ * @returns {!Long} Negated Long | ||
*/ | ||
Long.prototype.negate = function negate() { | ||
if (!this.unsigned && this.equals(Long.MIN_VALUE)) | ||
LongPrototype.negate = function negate() { | ||
if (!this.unsigned && this.eq(Long.MIN_VALUE)) | ||
return Long.MIN_VALUE; | ||
@@ -724,3 +740,3 @@ return this.not().add(Long.ONE); | ||
*/ | ||
Long.prototype.neg = Long.prototype.negate; | ||
LongPrototype.neg = LongPrototype.negate; | ||
@@ -733,3 +749,3 @@ /** | ||
*/ | ||
Long.prototype.add = function add(addend) { | ||
LongPrototype.add = function add(addend) { | ||
if (!Long.isLong(addend)) | ||
@@ -762,3 +778,3 @@ addend = Long.fromValue(addend); | ||
c48 &= 0xFFFF; | ||
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); | ||
return new Long((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); | ||
}; | ||
@@ -772,6 +788,6 @@ | ||
*/ | ||
Long.prototype.subtract = function subtract(subtrahend) { | ||
LongPrototype.subtract = function subtract(subtrahend) { | ||
if (!Long.isLong(subtrahend)) | ||
subtrahend = Long.fromValue(subtrahend); | ||
return this.add(subtrahend.negate()); | ||
return this.add(subtrahend.neg()); | ||
}; | ||
@@ -786,3 +802,3 @@ | ||
*/ | ||
Long.prototype.sub = Long.prototype.subtract; | ||
LongPrototype.sub = LongPrototype.subtract; | ||
@@ -795,3 +811,3 @@ /** | ||
*/ | ||
Long.prototype.multiply = function multiply(multiplier) { | ||
LongPrototype.multiply = function multiply(multiplier) { | ||
if (this.isZero()) | ||
@@ -803,5 +819,5 @@ return Long.ZERO; | ||
return Long.ZERO; | ||
if (this.equals(Long.MIN_VALUE)) | ||
if (this.eq(Long.MIN_VALUE)) | ||
return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; | ||
if (multiplier.equals(Long.MIN_VALUE)) | ||
if (multiplier.eq(Long.MIN_VALUE)) | ||
return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; | ||
@@ -811,10 +827,10 @@ | ||
if (multiplier.isNegative()) | ||
return this.negate().multiply(multiplier.negate()); | ||
return this.neg().mul(multiplier.neg()); | ||
else | ||
return this.negate().multiply(multiplier).negate(); | ||
return this.neg().mul(multiplier).neg(); | ||
} else if (multiplier.isNegative()) | ||
return this.multiply(multiplier.negate()).negate(); | ||
return this.mul(multiplier.neg()).neg(); | ||
// If both longs are small, use float multiplication | ||
if (this.lessThan(TWO_PWR_24) && multiplier.lessThan(TWO_PWR_24)) | ||
if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24)) | ||
return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); | ||
@@ -856,3 +872,3 @@ | ||
c48 &= 0xFFFF; | ||
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); | ||
return new Long((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); | ||
}; | ||
@@ -867,3 +883,3 @@ | ||
*/ | ||
Long.prototype.mul = Long.prototype.multiply; | ||
LongPrototype.mul = LongPrototype.multiply; | ||
@@ -876,35 +892,35 @@ /** | ||
*/ | ||
Long.prototype.divide = function divide(divisor) { | ||
LongPrototype.divide = function divide(divisor) { | ||
if (!Long.isLong(divisor)) | ||
divisor = Long.fromValue(divisor); | ||
if (divisor.isZero()) | ||
throw(new Error('division by zero')); | ||
throw Error('division by zero'); | ||
if (this.isZero()) | ||
return this.unsigned ? Long.UZERO : Long.ZERO; | ||
var approx, rem, res; | ||
if (this.equals(Long.MIN_VALUE)) { | ||
if (divisor.equals(Long.ONE) || divisor.equals(Long.NEG_ONE)) | ||
if (this.eq(Long.MIN_VALUE)) { | ||
if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) | ||
return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE | ||
else if (divisor.equals(Long.MIN_VALUE)) | ||
else if (divisor.eq(Long.MIN_VALUE)) | ||
return Long.ONE; | ||
else { | ||
// At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. | ||
var halfThis = this.shiftRight(1); | ||
approx = halfThis.divide(divisor).shiftLeft(1); | ||
if (approx.equals(Long.ZERO)) { | ||
var halfThis = this.shr(1); | ||
approx = halfThis.div(divisor).shl(1); | ||
if (approx.eq(Long.ZERO)) { | ||
return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; | ||
} else { | ||
rem = this.subtract(divisor.multiply(approx)); | ||
res = approx.add(rem.divide(divisor)); | ||
rem = this.sub(divisor.mul(approx)); | ||
res = approx.add(rem.div(divisor)); | ||
return res; | ||
} | ||
} | ||
} else if (divisor.equals(Long.MIN_VALUE)) | ||
} else if (divisor.eq(Long.MIN_VALUE)) | ||
return this.unsigned ? Long.UZERO : Long.ZERO; | ||
if (this.isNegative()) { | ||
if (divisor.isNegative()) | ||
return this.negate().divide(divisor.negate()); | ||
return this.negate().divide(divisor).negate(); | ||
return this.neg().div(divisor.neg()); | ||
return this.neg().div(divisor).neg(); | ||
} else if (divisor.isNegative()) | ||
return this.divide(divisor.negate()).negate(); | ||
return this.div(divisor.neg()).neg(); | ||
@@ -918,3 +934,3 @@ // Repeat the following until the remainder is less than other: find a | ||
rem = this; | ||
while (rem.greaterThanOrEqual(divisor)) { | ||
while (rem.gte(divisor)) { | ||
// Approximate the result of division. This may be a little greater or | ||
@@ -932,7 +948,7 @@ // smaller than the actual value. | ||
approxRes = Long.fromNumber(approx), | ||
approxRem = approxRes.multiply(divisor); | ||
while (approxRem.isNegative() || approxRem.greaterThan(rem)) { | ||
approxRem = approxRes.mul(divisor); | ||
while (approxRem.isNegative() || approxRem.gt(rem)) { | ||
approx -= delta; | ||
approxRes = Long.fromNumber(approx, this.unsigned); | ||
approxRem = approxRes.multiply(divisor); | ||
approxRem = approxRes.mul(divisor); | ||
} | ||
@@ -946,3 +962,3 @@ | ||
res = res.add(approxRes); | ||
rem = rem.subtract(approxRem); | ||
rem = rem.sub(approxRem); | ||
} | ||
@@ -959,3 +975,3 @@ return res; | ||
*/ | ||
Long.prototype.div = Long.prototype.divide; | ||
LongPrototype.div = LongPrototype.divide; | ||
@@ -968,6 +984,6 @@ /** | ||
*/ | ||
Long.prototype.modulo = function modulo(divisor) { | ||
LongPrototype.modulo = function modulo(divisor) { | ||
if (!Long.isLong(divisor)) | ||
divisor = Long.fromValue(divisor); | ||
return this.subtract(this.divide(divisor).multiply(divisor)); | ||
return this.sub(this.div(divisor).mul(divisor)); | ||
}; | ||
@@ -982,3 +998,3 @@ | ||
*/ | ||
Long.prototype.mod = Long.prototype.modulo; | ||
LongPrototype.mod = LongPrototype.modulo; | ||
@@ -990,4 +1006,4 @@ /** | ||
*/ | ||
Long.prototype.not = function not() { | ||
return Long.fromBits(~this.low, ~this.high, this.unsigned); | ||
LongPrototype.not = function not() { | ||
return new Long(~this.low, ~this.high, this.unsigned); | ||
}; | ||
@@ -1001,6 +1017,6 @@ | ||
*/ | ||
Long.prototype.and = function and(other) { | ||
LongPrototype.and = function and(other) { | ||
if (!Long.isLong(other)) | ||
other = Long.fromValue(other); | ||
return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); | ||
return new Long(this.low & other.low, this.high & other.high, this.unsigned); | ||
}; | ||
@@ -1014,6 +1030,6 @@ | ||
*/ | ||
Long.prototype.or = function or(other) { | ||
LongPrototype.or = function or(other) { | ||
if (!Long.isLong(other)) | ||
other = Long.fromValue(other); | ||
return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); | ||
return new Long(this.low | other.low, this.high | other.high, this.unsigned); | ||
}; | ||
@@ -1027,6 +1043,6 @@ | ||
*/ | ||
Long.prototype.xor = function xor(other) { | ||
LongPrototype.xor = function xor(other) { | ||
if (!Long.isLong(other)) | ||
other = Long.fromValue(other); | ||
return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); | ||
return new Long(this.low ^ other.low, this.high ^ other.high, this.unsigned); | ||
}; | ||
@@ -1040,3 +1056,3 @@ | ||
*/ | ||
Long.prototype.shiftLeft = function shiftLeft(numBits) { | ||
LongPrototype.shiftLeft = function shiftLeft(numBits) { | ||
if (Long.isLong(numBits)) | ||
@@ -1047,5 +1063,5 @@ numBits = numBits.toInt(); | ||
else if (numBits < 32) | ||
return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); | ||
return new Long(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); | ||
else | ||
return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); | ||
return new Long(0, this.low << (numBits - 32), this.unsigned); | ||
}; | ||
@@ -1060,3 +1076,3 @@ | ||
*/ | ||
Long.prototype.shl = Long.prototype.shiftLeft; | ||
LongPrototype.shl = LongPrototype.shiftLeft; | ||
@@ -1069,3 +1085,3 @@ /** | ||
*/ | ||
Long.prototype.shiftRight = function shiftRight(numBits) { | ||
LongPrototype.shiftRight = function shiftRight(numBits) { | ||
if (Long.isLong(numBits)) | ||
@@ -1076,5 +1092,5 @@ numBits = numBits.toInt(); | ||
else if (numBits < 32) | ||
return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); | ||
return new Long((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); | ||
else | ||
return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); | ||
return new Long(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); | ||
}; | ||
@@ -1089,3 +1105,3 @@ | ||
*/ | ||
Long.prototype.shr = Long.prototype.shiftRight; | ||
LongPrototype.shr = LongPrototype.shiftRight; | ||
@@ -1098,3 +1114,3 @@ /** | ||
*/ | ||
Long.prototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) { | ||
LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) { | ||
if (Long.isLong(numBits)) | ||
@@ -1109,7 +1125,7 @@ numBits = numBits.toInt(); | ||
var low = this.low; | ||
return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned); | ||
return new Long((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned); | ||
} else if (numBits === 32) | ||
return Long.fromBits(high, 0, this.unsigned); | ||
return new Long(high, 0, this.unsigned); | ||
else | ||
return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); | ||
return new Long(high >>> (numBits - 32), 0, this.unsigned); | ||
} | ||
@@ -1125,3 +1141,3 @@ }; | ||
*/ | ||
Long.prototype.shru = Long.prototype.shiftRightUnsigned; | ||
LongPrototype.shru = LongPrototype.shiftRightUnsigned; | ||
@@ -1133,3 +1149,3 @@ /** | ||
*/ | ||
Long.prototype.toSigned = function toSigned() { | ||
LongPrototype.toSigned = function toSigned() { | ||
if (!this.unsigned) | ||
@@ -1145,3 +1161,3 @@ return this; | ||
*/ | ||
Long.prototype.toUnsigned = function toUnsigned() { | ||
LongPrototype.toUnsigned = function toUnsigned() { | ||
if (this.unsigned) | ||
@@ -1148,0 +1164,0 @@ return this; |
/* | ||
Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io> | ||
long.js (c) 2013 Daniel Wirtz <dcode@dcode.io> | ||
Released under the Apache License, Version 2.0 | ||
see: https://github.com/dcodeIO/Long.js for details | ||
see: https://github.com/dcodeIO/long.js for details | ||
*/ | ||
function p(){function b(a,b,d){this.low=a|0;this.high=b|0;this.unsigned=!!d}Object.defineProperty(b.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});b.isLong=function(a){return!0===(a&&a.__isLong__)};var r={},s={};b.fromInt=function(a,c){var d;if(c){a>>>=0;if(0<=a&&256>a&&(d=s[a]))return d;d=new b(a,0>(a|0)?-1:0,!0);0<=a&&256>a&&(s[a]=d)}else{a|=0;if(-128<=a&&128>a&&(d=r[a]))return d;d=new b(a,0>a?-1:0,!1);-128<=a&&128>a&&(r[a]=d)}return d};b.fromNumber=function(a,c){c=!!c;return isNaN(a)|| | ||
!isFinite(a)?b.ZERO:!c&&a<=-t?b.MIN_VALUE:!c&&a+1>=t?b.MAX_VALUE:c&&a>=u?b.MAX_UNSIGNED_VALUE:0>a?b.fromNumber(-a,c).negate():new b(a%4294967296|0,a/4294967296|0,c)};b.fromBits=function(a,c,d){return new b(a,c,d)};b.fromString=function(a,c,d){if(0===a.length)throw Error("number format error: empty string");if("NaN"===a||"Infinity"===a||"+Infinity"===a||"-Infinity"===a)return b.ZERO;"number"===typeof c&&(d=c,c=!1);d=d||10;if(2>d||36<d)throw Error("radix out of range: "+d);var e;if(0<(e=a.indexOf("-")))throw Error('number format error: interior "-" character: '+ | ||
a);if(0===e)return b.fromString(a.substring(1),c,d).negate();e=b.fromNumber(Math.pow(d,8));for(var f=b.ZERO,g=0;g<a.length;g+=8){var k=Math.min(8,a.length-g),l=parseInt(a.substring(g,g+k),d);8>k?(k=b.fromNumber(Math.pow(d,k)),f=f.multiply(k).add(b.fromNumber(l))):(f=f.multiply(e),f=f.add(b.fromNumber(l)))}f.unsigned=c;return f};b.fromValue=function(a){return a instanceof b?a:"number"===typeof a?b.fromNumber(a):"string"===typeof a?b.fromString(a):new b(a.low,a.high,a.unsigned)};var u=4294967296*4294967296, | ||
t=u/2,v=b.fromInt(16777216);b.ZERO=b.fromInt(0);b.UZERO=b.fromInt(0,!0);b.ONE=b.fromInt(1);b.UONE=b.fromInt(1,!0);b.NEG_ONE=b.fromInt(-1);b.MAX_VALUE=b.fromBits(-1,2147483647,!1);b.MAX_UNSIGNED_VALUE=b.fromBits(-1,-1,!0);b.MIN_VALUE=b.fromBits(0,-2147483648,!1);b.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.prototype.toNumber=function(){return this.unsigned?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(this.low>>>0)};b.prototype.toString=function(a){a= | ||
a||10;if(2>a||36<a)throw RangeError("radix out of range: "+a);if(this.isZero())return"0";var c;if(this.isNegative()){if(this.equals(b.MIN_VALUE)){c=b.fromNumber(a);var d=this.divide(c);c=d.multiply(c).subtract(this);return d.toString(a)+c.toInt().toString(a)}return"-"+this.negate().toString(a)}d=b.fromNumber(Math.pow(a,6),this.unsigned);c=this;for(var e="";;){var f=c.divide(d),g=(c.subtract(f.multiply(d)).toInt()>>>0).toString(a);c=f;if(c.isZero())return g+e;for(;6>g.length;)g="0"+g;e=""+g+e}};b.prototype.getHighBits= | ||
function(){return this.high};b.prototype.getHighBitsUnsigned=function(){return this.high>>>0};b.prototype.getLowBits=function(){return this.low};b.prototype.getLowBitsUnsigned=function(){return this.low>>>0};b.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(b.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var a=0!=this.high?this.high:this.low,c=31;0<c&&0==(a&1<<c);c--);return 0!=this.high?c+33:c+1};b.prototype.isZero=function(){return 0===this.high&&0===this.low};b.prototype.isNegative= | ||
function(){return!this.unsigned&&0>this.high};b.prototype.isPositive=function(){return this.unsigned||0<=this.high};b.prototype.isOdd=function(){return 1===(this.low&1)};b.prototype.isEven=function(){return 0===(this.low&1)};b.prototype.equals=function(a){b.isLong(a)||(a=b.fromValue(a));return this.unsigned!==a.unsigned&&1===this.high>>>31&&1===a.high>>>31?!1:this.high===a.high&&this.low===a.low};b.eq=b.prototype.equals;b.prototype.notEquals=function(a){return!this.equals(a)};b.neq=b.prototype.notEquals; | ||
b.prototype.lessThan=function(a){return 0>this.compare(a)};b.prototype.lt=b.prototype.lessThan;b.prototype.lessThanOrEqual=function(a){return 0>=this.compare(a)};b.prototype.lte=b.prototype.lessThanOrEqual;b.prototype.greaterThan=function(a){return 0<this.compare(a)};b.prototype.gt=b.prototype.greaterThan;b.prototype.greaterThanOrEqual=function(a){return 0<=this.compare(a)};b.prototype.gte=b.prototype.greaterThanOrEqual;b.prototype.compare=function(a){b.isLong(a)||(a=b.fromValue(a));if(this.equals(a))return 0; | ||
var c=this.isNegative(),d=a.isNegative();return c&&!d?-1:!c&&d?1:this.unsigned?a.high>>>0>this.high>>>0||a.high===this.high&&a.low>>>0>this.low>>>0?-1:1:this.subtract(a).isNegative()?-1:1};b.prototype.negate=function(){return!this.unsigned&&this.equals(b.MIN_VALUE)?b.MIN_VALUE:this.not().add(b.ONE)};b.prototype.neg=b.prototype.negate;b.prototype.add=function(a){b.isLong(a)||(a=b.fromValue(a));var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=a.high>>>16,g=a.high&65535,k=a.low>>>16,l;l=0+((this.low& | ||
65535)+(a.low&65535));a=0+(l>>>16);a+=e+k;e=0+(a>>>16);e+=d+g;d=0+(e>>>16);d=d+(c+f)&65535;return b.fromBits((a&65535)<<16|l&65535,d<<16|e&65535,this.unsigned)};b.prototype.subtract=function(a){b.isLong(a)||(a=b.fromValue(a));return this.add(a.negate())};b.prototype.sub=b.prototype.subtract;b.prototype.multiply=function(a){if(this.isZero())return b.ZERO;b.isLong(a)||(a=b.fromValue(a));if(a.isZero())return b.ZERO;if(this.equals(b.MIN_VALUE))return a.isOdd()?b.MIN_VALUE:b.ZERO;if(a.equals(b.MIN_VALUE))return this.isOdd()? | ||
b.MIN_VALUE:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().multiply(a.negate()):this.negate().multiply(a).negate();if(a.isNegative())return this.multiply(a.negate()).negate();if(this.lessThan(v)&&a.lessThan(v))return b.fromNumber(this.toNumber()*a.toNumber(),this.unsigned);var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=this.low&65535,g=a.high>>>16,k=a.high&65535,l=a.low>>>16;a=a.low&65535;var n,h,m,q;q=0+f*a;m=0+(q>>>16);m+=e*a;h=0+(m>>>16);m=(m&65535)+f*l;h+=m>>>16;m&= | ||
65535;h+=d*a;n=0+(h>>>16);h=(h&65535)+e*l;n+=h>>>16;h&=65535;h+=f*k;n+=h>>>16;h&=65535;n=n+(c*a+d*l+e*k+f*g)&65535;return b.fromBits(m<<16|q&65535,n<<16|h,this.unsigned)};b.prototype.mul=b.prototype.multiply;b.prototype.divide=function(a){b.isLong(a)||(a=b.fromValue(a));if(a.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?b.UZERO:b.ZERO;var c,d,e;if(this.equals(b.MIN_VALUE)){if(a.equals(b.ONE)||a.equals(b.NEG_ONE))return b.MIN_VALUE;if(a.equals(b.MIN_VALUE))return b.ONE; | ||
c=this.shiftRight(1).divide(a).shiftLeft(1);if(c.equals(b.ZERO))return a.isNegative()?b.ONE:b.NEG_ONE;d=this.subtract(a.multiply(c));return e=c.add(d.divide(a))}if(a.equals(b.MIN_VALUE))return this.unsigned?b.UZERO:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().divide(a.negate()):this.negate().divide(a).negate();if(a.isNegative())return this.divide(a.negate()).negate();e=b.ZERO;for(d=this;d.greaterThanOrEqual(a);){c=Math.max(1,Math.floor(d.toNumber()/a.toNumber()));for(var f=Math.ceil(Math.log(c)/ | ||
Math.LN2),f=48>=f?1:Math.pow(2,f-48),g=b.fromNumber(c),k=g.multiply(a);k.isNegative()||k.greaterThan(d);)c-=f,g=b.fromNumber(c,this.unsigned),k=g.multiply(a);g.isZero()&&(g=b.ONE);e=e.add(g);d=d.subtract(k)}return e};b.prototype.div=b.prototype.divide;b.prototype.modulo=function(a){b.isLong(a)||(a=b.fromValue(a));return this.subtract(this.divide(a).multiply(a))};b.prototype.mod=b.prototype.modulo;b.prototype.not=function(){return b.fromBits(~this.low,~this.high,this.unsigned)};b.prototype.and=function(a){b.isLong(a)|| | ||
(a=b.fromValue(a));return b.fromBits(this.low&a.low,this.high&a.high,this.unsigned)};b.prototype.or=function(a){b.isLong(a)||(a=b.fromValue(a));return b.fromBits(this.low|a.low,this.high|a.high,this.unsigned)};b.prototype.xor=function(a){b.isLong(a)||(a=b.fromValue(a));return b.fromBits(this.low^a.low,this.high^a.high,this.unsigned)};b.prototype.shiftLeft=function(a){b.isLong(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?b.fromBits(this.low<<a,this.high<<a|this.low>>>32-a,this.unsigned):b.fromBits(0, | ||
this.low<<a-32,this.unsigned)};b.prototype.shl=b.prototype.shiftLeft;b.prototype.shiftRight=function(a){b.isLong(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?b.fromBits(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):b.fromBits(this.high>>a-32,0<=this.high?0:-1,this.unsigned)};b.prototype.shr=b.prototype.shiftRight;b.prototype.shiftRightUnsigned=function(a){b.isLong(a)&&(a=a.toInt());a&=63;if(0===a)return this;var c=this.high;return 32>a?b.fromBits(this.low>>>a|c<<32-a,c>>>a,this.unsigned): | ||
32===a?b.fromBits(c,0,this.unsigned):b.fromBits(c>>>a-32,0,this.unsigned)};b.prototype.shru=b.prototype.shiftRightUnsigned;b.prototype.toSigned=function(){return this.unsigned?new b(this.low,this.high,!1):this};b.prototype.toUnsigned=function(){return this.unsigned?this:new b(this.low,this.high,!0)};return b}"function"===typeof define&&define.amd?define([],p):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=p():(this.dcodeIO=this.dcodeIO||{}).Long=p(); | ||
function p(){function c(a,c,b){this.low=a|0;this.high=c|0;this.unsigned=!!b}Object.defineProperty(c.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});c.isLong=function(a){return!0===(a&&a.__isLong__)};var r={},s={};c.fromInt=function(a,b){var d,e;if(b){a>>>=0;if(e=0<=a&&256>a)if(d=s[a])return d;d=new c(a,0>(a|0)?-1:0,!0);e&&(s[a]=d)}else{a|=0;if(e=-128<=a&&128>a)if(d=r[a])return d;d=new c(a,0>a?-1:0,!1);e&&(r[a]=d)}return d};c.fromNumber=function(a,b){b=!!b;return isNaN(a)||!isFinite(a)? | ||
c.ZERO:!b&&a<=-t?c.MIN_VALUE:!b&&a+1>=t?c.MAX_VALUE:b&&a>=u?c.MAX_UNSIGNED_VALUE:0>a?c.fromNumber(-a,b).neg():new c(a%4294967296|0,a/4294967296|0,b)};c.fromBits=function(a,b,d){return new c(a,b,d)};c.fromString=function(a,b,d){if(0===a.length)throw Error("number format error: empty string");if("NaN"===a||"Infinity"===a||"+Infinity"===a||"-Infinity"===a)return c.ZERO;"number"===typeof b&&(d=b,b=!1);d=d||10;if(2>d||36<d)throw Error("radix out of range: "+d);var e;if(0<(e=a.indexOf("-")))throw Error('number format error: interior "-" character: '+ | ||
a);if(0===e)return c.fromString(a.substring(1),b,d).neg();e=c.fromNumber(Math.pow(d,8));for(var f=c.ZERO,g=0;g<a.length;g+=8){var k=Math.min(8,a.length-g),l=parseInt(a.substring(g,g+k),d);8>k?(k=c.fromNumber(Math.pow(d,k)),f=f.mul(k).add(c.fromNumber(l))):(f=f.mul(e),f=f.add(c.fromNumber(l)))}f.unsigned=b;return f};c.fromValue=function(a){return a instanceof c?a:"number"===typeof a?c.fromNumber(a):"string"===typeof a?c.fromString(a):new c(a.low,a.high,a.unsigned)};var u=4294967296*4294967296,t=u/ | ||
2,v=c.fromInt(16777216);c.ZERO=c.fromInt(0);c.UZERO=c.fromInt(0,!0);c.ONE=c.fromInt(1);c.UONE=c.fromInt(1,!0);c.NEG_ONE=c.fromInt(-1);c.MAX_VALUE=new c(-1,2147483647,!1);c.MAX_UNSIGNED_VALUE=new c(-1,-1,!0);c.MIN_VALUE=new c(0,-2147483648,!1);var b=c.prototype;b.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.toNumber=function(){return this.unsigned?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(this.low>>>0)};b.toString=function(a){a=a||10;if(2>a||36<a)throw RangeError("radix out of range: "+ | ||
a);if(this.isZero())return"0";var b;if(this.isNegative()){if(this.eq(c.MIN_VALUE)){b=c.fromNumber(a);var d=this.div(b);b=d.mul(b).sub(this);return d.toString(a)+b.toInt().toString(a)}return"-"+this.neg().toString(a)}d=c.fromNumber(Math.pow(a,6),this.unsigned);b=this;for(var e="";;){var f=b.div(d),g=(b.sub(f.mul(d)).toInt()>>>0).toString(a);b=f;if(b.isZero())return g+e;for(;6>g.length;)g="0"+g;e=""+g+e}};b.getHighBits=function(){return this.high};b.getHighBitsUnsigned=function(){return this.high>>> | ||
0};b.getLowBits=function(){return this.low};b.getLowBitsUnsigned=function(){return this.low>>>0};b.getNumBitsAbs=function(){if(this.isNegative())return this.eq(c.MIN_VALUE)?64:this.neg().getNumBitsAbs();for(var a=0!=this.high?this.high:this.low,b=31;0<b&&0==(a&1<<b);b--);return 0!=this.high?b+33:b+1};b.isZero=function(){return 0===this.high&&0===this.low};b.isNegative=function(){return!this.unsigned&&0>this.high};b.isPositive=function(){return this.unsigned||0<=this.high};b.isOdd=function(){return 1=== | ||
(this.low&1)};b.isEven=function(){return 0===(this.low&1)};b.equals=function(a){c.isLong(a)||(a=c.fromValue(a));return this.unsigned!==a.unsigned&&1===this.high>>>31&&1===a.high>>>31?!1:this.high===a.high&&this.low===a.low};b.eq=b.equals;b.notEquals=function(a){return!this.eq(a)};b.neq=b.notEquals;b.lessThan=function(a){return 0>this.compare(a)};b.lt=b.lessThan;b.lessThanOrEqual=function(a){return 0>=this.compare(a)};b.lte=b.lessThanOrEqual;b.greaterThan=function(a){return 0<this.compare(a)};b.gt= | ||
b.greaterThan;b.greaterThanOrEqual=function(a){return 0<=this.compare(a)};b.gte=b.greaterThanOrEqual;b.compare=function(a){c.isLong(a)||(a=c.fromValue(a));if(this.eq(a))return 0;var b=this.isNegative(),d=a.isNegative();return b&&!d?-1:!b&&d?1:this.unsigned?a.high>>>0>this.high>>>0||a.high===this.high&&a.low>>>0>this.low>>>0?-1:1:this.sub(a).isNegative()?-1:1};b.comp=b.compare;b.negate=function(){return!this.unsigned&&this.eq(c.MIN_VALUE)?c.MIN_VALUE:this.not().add(c.ONE)};b.neg=b.negate;b.add=function(a){c.isLong(a)|| | ||
(a=c.fromValue(a));var b=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=a.high>>>16,g=a.high&65535,k=a.low>>>16,l;l=0+((this.low&65535)+(a.low&65535));a=0+(l>>>16);a+=e+k;e=0+(a>>>16);e+=d+g;d=0+(e>>>16);d=d+(b+f)&65535;return new c((a&65535)<<16|l&65535,d<<16|e&65535,this.unsigned)};b.subtract=function(a){c.isLong(a)||(a=c.fromValue(a));return this.add(a.neg())};b.sub=b.subtract;b.multiply=function(a){if(this.isZero())return c.ZERO;c.isLong(a)||(a=c.fromValue(a));if(a.isZero())return c.ZERO; | ||
if(this.eq(c.MIN_VALUE))return a.isOdd()?c.MIN_VALUE:c.ZERO;if(a.eq(c.MIN_VALUE))return this.isOdd()?c.MIN_VALUE:c.ZERO;if(this.isNegative())return a.isNegative()?this.neg().mul(a.neg()):this.neg().mul(a).neg();if(a.isNegative())return this.mul(a.neg()).neg();if(this.lt(v)&&a.lt(v))return c.fromNumber(this.toNumber()*a.toNumber(),this.unsigned);var b=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=this.low&65535,g=a.high>>>16,k=a.high&65535,l=a.low>>>16;a=a.low&65535;var n,h,m,q;q=0+f*a;m=0+(q>>> | ||
16);m+=e*a;h=0+(m>>>16);m=(m&65535)+f*l;h+=m>>>16;m&=65535;h+=d*a;n=0+(h>>>16);h=(h&65535)+e*l;n+=h>>>16;h&=65535;h+=f*k;n+=h>>>16;h&=65535;n=n+(b*a+d*l+e*k+f*g)&65535;return new c(m<<16|q&65535,n<<16|h,this.unsigned)};b.mul=b.multiply;b.divide=function(a){c.isLong(a)||(a=c.fromValue(a));if(a.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?c.UZERO:c.ZERO;var b,d,e;if(this.eq(c.MIN_VALUE)){if(a.eq(c.ONE)||a.eq(c.NEG_ONE))return c.MIN_VALUE;if(a.eq(c.MIN_VALUE))return c.ONE; | ||
b=this.shr(1).div(a).shl(1);if(b.eq(c.ZERO))return a.isNegative()?c.ONE:c.NEG_ONE;d=this.sub(a.mul(b));return e=b.add(d.div(a))}if(a.eq(c.MIN_VALUE))return this.unsigned?c.UZERO:c.ZERO;if(this.isNegative())return a.isNegative()?this.neg().div(a.neg()):this.neg().div(a).neg();if(a.isNegative())return this.div(a.neg()).neg();e=c.ZERO;for(d=this;d.gte(a);){b=Math.max(1,Math.floor(d.toNumber()/a.toNumber()));for(var f=Math.ceil(Math.log(b)/Math.LN2),f=48>=f?1:Math.pow(2,f-48),g=c.fromNumber(b),k=g.mul(a);k.isNegative()|| | ||
k.gt(d);)b-=f,g=c.fromNumber(b,this.unsigned),k=g.mul(a);g.isZero()&&(g=c.ONE);e=e.add(g);d=d.sub(k)}return e};b.div=b.divide;b.modulo=function(a){c.isLong(a)||(a=c.fromValue(a));return this.sub(this.div(a).mul(a))};b.mod=b.modulo;b.not=function(){return new c(~this.low,~this.high,this.unsigned)};b.and=function(a){c.isLong(a)||(a=c.fromValue(a));return new c(this.low&a.low,this.high&a.high,this.unsigned)};b.or=function(a){c.isLong(a)||(a=c.fromValue(a));return new c(this.low|a.low,this.high|a.high, | ||
this.unsigned)};b.xor=function(a){c.isLong(a)||(a=c.fromValue(a));return new c(this.low^a.low,this.high^a.high,this.unsigned)};b.shiftLeft=function(a){c.isLong(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?new c(this.low<<a,this.high<<a|this.low>>>32-a,this.unsigned):new c(0,this.low<<a-32,this.unsigned)};b.shl=b.shiftLeft;b.shiftRight=function(a){c.isLong(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?new c(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):new c(this.high>>a-32,0<=this.high? | ||
0:-1,this.unsigned)};b.shr=b.shiftRight;b.shiftRightUnsigned=function(a){c.isLong(a)&&(a=a.toInt());a&=63;if(0===a)return this;var b=this.high;return 32>a?new c(this.low>>>a|b<<32-a,b>>>a,this.unsigned):32===a?new c(b,0,this.unsigned):new c(b>>>a-32,0,this.unsigned)};b.shru=b.shiftRightUnsigned;b.toSigned=function(){return this.unsigned?new c(this.low,this.high,!1):this};b.toUnsigned=function(){return this.unsigned?this:new c(this.low,this.high,!0)};return c} | ||
"function"===typeof define&&define.amd?define([],p):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=p():(this.dcodeIO=this.dcodeIO||{}).Long=p(); |
{ | ||
"name": "long", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"author": "Daniel Wirtz <dcode@dcode.io>", | ||
@@ -5,0 +5,0 @@ "description": "A Long class for representing a 64-bit two's-complement integer value.", |
@@ -1,2 +0,2 @@ | ||
![Long.js - A Long class for representing a 64 bit two's-complement integer ](https://raw.github.com/dcodeIO/Long.js/master/long.png) | ||
![long.js - A Long class for representing a 64 bit two's-complement integer ](https://raw.github.com/dcodeIO/long.js/master/long.png) | ||
======= | ||
@@ -6,4 +6,4 @@ A Long class for representing a 64 bit two's-complement integer value derived from the [Closure Library](https://github.com/google/closure-library) | ||
[![Build Status](https://travis-ci.org/dcodeIO/Long.js.svg)](https://travis-ci.org/dcodeIO/Long.js) | ||
[![Donate](https://raw.githubusercontent.com/dcodeIO/Long.js/master/donate.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=info%40code-emitter.com&item_name=Open%20Source%3A%20Long.js) | ||
[![Build Status](https://travis-ci.org/dcodeIO/long.js.svg)](https://travis-ci.org/dcodeIO/long.js) | ||
[![Donate](https://raw.githubusercontent.com/dcodeIO/long.js/master/donate.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dcode%40dcode.io&item_name=%3C3%20long.js) | ||
@@ -25,3 +25,3 @@ Background | ||
In some use cases, however, it is required to be able to reliably work with and perform bitwise operations on the full | ||
64 bits. This is where Long.js comes into play. | ||
64 bits. This is where long.js comes into play. | ||
@@ -509,5 +509,5 @@ Usage | ||
--------- | ||
* [Distributions](https://github.com/dcodeIO/Long.js/tree/master/dist) | ||
* [ZIP-Archive](https://github.com/dcodeIO/Long.js/archive/master.zip) | ||
* [Tarball](https://github.com/dcodeIO/Long.js/tarball/master) | ||
* [Distributions](https://github.com/dcodeIO/long.js/tree/master/dist) | ||
* [ZIP-Archive](https://github.com/dcodeIO/long.js/archive/master.zip) | ||
* [Tarball](https://github.com/dcodeIO/long.js/tarball/master) | ||
@@ -514,0 +514,0 @@ License |
238
src/long.js
@@ -99,6 +99,6 @@ /** | ||
Long.fromInt = function fromInt(value, unsigned) { | ||
var obj, cachedObj; | ||
var obj, cachedObj, cache; | ||
if (!unsigned) { | ||
value = value | 0; | ||
if (-128 <= value && value < 128) { | ||
if (cache = (-128 <= value && value < 128)) { | ||
cachedObj = INT_CACHE[value]; | ||
@@ -109,3 +109,3 @@ if (cachedObj) | ||
obj = new Long(value, value < 0 ? -1 : 0, false); | ||
if (-128 <= value && value < 128) | ||
if (cache) | ||
INT_CACHE[value] = obj; | ||
@@ -115,3 +115,3 @@ return obj; | ||
value = value >>> 0; | ||
if (0 <= value && value < 256) { | ||
if (cache = (0 <= value && value < 256)) { | ||
cachedObj = UINT_CACHE[value]; | ||
@@ -122,3 +122,3 @@ if (cachedObj) | ||
obj = new Long(value, (value | 0) < 0 ? -1 : 0, true); | ||
if (0 <= value && value < 256) | ||
if (cache) | ||
UINT_CACHE[value] = obj; | ||
@@ -147,3 +147,3 @@ return obj; | ||
if (value < 0) | ||
return Long.fromNumber(-value, unsigned).negate(); | ||
return Long.fromNumber(-value, unsigned).neg(); | ||
return new Long((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); | ||
@@ -189,3 +189,3 @@ }; | ||
else if (p === 0) | ||
return Long.fromString(str.substring(1), unsigned, radix).negate(); | ||
return Long.fromString(str.substring(1), unsigned, radix).neg(); | ||
@@ -202,5 +202,5 @@ // Do several (8) digits each time through the loop, so as to | ||
var power = Long.fromNumber(Math.pow(radix, size)); | ||
result = result.multiply(power).add(Long.fromNumber(value)); | ||
result = result.mul(power).add(Long.fromNumber(value)); | ||
} else { | ||
result = result.multiply(radixToPower); | ||
result = result.mul(radixToPower); | ||
result = result.add(Long.fromNumber(value)); | ||
@@ -315,3 +315,3 @@ } | ||
*/ | ||
Long.MAX_VALUE = Long.fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false); | ||
Long.MAX_VALUE = new Long(0xFFFFFFFF|0, 0x7FFFFFFF|0, false); | ||
@@ -323,3 +323,3 @@ /** | ||
*/ | ||
Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xFFFFFFFF|0, 0xFFFFFFFF|0, true); | ||
Long.MAX_UNSIGNED_VALUE = new Long(0xFFFFFFFF|0, 0xFFFFFFFF|0, true); | ||
@@ -331,5 +331,11 @@ /** | ||
*/ | ||
Long.MIN_VALUE = Long.fromBits(0, 0x80000000|0, false); | ||
Long.MIN_VALUE = new Long(0, 0x80000000|0, false); | ||
/** | ||
* @alias Long.prototype | ||
* @inner | ||
*/ | ||
var LongPrototype = Long.prototype; | ||
/** | ||
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. | ||
@@ -339,3 +345,3 @@ * @returns {number} | ||
*/ | ||
Long.prototype.toInt = function toInt() { | ||
LongPrototype.toInt = function toInt() { | ||
return this.unsigned ? this.low >>> 0 : this.low; | ||
@@ -349,3 +355,3 @@ }; | ||
*/ | ||
Long.prototype.toNumber = function toNumber() { | ||
LongPrototype.toNumber = function toNumber() { | ||
if (this.unsigned) { | ||
@@ -365,3 +371,3 @@ return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0); | ||
*/ | ||
Long.prototype.toString = function toString(radix) { | ||
LongPrototype.toString = function toString(radix) { | ||
radix = radix || 10; | ||
@@ -374,11 +380,11 @@ if (radix < 2 || 36 < radix) | ||
if (this.isNegative()) { // Unsigned Longs are never negative | ||
if (this.equals(Long.MIN_VALUE)) { | ||
if (this.eq(Long.MIN_VALUE)) { | ||
// We need to change the Long value before it can be negated, so we remove | ||
// the bottom-most digit in this base and then recurse to do the rest. | ||
var radixLong = Long.fromNumber(radix); | ||
var div = this.divide(radixLong); | ||
rem = div.multiply(radixLong).subtract(this); | ||
var div = this.div(radixLong); | ||
rem = div.mul(radixLong).sub(this); | ||
return div.toString(radix) + rem.toInt().toString(radix); | ||
} else | ||
return '-' + this.negate().toString(radix); | ||
return '-' + this.neg().toString(radix); | ||
} | ||
@@ -392,4 +398,4 @@ | ||
while (true) { | ||
var remDiv = rem.divide(radixToPower), | ||
intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0, | ||
var remDiv = rem.div(radixToPower), | ||
intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0, | ||
digits = intval.toString(radix); | ||
@@ -412,3 +418,3 @@ rem = remDiv; | ||
*/ | ||
Long.prototype.getHighBits = function getHighBits() { | ||
LongPrototype.getHighBits = function getHighBits() { | ||
return this.high; | ||
@@ -422,3 +428,3 @@ }; | ||
*/ | ||
Long.prototype.getHighBitsUnsigned = function getHighBitsUnsigned() { | ||
LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() { | ||
return this.high >>> 0; | ||
@@ -432,3 +438,3 @@ }; | ||
*/ | ||
Long.prototype.getLowBits = function getLowBits() { | ||
LongPrototype.getLowBits = function getLowBits() { | ||
return this.low; | ||
@@ -442,3 +448,3 @@ }; | ||
*/ | ||
Long.prototype.getLowBitsUnsigned = function getLowBitsUnsigned() { | ||
LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() { | ||
return this.low >>> 0; | ||
@@ -452,5 +458,5 @@ }; | ||
*/ | ||
Long.prototype.getNumBitsAbs = function getNumBitsAbs() { | ||
LongPrototype.getNumBitsAbs = function getNumBitsAbs() { | ||
if (this.isNegative()) // Unsigned Longs are never negative | ||
return this.equals(Long.MIN_VALUE) ? 64 : this.negate().getNumBitsAbs(); | ||
return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); | ||
var val = this.high != 0 ? this.high : this.low; | ||
@@ -468,3 +474,3 @@ for (var bit = 31; bit > 0; bit--) | ||
*/ | ||
Long.prototype.isZero = function isZero() { | ||
LongPrototype.isZero = function isZero() { | ||
return this.high === 0 && this.low === 0; | ||
@@ -478,3 +484,3 @@ }; | ||
*/ | ||
Long.prototype.isNegative = function isNegative() { | ||
LongPrototype.isNegative = function isNegative() { | ||
return !this.unsigned && this.high < 0; | ||
@@ -488,3 +494,3 @@ }; | ||
*/ | ||
Long.prototype.isPositive = function isPositive() { | ||
LongPrototype.isPositive = function isPositive() { | ||
return this.unsigned || this.high >= 0; | ||
@@ -498,3 +504,3 @@ }; | ||
*/ | ||
Long.prototype.isOdd = function isOdd() { | ||
LongPrototype.isOdd = function isOdd() { | ||
return (this.low & 1) === 1; | ||
@@ -508,3 +514,3 @@ }; | ||
*/ | ||
Long.prototype.isEven = function isEven() { | ||
LongPrototype.isEven = function isEven() { | ||
return (this.low & 1) === 0; | ||
@@ -519,3 +525,3 @@ }; | ||
*/ | ||
Long.prototype.equals = function equals(other) { | ||
LongPrototype.equals = function equals(other) { | ||
if (!Long.isLong(other)) | ||
@@ -535,3 +541,3 @@ other = Long.fromValue(other); | ||
*/ | ||
Long.eq = Long.prototype.equals; | ||
LongPrototype.eq = LongPrototype.equals; | ||
@@ -544,4 +550,4 @@ /** | ||
*/ | ||
Long.prototype.notEquals = function notEquals(other) { | ||
return !this.equals(/* validates */ other); | ||
LongPrototype.notEquals = function notEquals(other) { | ||
return !this.eq(/* validates */ other); | ||
}; | ||
@@ -556,3 +562,3 @@ | ||
*/ | ||
Long.neq = Long.prototype.notEquals; | ||
LongPrototype.neq = LongPrototype.notEquals; | ||
@@ -565,3 +571,3 @@ /** | ||
*/ | ||
Long.prototype.lessThan = function lessThan(other) { | ||
LongPrototype.lessThan = function lessThan(other) { | ||
return this.compare(/* validates */ other) < 0; | ||
@@ -577,3 +583,3 @@ }; | ||
*/ | ||
Long.prototype.lt = Long.prototype.lessThan; | ||
LongPrototype.lt = LongPrototype.lessThan; | ||
@@ -586,3 +592,3 @@ /** | ||
*/ | ||
Long.prototype.lessThanOrEqual = function lessThanOrEqual(other) { | ||
LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) { | ||
return this.compare(/* validates */ other) <= 0; | ||
@@ -598,3 +604,3 @@ }; | ||
*/ | ||
Long.prototype.lte = Long.prototype.lessThanOrEqual; | ||
LongPrototype.lte = LongPrototype.lessThanOrEqual; | ||
@@ -607,3 +613,3 @@ /** | ||
*/ | ||
Long.prototype.greaterThan = function greaterThan(other) { | ||
LongPrototype.greaterThan = function greaterThan(other) { | ||
return this.compare(/* validates */ other) > 0; | ||
@@ -619,3 +625,3 @@ }; | ||
*/ | ||
Long.prototype.gt = Long.prototype.greaterThan; | ||
LongPrototype.gt = LongPrototype.greaterThan; | ||
@@ -628,3 +634,3 @@ /** | ||
*/ | ||
Long.prototype.greaterThanOrEqual = function greaterThanOrEqual(other) { | ||
LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) { | ||
return this.compare(/* validates */ other) >= 0; | ||
@@ -640,3 +646,3 @@ }; | ||
*/ | ||
Long.prototype.gte = Long.prototype.greaterThanOrEqual; | ||
LongPrototype.gte = LongPrototype.greaterThanOrEqual; | ||
@@ -650,6 +656,6 @@ /** | ||
*/ | ||
Long.prototype.compare = function compare(other) { | ||
LongPrototype.compare = function compare(other) { | ||
if (!Long.isLong(other)) | ||
other = Long.fromValue(other); | ||
if (this.equals(other)) | ||
if (this.eq(other)) | ||
return 0; | ||
@@ -664,3 +670,3 @@ var thisNeg = this.isNegative(), | ||
if (!this.unsigned) | ||
return this.subtract(other).isNegative() ? -1 : 1; | ||
return this.sub(other).isNegative() ? -1 : 1; | ||
// Both are positive if at least one is unsigned | ||
@@ -671,2 +677,12 @@ return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1; | ||
/** | ||
* Compares this Long's value with the specified's. This is an alias of {@link Long#compare}. | ||
* @function | ||
* @param {!Long|number|string} other Other value | ||
* @returns {number} 0 if they are the same, 1 if the this is greater and -1 | ||
* if the given one is greater | ||
* @expose | ||
*/ | ||
LongPrototype.comp = LongPrototype.compare; | ||
/** | ||
* Negates this Long's value. | ||
@@ -676,4 +692,4 @@ * @returns {!Long} Negated Long | ||
*/ | ||
Long.prototype.negate = function negate() { | ||
if (!this.unsigned && this.equals(Long.MIN_VALUE)) | ||
LongPrototype.negate = function negate() { | ||
if (!this.unsigned && this.eq(Long.MIN_VALUE)) | ||
return Long.MIN_VALUE; | ||
@@ -689,3 +705,3 @@ return this.not().add(Long.ONE); | ||
*/ | ||
Long.prototype.neg = Long.prototype.negate; | ||
LongPrototype.neg = LongPrototype.negate; | ||
@@ -698,3 +714,3 @@ /** | ||
*/ | ||
Long.prototype.add = function add(addend) { | ||
LongPrototype.add = function add(addend) { | ||
if (!Long.isLong(addend)) | ||
@@ -727,3 +743,3 @@ addend = Long.fromValue(addend); | ||
c48 &= 0xFFFF; | ||
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); | ||
return new Long((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); | ||
}; | ||
@@ -737,6 +753,6 @@ | ||
*/ | ||
Long.prototype.subtract = function subtract(subtrahend) { | ||
LongPrototype.subtract = function subtract(subtrahend) { | ||
if (!Long.isLong(subtrahend)) | ||
subtrahend = Long.fromValue(subtrahend); | ||
return this.add(subtrahend.negate()); | ||
return this.add(subtrahend.neg()); | ||
}; | ||
@@ -751,3 +767,3 @@ | ||
*/ | ||
Long.prototype.sub = Long.prototype.subtract; | ||
LongPrototype.sub = LongPrototype.subtract; | ||
@@ -760,3 +776,3 @@ /** | ||
*/ | ||
Long.prototype.multiply = function multiply(multiplier) { | ||
LongPrototype.multiply = function multiply(multiplier) { | ||
if (this.isZero()) | ||
@@ -768,5 +784,5 @@ return Long.ZERO; | ||
return Long.ZERO; | ||
if (this.equals(Long.MIN_VALUE)) | ||
if (this.eq(Long.MIN_VALUE)) | ||
return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; | ||
if (multiplier.equals(Long.MIN_VALUE)) | ||
if (multiplier.eq(Long.MIN_VALUE)) | ||
return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; | ||
@@ -776,10 +792,10 @@ | ||
if (multiplier.isNegative()) | ||
return this.negate().multiply(multiplier.negate()); | ||
return this.neg().mul(multiplier.neg()); | ||
else | ||
return this.negate().multiply(multiplier).negate(); | ||
return this.neg().mul(multiplier).neg(); | ||
} else if (multiplier.isNegative()) | ||
return this.multiply(multiplier.negate()).negate(); | ||
return this.mul(multiplier.neg()).neg(); | ||
// If both longs are small, use float multiplication | ||
if (this.lessThan(TWO_PWR_24) && multiplier.lessThan(TWO_PWR_24)) | ||
if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24)) | ||
return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); | ||
@@ -821,3 +837,3 @@ | ||
c48 &= 0xFFFF; | ||
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); | ||
return new Long((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); | ||
}; | ||
@@ -832,3 +848,3 @@ | ||
*/ | ||
Long.prototype.mul = Long.prototype.multiply; | ||
LongPrototype.mul = LongPrototype.multiply; | ||
@@ -841,35 +857,35 @@ /** | ||
*/ | ||
Long.prototype.divide = function divide(divisor) { | ||
LongPrototype.divide = function divide(divisor) { | ||
if (!Long.isLong(divisor)) | ||
divisor = Long.fromValue(divisor); | ||
if (divisor.isZero()) | ||
throw(new Error('division by zero')); | ||
throw Error('division by zero'); | ||
if (this.isZero()) | ||
return this.unsigned ? Long.UZERO : Long.ZERO; | ||
var approx, rem, res; | ||
if (this.equals(Long.MIN_VALUE)) { | ||
if (divisor.equals(Long.ONE) || divisor.equals(Long.NEG_ONE)) | ||
if (this.eq(Long.MIN_VALUE)) { | ||
if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) | ||
return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE | ||
else if (divisor.equals(Long.MIN_VALUE)) | ||
else if (divisor.eq(Long.MIN_VALUE)) | ||
return Long.ONE; | ||
else { | ||
// At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. | ||
var halfThis = this.shiftRight(1); | ||
approx = halfThis.divide(divisor).shiftLeft(1); | ||
if (approx.equals(Long.ZERO)) { | ||
var halfThis = this.shr(1); | ||
approx = halfThis.div(divisor).shl(1); | ||
if (approx.eq(Long.ZERO)) { | ||
return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; | ||
} else { | ||
rem = this.subtract(divisor.multiply(approx)); | ||
res = approx.add(rem.divide(divisor)); | ||
rem = this.sub(divisor.mul(approx)); | ||
res = approx.add(rem.div(divisor)); | ||
return res; | ||
} | ||
} | ||
} else if (divisor.equals(Long.MIN_VALUE)) | ||
} else if (divisor.eq(Long.MIN_VALUE)) | ||
return this.unsigned ? Long.UZERO : Long.ZERO; | ||
if (this.isNegative()) { | ||
if (divisor.isNegative()) | ||
return this.negate().divide(divisor.negate()); | ||
return this.negate().divide(divisor).negate(); | ||
return this.neg().div(divisor.neg()); | ||
return this.neg().div(divisor).neg(); | ||
} else if (divisor.isNegative()) | ||
return this.divide(divisor.negate()).negate(); | ||
return this.div(divisor.neg()).neg(); | ||
@@ -883,3 +899,3 @@ // Repeat the following until the remainder is less than other: find a | ||
rem = this; | ||
while (rem.greaterThanOrEqual(divisor)) { | ||
while (rem.gte(divisor)) { | ||
// Approximate the result of division. This may be a little greater or | ||
@@ -897,7 +913,7 @@ // smaller than the actual value. | ||
approxRes = Long.fromNumber(approx), | ||
approxRem = approxRes.multiply(divisor); | ||
while (approxRem.isNegative() || approxRem.greaterThan(rem)) { | ||
approxRem = approxRes.mul(divisor); | ||
while (approxRem.isNegative() || approxRem.gt(rem)) { | ||
approx -= delta; | ||
approxRes = Long.fromNumber(approx, this.unsigned); | ||
approxRem = approxRes.multiply(divisor); | ||
approxRem = approxRes.mul(divisor); | ||
} | ||
@@ -911,3 +927,3 @@ | ||
res = res.add(approxRes); | ||
rem = rem.subtract(approxRem); | ||
rem = rem.sub(approxRem); | ||
} | ||
@@ -924,3 +940,3 @@ return res; | ||
*/ | ||
Long.prototype.div = Long.prototype.divide; | ||
LongPrototype.div = LongPrototype.divide; | ||
@@ -933,6 +949,6 @@ /** | ||
*/ | ||
Long.prototype.modulo = function modulo(divisor) { | ||
LongPrototype.modulo = function modulo(divisor) { | ||
if (!Long.isLong(divisor)) | ||
divisor = Long.fromValue(divisor); | ||
return this.subtract(this.divide(divisor).multiply(divisor)); | ||
return this.sub(this.div(divisor).mul(divisor)); | ||
}; | ||
@@ -947,3 +963,3 @@ | ||
*/ | ||
Long.prototype.mod = Long.prototype.modulo; | ||
LongPrototype.mod = LongPrototype.modulo; | ||
@@ -955,4 +971,4 @@ /** | ||
*/ | ||
Long.prototype.not = function not() { | ||
return Long.fromBits(~this.low, ~this.high, this.unsigned); | ||
LongPrototype.not = function not() { | ||
return new Long(~this.low, ~this.high, this.unsigned); | ||
}; | ||
@@ -966,6 +982,6 @@ | ||
*/ | ||
Long.prototype.and = function and(other) { | ||
LongPrototype.and = function and(other) { | ||
if (!Long.isLong(other)) | ||
other = Long.fromValue(other); | ||
return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); | ||
return new Long(this.low & other.low, this.high & other.high, this.unsigned); | ||
}; | ||
@@ -979,6 +995,6 @@ | ||
*/ | ||
Long.prototype.or = function or(other) { | ||
LongPrototype.or = function or(other) { | ||
if (!Long.isLong(other)) | ||
other = Long.fromValue(other); | ||
return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); | ||
return new Long(this.low | other.low, this.high | other.high, this.unsigned); | ||
}; | ||
@@ -992,6 +1008,6 @@ | ||
*/ | ||
Long.prototype.xor = function xor(other) { | ||
LongPrototype.xor = function xor(other) { | ||
if (!Long.isLong(other)) | ||
other = Long.fromValue(other); | ||
return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); | ||
return new Long(this.low ^ other.low, this.high ^ other.high, this.unsigned); | ||
}; | ||
@@ -1005,3 +1021,3 @@ | ||
*/ | ||
Long.prototype.shiftLeft = function shiftLeft(numBits) { | ||
LongPrototype.shiftLeft = function shiftLeft(numBits) { | ||
if (Long.isLong(numBits)) | ||
@@ -1012,5 +1028,5 @@ numBits = numBits.toInt(); | ||
else if (numBits < 32) | ||
return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); | ||
return new Long(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); | ||
else | ||
return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); | ||
return new Long(0, this.low << (numBits - 32), this.unsigned); | ||
}; | ||
@@ -1025,3 +1041,3 @@ | ||
*/ | ||
Long.prototype.shl = Long.prototype.shiftLeft; | ||
LongPrototype.shl = LongPrototype.shiftLeft; | ||
@@ -1034,3 +1050,3 @@ /** | ||
*/ | ||
Long.prototype.shiftRight = function shiftRight(numBits) { | ||
LongPrototype.shiftRight = function shiftRight(numBits) { | ||
if (Long.isLong(numBits)) | ||
@@ -1041,5 +1057,5 @@ numBits = numBits.toInt(); | ||
else if (numBits < 32) | ||
return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); | ||
return new Long((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); | ||
else | ||
return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); | ||
return new Long(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); | ||
}; | ||
@@ -1054,3 +1070,3 @@ | ||
*/ | ||
Long.prototype.shr = Long.prototype.shiftRight; | ||
LongPrototype.shr = LongPrototype.shiftRight; | ||
@@ -1063,3 +1079,3 @@ /** | ||
*/ | ||
Long.prototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) { | ||
LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) { | ||
if (Long.isLong(numBits)) | ||
@@ -1074,7 +1090,7 @@ numBits = numBits.toInt(); | ||
var low = this.low; | ||
return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned); | ||
return new Long((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned); | ||
} else if (numBits === 32) | ||
return Long.fromBits(high, 0, this.unsigned); | ||
return new Long(high, 0, this.unsigned); | ||
else | ||
return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); | ||
return new Long(high >>> (numBits - 32), 0, this.unsigned); | ||
} | ||
@@ -1090,3 +1106,3 @@ }; | ||
*/ | ||
Long.prototype.shru = Long.prototype.shiftRightUnsigned; | ||
LongPrototype.shru = LongPrototype.shiftRightUnsigned; | ||
@@ -1098,3 +1114,3 @@ /** | ||
*/ | ||
Long.prototype.toSigned = function toSigned() { | ||
LongPrototype.toSigned = function toSigned() { | ||
if (!this.unsigned) | ||
@@ -1110,3 +1126,3 @@ return this; | ||
*/ | ||
Long.prototype.toUnsigned = function toUnsigned() { | ||
LongPrototype.toUnsigned = function toUnsigned() { | ||
if (this.unsigned) | ||
@@ -1113,0 +1129,0 @@ return this; |
@@ -19,5 +19,5 @@ /* | ||
/** | ||
* @license Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io> | ||
* @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io> | ||
* Released under the Apache License, Version 2.0 | ||
* see: https://github.com/dcodeIO/Long.js for details | ||
* see: https://github.com/dcodeIO/long.js for details | ||
*/ | ||
@@ -24,0 +24,0 @@ (function(global, factory) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3216
0
189464