Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

long

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

long - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

56

externs/Long.js

@@ -32,17 +32,20 @@ /*

* @param {number} high
* @param {boolean=} unsigned
* @constructor
*/
var Long = function(low, high) {};
var Long = function(low, high, unsigned) {};
/**
* @param {number} value
* @param {boolean=} unsigned
* @return {!Long}
*/
Long.fromInt = function(value) {};
Long.fromInt = function(value, unsigned) {};
/**
* @param {number} value
* @param {boolean=} unsigned
* @return {!Long}
*/
Long.fromNumber = function(value) {};
Long.fromNumber = function(value, unsigned) {};

@@ -52,12 +55,14 @@ /**

* @param {number} highBits
* @param {boolean=} unsigned
* @return {!Long}
*/
Long.fromBits = function(lowBits, highBits) {};
Long.fromBits = function(lowBits, highBits, unsigned) {};
/**
* @param {string} str
* @param {number=} opt_radix
* @param {(boolean|number)=} unsigned
* @param {number=} radix
* @return {!Long}
*/
Long.fromString = function(str, opt_radix) {};
Long.fromString = function(str, unsigned, radix) {};

@@ -82,2 +87,22 @@ /**

*/
Long.MAX_SIGNED_VALUE;
/**
* @type {!Long}
*/
Long.MIN_SIGNED_VALUE;
/**
* @type {!Long}
*/
Long.MAX_UNSIGNED_VALUE;
/**
* @type {!Long}
*/
Long.MIN_UNSIGNED_VALUE;
/**
* @type {!Long}
*/
Long.MAX_VALUE;

@@ -91,2 +116,17 @@

/**
* @type {number}
*/
Long.prototype.low;
/**
* @type {number}
*/
Long.prototype.high;
/**
* @type {boolean}
*/
Long.prototype.unsigned;
/**
* @return {number}

@@ -102,6 +142,6 @@ */

/**
* @param {number=} opt_radix
* @param {number=} radix
* @return {string}
*/
Long.prototype.toString = function(opt_radix) {};
Long.prototype.toString = function(radix) {};

@@ -108,0 +148,0 @@ /**

434

Long.js

@@ -56,33 +56,47 @@ /*

* @exports Long
* @param {number} low The low (signed) 32 bits of the long.
* @param {number} high The high (signed) 32 bits of the long.
* @param {number} low The low (signed) 32 bits of the long.
* @param {number} high The high (signed) 32 bits of the long.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @constructor
*/
var Long = function(low, high) {
var Long = function(low, high, unsigned) {
/**
* The low 32 bits as a signed value.
* @type {number}
* @private
* @expose
*/
this.low_ = low | 0; // force into 32 signed bits.
this.low = low | 0;
/**
* The high 32 bits as a signed value.
* @type {number}
* @private
* @expose
*/
this.high_ = high | 0; // force into 32 signed bits.
this.high = high | 0;
/**
* Whether unsigned or not.
* @type {boolean}
* @expose
*/
this.unsigned = !!unsigned;
};
// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from* methods on which they depend.
// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the
// from* methods on which they depend.
// NOTE: The following cache variables are used internally only and are therefore not exposed as properties of the
// Long class.
/**
* A cache of the Long representations of small integer values.
* @type {!Object}
* @private
*/
Long.IntCache_ = {};
var INT_CACHE = {};
/**
* A cache of the Long representations of small unsigned integer values.
* @type {!Object}
*/
var UINT_CACHE = {};

@@ -92,21 +106,32 @@ /**

* @param {number} value The 32-bit integer in question.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* @expose
*/
Long.fromInt = function(value) {
if (-128 <= value && value < 128) {
var cachedObj = Long.IntCache_[value];
if (cachedObj) {
return cachedObj;
Long.fromInt = function(value, unsigned) {
if (!unsigned) {
value = value | 0;
if (-128 <= value && value < 128) {
var cachedObj = INT_CACHE[value];
if (cachedObj) return cachedObj;
}
var obj = new Long(value, value < 0 ? -1 : 0, false);
if (-128 <= value && value < 128) {
INT_CACHE[value] = obj;
}
return obj;
} else {
value = value >>> 0;
if (0 <= value && value < 256) {
var cachedObj = UINT_CACHE[value];
if (cachedObj) return cachedObj;
}
var obj = new Long(value, (value | 0) < 0 ? -1 : 0, true);
if (0 <= value && value < 256) {
UINT_CACHE[value] = obj;
}
return obj;
}
var obj = new Long(value | 0, value < 0 ? -1 : 0);
if (-128 <= value && value < 128) {
Long.IntCache_[value] = obj;
}
return obj;
};
/**

@@ -116,22 +141,25 @@ * Returns a Long representing the given value, provided that it is a finite

* @param {number} value The number in question.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* @expose
*/
Long.fromNumber = function(value) {
Long.fromNumber = function(value, unsigned) {
unsigned = !!unsigned;
if (isNaN(value) || !isFinite(value)) {
return Long.ZERO;
} else if (value <= -Long.TWO_PWR_63_DBL_) {
return Long.MIN_VALUE;
} else if (value + 1 >= Long.TWO_PWR_63_DBL_) {
return Long.MAX_VALUE;
} else if (!unsigned && value <= -TWO_PWR_63_DBL) {
return Long.MIN_SIGNED_VALUE;
} else if (unsigned && value <= 0) {
return Long.MIN_UNSIGNED_VALUE;
} else if (!unsigned && value + 1 >= TWO_PWR_63_DBL) {
return Long.MAX_SIGNED_VALUE;
} else if (unsigned && value >= TWO_PWR_64_DBL) {
return Long.MAX_UNSIGNED_VALUE;
} else if (value < 0) {
return Long.fromNumber(-value).negate();
return Long.fromNumber(-value, false).negate();
} else {
return new Long(
(value % Long.TWO_PWR_32_DBL_) | 0,
(value / Long.TWO_PWR_32_DBL_) | 0);
return new Long((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
}
};
/**

@@ -142,10 +170,10 @@ * Returns a Long representing the 64-bit integer that comes by concatenating

* @param {number} highBits The high 32-bits.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* @expose
*/
Long.fromBits = function(lowBits, highBits) {
return new Long(lowBits, highBits);
Long.fromBits = function(lowBits, highBits, unsigned) {
return new Long(lowBits, highBits, unsigned);
};
/**

@@ -155,20 +183,24 @@ * Returns a Long representation of the given string, written using the given

* @param {string} str The textual representation of the Long.
* @param {number=} opt_radix The radix in which the text is written.
* @param {(boolean|number)=} unsigned Whether unsigned or not. Defaults to false (signed).
* @param {number=} radix The radix in which the text is written.
* @return {!Long} The corresponding Long value.
* @expose
*/
Long.fromString = function(str, opt_radix) {
Long.fromString = function(str, unsigned, radix) {
if (str.length == 0) {
throw Error('number format error: empty string');
throw(new Error('number format error: empty string'));
}
var radix = opt_radix || 10;
if (typeof unsigned == 'number') { // For goog.math.Long compatibility
radix = unsigned;
unsigned = false;
}
radix = radix || 10;
if (radix < 2 || 36 < radix) {
throw Error('radix out of range: ' + radix);
throw(new Error('radix out of range: ' + radix));
}
if (str.charAt(0) == '-') {
return Long.fromString(str.substring(1), radix).negate();
return Long.fromString(str.substring(1), unsigned, radix).negate();
} else if (str.indexOf('-') >= 0) {
throw Error('number format error: interior "-" character: ' + str);
throw(new Error('number format error: interior "-" character: ' + str));
}

@@ -195,62 +227,47 @@

// NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
// no runtime penalty for these.
// NOTE: The following constant values are used internally only and are therefore not exposed as properties of the
// Long class.
// NOTE: the compiler should inline these constant values below and then remove
// these variables, so there should be no runtime penalty for these.
/**
* Number used repeated below in calculations. This must appear before the
* first call to any from* function below.
* @type {number}
* @private
*/
Long.TWO_PWR_16_DBL_ = 1 << 16;
var TWO_PWR_16_DBL = 1 << 16;
/**
* @type {number}
* @private
*/
Long.TWO_PWR_24_DBL_ = 1 << 24;
var TWO_PWR_24_DBL = 1 << 24;
/**
* @type {number}
* @private
*/
Long.TWO_PWR_32_DBL_ =
Long.TWO_PWR_16_DBL_ * Long.TWO_PWR_16_DBL_;
var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
/**
* @type {number}
* @private
*/
Long.TWO_PWR_31_DBL_ =
Long.TWO_PWR_32_DBL_ / 2;
var TWO_PWR_31_DBL = TWO_PWR_32_DBL / 2;
/**
* @type {number}
* @private
*/
Long.TWO_PWR_48_DBL_ =
Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_16_DBL_;
var TWO_PWR_48_DBL = TWO_PWR_32_DBL * TWO_PWR_16_DBL;
/**
* @type {number}
* @private
*/
Long.TWO_PWR_64_DBL_ =
Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_32_DBL_;
var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
/**
* @type {number}
* @private
*/
Long.TWO_PWR_63_DBL_ =
Long.TWO_PWR_64_DBL_ / 2;
var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
/**
* @type {!Long}
*/
var TWO_PWR_24 = Long.fromInt(1 << 24);

@@ -263,3 +280,2 @@ /**

/**

@@ -271,3 +287,2 @@ * @type {!Long}

/**

@@ -279,2 +294,7 @@ * @type {!Long}

/**
* @type {!Long}
* @expose
*/
Long.MAX_SIGNED_VALUE = Long.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);

@@ -285,5 +305,10 @@ /**

*/
Long.MAX_VALUE =
Long.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0);
Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);
/**
* Alias of {@link Long.MAX_SIGNED_VALUE} for goog.math.Long compatibility.
* @type {!Long}
* @expose
*/
Long.MAX_VALUE = Long.MAX_SIGNED_VALUE;

@@ -294,12 +319,17 @@ /**

*/
Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0);
Long.MIN_SIGNED_VALUE = Long.fromBits(0, 0x80000000 | 0, false);
/**
* @type {!Long}
* @expose
*/
Long.MIN_UNSIGNED_VALUE = Long.fromBits(0, 0, true);
/**
* Alias of {@link Long.MIN_SIGNED_VALUE} for goog.math.Long compatibility.
* @type {!Long}
* @private
* @expose
*/
Long.TWO_PWR_24_ = Long.fromInt(1 << 24);
Long.MIN_VALUE = Long.MIN_SIGNED_VALUE;
/**

@@ -310,6 +340,5 @@ * @return {number} The value, assuming it is a 32-bit integer.

Long.prototype.toInt = function() {
return this.low_;
return this.unsigned ? this.low >>> 0 : this.low;
};
/**

@@ -320,9 +349,10 @@ * @return {number} The closest floating-point representation to this value.

Long.prototype.toNumber = function() {
return this.high_ * Long.TWO_PWR_32_DBL_ +
this.getLowBitsUnsigned();
if (this.unsigned) {
return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0);
}
return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
};
/**
* @param {number=} opt_radix The radix in which the text should be written.
* @param {number=} radix The radix in which the text should be written.
* @return {string} The textual representation of this value.

@@ -332,14 +362,12 @@ * @override

*/
Long.prototype.toString = function(opt_radix) {
var radix = opt_radix || 10;
Long.prototype.toString = function(radix) {
radix = radix || 10;
if (radix < 2 || 36 < radix) {
throw Error('radix out of range: ' + radix);
throw(new Error('radix out of range: ' + radix));
}
if (this.isZero()) {
return '0';
}
if (this.isNegative()) {
if (this.equals(Long.MIN_VALUE)) {
if (this.isNegative()) { // Unsigned Longs are never negative
if (this.equals(Long.MIN_SIGNED_VALUE)) {
// We need to change the Long value before it can be negated, so we remove

@@ -359,3 +387,2 @@ // the bottom-most digit in this base and then recurse to do the rest.

var radixToPower = Long.fromNumber(Math.pow(radix, 6));
var rem = this;

@@ -367,3 +394,2 @@ var result = '';

var digits = intval.toString(radix);
rem = remDiv;

@@ -381,31 +407,34 @@ if (rem.isZero()) {

/**
* @return {number} The high 32-bits as a signed value.
* @return {number} The high 32 bits as a signed value.
* @expose
*/
Long.prototype.getHighBits = function() {
return this.high_;
return this.high;
};
/**
* @return {number} The high 32 bits as an unsigned value.
* @expose
*/
Long.prototype.getHighBitsUnsigned = function() {
return this.high >>> 0;
};
/**
* @return {number} The low 32-bits as a signed value.
* @return {number} The low 32 bits as a signed value.
* @expose
*/
Long.prototype.getLowBits = function() {
return this.low_;
return this.low;
};
/**
* @return {number} The low 32-bits as an unsigned value.
* @return {number} The low 32 bits as an unsigned value.
* @expose
*/
Long.prototype.getLowBitsUnsigned = function() {
return (this.low_ >= 0) ?
this.low_ : Long.TWO_PWR_32_DBL_ + this.low_;
return this.low >>> 0;
};
/**

@@ -417,4 +446,4 @@ * @return {number} Returns the number of bits needed to represent the absolute

Long.prototype.getNumBitsAbs = function() {
if (this.isNegative()) {
if (this.equals(Long.MIN_VALUE)) {
if (this.isNegative()) { // Unsigned Longs are never negative
if (this.equals(Long.MIN_SIGNED_VALUE)) {
return 64;

@@ -425,3 +454,3 @@ } else {

} else {
var val = this.high_ != 0 ? this.high_ : this.low_;
var val = this.high != 0 ? this.high : this.low;
for (var bit = 31; bit > 0; bit--) {

@@ -432,7 +461,6 @@ if ((val & (1 << bit)) != 0) {

}
return this.high_ != 0 ? bit + 33 : bit + 1;
return this.high != 0 ? bit + 33 : bit + 1;
}
};
/**

@@ -443,6 +471,5 @@ * @return {boolean} Whether this value is zero.

Long.prototype.isZero = function() {
return this.high_ == 0 && this.low_ == 0;
return this.high == 0 && this.low == 0;
};
/**

@@ -453,6 +480,5 @@ * @return {boolean} Whether this value is negative.

Long.prototype.isNegative = function() {
return this.high_ < 0;
return !this.unsigned && this.high < 0;
};
/**

@@ -463,3 +489,3 @@ * @return {boolean} Whether this value is odd.

Long.prototype.isOdd = function() {
return (this.low_ & 1) == 1;
return (this.low & 1) == 1;
};

@@ -471,3 +497,3 @@

Long.prototype.isEven = function() {
return (this.low_ & 1) == 0;
return (this.low & 1) == 0;
};

@@ -481,3 +507,4 @@

Long.prototype.equals = function(other) {
return (this.high_ == other.high_) && (this.low_ == other.low_);
if (this.unsigned != other.unsigned && (this.high >>> 31) != (other.high >>> 31)) return false;
return (this.high == other.high) && (this.low == other.low);
};

@@ -491,6 +518,5 @@

Long.prototype.notEquals = function(other) {
return (this.high_ != other.high_) || (this.low_ != other.low_);
return !this.equals(other);
};
/**

@@ -505,3 +531,2 @@ * @param {Long} other Long to compare against.

/**

@@ -516,3 +541,2 @@ * @param {Long} other Long to compare against.

/**

@@ -527,3 +551,2 @@ * @param {Long} other Long to compare against.

/**

@@ -538,3 +561,2 @@ * @param {Long} other Long to compare against.

/**

@@ -551,21 +573,15 @@ * Compares this Long with the given one.

}
var thisNeg = this.isNegative();
var otherNeg = other.isNegative();
if (thisNeg && !otherNeg) {
return -1;
}
if (!thisNeg && otherNeg) {
return 1;
}
// at this point, the signs are the same, so subtraction will not overflow
if (this.subtract(other).isNegative()) {
return -1;
if (thisNeg && !otherNeg) return -1;
if (!thisNeg && otherNeg) return 1;
if (!this.unsigned) {
// At this point the signs are the same
return this.subtract(other).isNegative() ? -1 : 1;
} else {
return 1;
// Both are positive if at least one is unsigned
return (other.high >>> 0) > (this.high >>> 0) || (other.high == this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
}
};
/**

@@ -576,10 +592,8 @@ * @return {!Long} The negation of this value.

Long.prototype.negate = function() {
if (this.equals(Long.MIN_VALUE)) {
return Long.MIN_VALUE;
} else {
return this.not().add(Long.ONE);
if (!this.unsigned && this.equals(Long.MIN_SIGNED_VALUE)) {
return Long.MIN_SIGNED_VALUE;
}
return this.not().add(Long.ONE);
};
/**

@@ -593,13 +607,13 @@ * Returns the sum of this and the given Long.

// Divide each number into 4 chunks of 16 bits, and then sum the chunks.
var a48 = this.high >>> 16;
var a32 = this.high & 0xFFFF;
var a16 = this.low >>> 16;
var a00 = this.low & 0xFFFF;
var a48 = this.high_ >>> 16;
var a32 = this.high_ & 0xFFFF;
var a16 = this.low_ >>> 16;
var a00 = this.low_ & 0xFFFF;
var b48 = other.high >>> 16;
var b32 = other.high & 0xFFFF;
var b16 = other.low >>> 16;
var b00 = other.low & 0xFFFF;
var b48 = other.high_ >>> 16;
var b32 = other.high_ & 0xFFFF;
var b16 = other.low_ >>> 16;
var b00 = other.low_ & 0xFFFF;
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;

@@ -617,6 +631,5 @@ c00 += a00 + b00;

c48 &= 0xFFFF;
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
};
/**

@@ -632,3 +645,2 @@ * Returns the difference of this and the given Long.

/**

@@ -662,7 +674,6 @@ * Returns the product of this and the given long.

}
// If both longs are small, use float multiplication
if (this.lessThan(Long.TWO_PWR_24_) &&
other.lessThan(Long.TWO_PWR_24_)) {
return Long.fromNumber(this.toNumber() * other.toNumber());
if (this.lessThan(TWO_PWR_24) &&
other.lessThan(TWO_PWR_24)) {
return Long.fromNumber(this.toNumber() * other.toNumber(), this.unsigned);
}

@@ -672,13 +683,13 @@

// We can skip products that would overflow.
var a48 = this.high >>> 16;
var a32 = this.high & 0xFFFF;
var a16 = this.low >>> 16;
var a00 = this.low & 0xFFFF;
var a48 = this.high_ >>> 16;
var a32 = this.high_ & 0xFFFF;
var a16 = this.low_ >>> 16;
var a00 = this.low_ & 0xFFFF;
var b48 = other.high >>> 16;
var b32 = other.high & 0xFFFF;
var b16 = other.low >>> 16;
var b00 = other.low & 0xFFFF;
var b48 = other.high_ >>> 16;
var b32 = other.high_ & 0xFFFF;
var b16 = other.low_ >>> 16;
var b00 = other.low_ & 0xFFFF;
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;

@@ -705,6 +716,5 @@ c00 += a00 * b00;

c48 &= 0xFFFF;
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
};
/**

@@ -718,11 +728,9 @@ * Returns this Long divided by the given one.

if (other.isZero()) {
throw Error('division by zero');
throw(new Error('division by zero'));
} else if (this.isZero()) {
return Long.ZERO;
}
if (this.equals(Long.MIN_VALUE)) {
if (other.equals(Long.ONE) ||
other.equals(Long.NEG_ONE)) {
return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
if (this.equals(Long.MIN_SIGNED_VALUE)) {
if (other.equals(Long.ONE) || other.equals(Long.NEG_ONE)) {
return min; // recall that -MIN_VALUE == MIN_VALUE
} else if (other.equals(Long.MIN_VALUE)) {

@@ -745,3 +753,2 @@ return Long.ONE;

}
if (this.isNegative()) {

@@ -776,7 +783,7 @@ if (other.isNegative()) {

// that if it is too large, the product overflows and is negative.
var approxRes = Long.fromNumber(approx);
var approxRes = Long.fromNumber(approx, this.unsigned);
var approxRem = approxRes.multiply(other);
while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
approx -= delta;
approxRes = Long.fromNumber(approx);
approxRes = Long.fromNumber(approx, this.unsigned);
approxRem = approxRes.multiply(other);

@@ -797,3 +804,2 @@ }

/**

@@ -809,3 +815,2 @@ * Returns this Long modulo the given one.

/**

@@ -816,6 +821,5 @@ * @return {!Long} The bitwise-NOT of this value.

Long.prototype.not = function() {
return Long.fromBits(~this.low_, ~this.high_);
return Long.fromBits(~this.low, ~this.high, this.unsigned);
};
/**

@@ -828,7 +832,5 @@ * Returns the bitwise-AND of this Long and the given one.

Long.prototype.and = function(other) {
return Long.fromBits(this.low_ & other.low_,
this.high_ & other.high_);
return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned);
};
/**

@@ -841,7 +843,5 @@ * Returns the bitwise-OR of this Long and the given one.

Long.prototype.or = function(other) {
return Long.fromBits(this.low_ | other.low_,
this.high_ | other.high_);
return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned);
};
/**

@@ -854,7 +854,5 @@ * Returns the bitwise-XOR of this Long and the given one.

Long.prototype.xor = function(other) {
return Long.fromBits(this.low_ ^ other.low_,
this.high_ ^ other.high_);
return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
};
/**

@@ -871,10 +869,8 @@ * Returns this Long with bits shifted to the left by the given amount.

} else {
var low = this.low_;
var low = this.low;
if (numBits < 32) {
var high = this.high_;
return Long.fromBits(
low << numBits,
(high << numBits) | (low >>> (32 - numBits)));
var high = this.high;
return Long.fromBits(low << numBits, (high << numBits) | (low >>> (32 - numBits)), this.unsigned);
} else {
return Long.fromBits(0, low << (numBits - 32));
return Long.fromBits(0, low << (numBits - 32), this.unsigned);
}

@@ -884,3 +880,2 @@ }

/**

@@ -897,12 +892,8 @@ * Returns this Long with bits shifted to the right by the given amount.

} else {
var high = this.high_;
var high = this.high;
if (numBits < 32) {
var low = this.low_;
return Long.fromBits(
(low >>> numBits) | (high << (32 - numBits)),
high >> numBits);
var low = this.low;
return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >> numBits, this.unsigned);
} else {
return Long.fromBits(
high >> (numBits - 32),
high >= 0 ? 0 : -1);
return Long.fromBits(high >> (numBits - 32), high >= 0 ? 0 : -1, this.unsigned);
}

@@ -912,3 +903,2 @@ }

/**

@@ -927,15 +917,21 @@ * Returns this Long with bits shifted to the right by the given amount, with

} else {
var high = this.high_;
var high = this.high;
if (numBits < 32) {
var low = this.low_;
return Long.fromBits(
(low >>> numBits) | (high << (32 - numBits)),
high >>> numBits);
var low = this.low;
return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned);
} else if (numBits == 32) {
return Long.fromBits(high, 0);
return Long.fromBits(high, 0, this.unsigned);
} else {
return Long.fromBits(high >>> (numBits - 32), 0);
return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned);
}
}
};
/**
* @return {Long} Cloned instance with the same low/high bits and unsigned flag.
* @expose
*/
Long.prototype.clone = function() {
return new Long(this.low, this.high, this.unsigned);
};

@@ -942,0 +938,0 @@ // Enable module loading if available

@@ -11,13 +11,17 @@ /*

*/
(function(p){function b(a,b){this.a=a|0;this.b=b|0}b.e={};b.fromInt=function(a){if(-128<=a&&128>a){var c=b.e[a];if(c)return c}c=new b(a|0,0>a?-1:0);-128<=a&&128>a&&(b.e[a]=c);return c};b.fromNumber=function(a){return isNaN(a)||!isFinite(a)?b.ZERO:a<=-b.g?b.MIN_VALUE:a+1>=b.g?b.MAX_VALUE:0>a?b.fromNumber(-a).negate():new b(a%b.c|0,a/b.c|0)};b.fromBits=function(a,c){return new b(a,c)};b.fromString=function(a,c){if(0==a.length)throw Error("number format error: empty string");var d=c||10;if(2>d||36<d)throw Error("radix out of range: "+
d);if("-"==a.charAt(0))return b.fromString(a.substring(1),d).negate();if(0<=a.indexOf("-"))throw Error('number format error: interior "-" character: '+a);for(var g=b.fromNumber(Math.pow(d,8)),f=b.ZERO,e=0;e<a.length;e+=8){var k=Math.min(8,a.length-e),l=parseInt(a.substring(e,e+k),d);8>k?(k=b.fromNumber(Math.pow(d,k)),f=f.multiply(k).add(b.fromNumber(l))):(f=f.multiply(g),f=f.add(b.fromNumber(l)))}return f};b.d=65536;b.i=16777216;b.c=b.d*b.d;b.j=b.c/2;b.k=b.c*b.d;b.h=b.c*b.c;b.g=b.h/2;b.ZERO=b.fromInt(0);
b.ONE=b.fromInt(1);b.NEG_ONE=b.fromInt(-1);b.MAX_VALUE=b.fromBits(-1,2147483647);b.MIN_VALUE=b.fromBits(0,-2147483648);b.f=b.fromInt(16777216);b.prototype.toInt=function(){return this.a};b.prototype.toNumber=function(){return this.b*b.c+this.getLowBitsUnsigned()};b.prototype.toString=function(a){a=a||10;if(2>a||36<a)throw Error("radix out of range: "+a);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(b.MIN_VALUE)){var c=b.fromNumber(a),d=this.div(c),c=d.multiply(c).subtract(this);
return d.toString(a)+c.toInt().toString(a)}return"-"+this.negate().toString(a)}for(var d=b.fromNumber(Math.pow(a,6)),c=this,g="";;){var f=c.div(d),e=c.subtract(f.multiply(d)).toInt().toString(a),c=f;if(c.isZero())return e+g;for(;6>e.length;)e="0"+e;g=""+e+g}};b.prototype.getHighBits=function(){return this.b};b.prototype.getLowBits=function(){return this.a};b.prototype.getLowBitsUnsigned=function(){return 0<=this.a?this.a:b.c+this.a};b.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(b.MIN_VALUE)?
64:this.negate().getNumBitsAbs();for(var a=0!=this.b?this.b:this.a,c=31;0<c&&0==(a&1<<c);c--);return 0!=this.b?c+33:c+1};b.prototype.isZero=function(){return 0==this.b&&0==this.a};b.prototype.isNegative=function(){return 0>this.b};b.prototype.isOdd=function(){return 1==(this.a&1)};b.prototype.equals=function(a){return this.b==a.b&&this.a==a.a};b.prototype.notEquals=function(a){return this.b!=a.b||this.a!=a.a};b.prototype.lessThan=function(a){return 0>this.compare(a)};b.prototype.lessThanOrEqual=function(a){return 0>=
this.compare(a)};b.prototype.greaterThan=function(a){return 0<this.compare(a)};b.prototype.greaterThanOrEqual=function(a){return 0<=this.compare(a)};b.prototype.compare=function(a){if(this.equals(a))return 0;var b=this.isNegative(),d=a.isNegative();return b&&!d?-1:!b&&d?1:this.subtract(a).isNegative()?-1:1};b.prototype.negate=function(){return this.equals(b.MIN_VALUE)?b.MIN_VALUE:this.not().add(b.ONE)};b.prototype.add=function(a){var c=this.b>>>16,d=this.b&65535,g=this.a>>>16,f=a.b>>>16,e=a.b&65535,
k=a.a>>>16,l;l=0+((this.a&65535)+(a.a&65535));a=0+(l>>>16);a+=g+k;g=0+(a>>>16);g+=d+e;d=0+(g>>>16);d=d+(c+f)&65535;return b.fromBits((a&65535)<<16|l&65535,d<<16|g&65535)};b.prototype.subtract=function(a){return this.add(a.negate())};b.prototype.multiply=function(a){if(this.isZero()||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(b.f)&&a.lessThan(b.f))return b.fromNumber(this.toNumber()*a.toNumber());var c=this.b>>>16,d=this.b&65535,g=this.a>>>16,f=this.a&65535,e=a.b>>>16,k=a.b&65535,l=a.a>>>16;a=a.a&65535;var n,h,m,p;p=0+f*a;m=0+(p>>>16);m+=g*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)+g*l;n+=h>>>16;h&=65535;h+=f*k;n+=h>>>16;h&=65535;n=n+(c*a+d*l+g*k+f*e)&65535;return b.fromBits(m<<
16|p&65535,n<<16|h)};b.prototype.div=function(a){if(a.isZero())throw Error("division by zero");if(this.isZero())return b.ZERO;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;var c=this.shiftRight(1).div(a).shiftLeft(1);if(c.equals(b.ZERO))return a.isNegative()?b.ONE:b.NEG_ONE;var d=this.subtract(a.multiply(c));return c.add(d.div(a))}if(a.equals(b.MIN_VALUE))return b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().div(a.negate()):
this.negate().div(a).negate();if(a.isNegative())return this.div(a.negate()).negate();for(var g=b.ZERO,d=this;d.greaterThanOrEqual(a);){for(var c=Math.max(1,Math.floor(d.toNumber()/a.toNumber())),f=Math.ceil(Math.log(c)/Math.LN2),f=48>=f?1:Math.pow(2,f-48),e=b.fromNumber(c),k=e.multiply(a);k.isNegative()||k.greaterThan(d);)c-=f,e=b.fromNumber(c),k=e.multiply(a);e.isZero()&&(e=b.ONE);g=g.add(e);d=d.subtract(k)}return g};b.prototype.modulo=function(a){return this.subtract(this.div(a).multiply(a))};b.prototype.not=
function(){return b.fromBits(~this.a,~this.b)};b.prototype.and=function(a){return b.fromBits(this.a&a.a,this.b&a.b)};b.prototype.or=function(a){return b.fromBits(this.a|a.a,this.b|a.b)};b.prototype.xor=function(a){return b.fromBits(this.a^a.a,this.b^a.b)};b.prototype.shiftLeft=function(a){a&=63;if(0==a)return this;var c=this.a;return 32>a?b.fromBits(c<<a,this.b<<a|c>>>32-a):b.fromBits(0,c<<a-32)};b.prototype.shiftRight=function(a){a&=63;if(0==a)return this;var c=this.b;return 32>a?b.fromBits(this.a>>>
a|c<<32-a,c>>a):b.fromBits(c>>a-32,0<=c?0:-1)};b.prototype.shiftRightUnsigned=function(a){a&=63;if(0==a)return this;var c=this.b;return 32>a?b.fromBits(this.a>>>a|c<<32-a,c>>>a):32==a?b.fromBits(c,0):b.fromBits(c>>>a-32,0)};"undefined"!=typeof module&&module.exports?module.exports=b:"undefined"!=typeof define&&define.amd?define("Math/Long",[],function(){return b}):(p.dcodeIO||(p.dcodeIO={}),p.dcodeIO.Long=b)})(this);
var q=!1;
(function(r){function b(a,b,d){this.low=a|0;this.high=b|0;this.unsigned=!!d}var s={},t={};b.fromInt=function(a,c){if(c){a>>>=0;if(0<=a&&256>a&&(d=t[a]))return d;d=new b(a,0>(a|0)?-1:0,!0);0<=a&&256>a&&(t[a]=d)}else{a|=0;if(-128<=a&&128>a){var d=s[a];if(d)return d}d=new b(a,0>a?-1:0,q);-128<=a&&128>a&&(s[a]=d)}return d};b.fromNumber=function(a,c){c=!!c;return isNaN(a)||!isFinite(a)?b.ZERO:!c&&a<=-u?b.MIN_SIGNED_VALUE:c&&0>=a?b.MIN_UNSIGNED_VALUE:!c&&a+1>=u?b.MAX_SIGNED_VALUE:c&&a>=v?b.MAX_UNSIGNED_VALUE:0>
a?b.fromNumber(-a,q).negate():new b(a%l|0,a/l|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");"number"==typeof c&&(d=c,c=q);d=d||10;if(2>d||36<d)throw Error("radix out of range: "+d);if("-"==a.charAt(0))return b.fromString(a.substring(1),c,d).negate();if(0<=a.indexOf("-"))throw Error('number format error: interior "-" character: '+a);c=b.fromNumber(Math.pow(d,8));for(var e=b.ZERO,g=0;g<a.length;g+=8){var f=
Math.min(8,a.length-g),k=parseInt(a.substring(g,g+f),d);8>f?(f=b.fromNumber(Math.pow(d,f)),e=e.multiply(f).add(b.fromNumber(k))):(e=e.multiply(c),e=e.add(b.fromNumber(k)))}return e};var l=4294967296,v=l*l,u=v/2,w=b.fromInt(16777216);b.ZERO=b.fromInt(0);b.ONE=b.fromInt(1);b.NEG_ONE=b.fromInt(-1);b.MAX_SIGNED_VALUE=b.fromBits(-1,2147483647,q);b.MAX_UNSIGNED_VALUE=b.fromBits(-1,-1,!0);b.MAX_VALUE=b.MAX_SIGNED_VALUE;b.MIN_SIGNED_VALUE=b.fromBits(0,-2147483648,q);b.MIN_UNSIGNED_VALUE=b.fromBits(0,0,!0);
b.MIN_VALUE=b.MIN_SIGNED_VALUE;b.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)};b.prototype.toString=function(a){a=a||10;if(2>a||36<a)throw Error("radix out of range: "+a);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(b.MIN_SIGNED_VALUE)){var c=b.fromNumber(a),d=this.div(c),c=d.multiply(c).subtract(this);return d.toString(a)+c.toInt().toString(a)}return"-"+
this.negate().toString(a)}for(var d=b.fromNumber(Math.pow(a,6)),c=this,e="";;){var g=c.div(d),f=c.subtract(g.multiply(d)).toInt().toString(a),c=g;if(c.isZero())return f+e;for(;6>f.length;)f="0"+f;e=""+f+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_SIGNED_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.isOdd=function(){return 1==(this.low&1)};b.prototype.equals=function(a){return this.unsigned!=a.unsigned&&this.high>>>31!=a.high>>>31?q:this.high==a.high&&this.low==a.low};b.prototype.notEquals=function(a){return!this.equals(a)};
b.prototype.lessThan=function(a){return 0>this.compare(a)};b.prototype.lessThanOrEqual=function(a){return 0>=this.compare(a)};b.prototype.greaterThan=function(a){return 0<this.compare(a)};b.prototype.greaterThanOrEqual=function(a){return 0<=this.compare(a)};b.prototype.compare=function(a){if(this.equals(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.subtract(a).isNegative()?-1:
1};b.prototype.negate=function(){return!this.unsigned&&this.equals(b.MIN_SIGNED_VALUE)?b.MIN_SIGNED_VALUE:this.not().add(b.ONE)};b.prototype.add=function(a){var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,g=a.high>>>16,f=a.high&65535,k=a.low>>>16,p;p=0+((this.low&65535)+(a.low&65535));a=0+(p>>>16);a+=e+k;e=0+(a>>>16);e+=d+f;d=0+(e>>>16);d=d+(c+g)&65535;return b.fromBits((a&65535)<<16|p&65535,d<<16|e&65535,this.unsigned)};b.prototype.subtract=function(a){return this.add(a.negate())};b.prototype.multiply=
function(a){if(this.isZero()||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(w)&&a.lessThan(w))return b.fromNumber(this.toNumber()*a.toNumber(),this.unsigned);var c=this.high>>>16,d=this.high&65535,e=this.low>>>
16,g=this.low&65535,f=a.high>>>16,k=a.high&65535,p=a.low>>>16;a=a.low&65535;var n,h,m,l;l=0+g*a;m=0+(l>>>16);m+=e*a;h=0+(m>>>16);m=(m&65535)+g*p;h+=m>>>16;m&=65535;h+=d*a;n=0+(h>>>16);h=(h&65535)+e*p;n+=h>>>16;h&=65535;h+=g*k;n+=h>>>16;h&=65535;n=n+(c*a+d*p+e*k+g*f)&65535;return b.fromBits(m<<16|l&65535,n<<16|h,this.unsigned)};b.prototype.div=function(a){if(a.isZero())throw Error("division by zero");if(this.isZero())return b.ZERO;if(this.equals(b.MIN_SIGNED_VALUE)){if(a.equals(b.ONE)||a.equals(b.NEG_ONE))return min;
if(a.equals(b.MIN_VALUE))return b.ONE;var c=this.shiftRight(1).div(a).shiftLeft(1);if(c.equals(b.ZERO))return a.isNegative()?b.ONE:b.NEG_ONE;var d=this.subtract(a.multiply(c));return c.add(d.div(a))}if(a.equals(b.MIN_VALUE))return b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().div(a.negate()):this.negate().div(a).negate();if(a.isNegative())return this.div(a.negate()).negate();for(var e=b.ZERO,d=this;d.greaterThanOrEqual(a);){for(var c=Math.max(1,Math.floor(d.toNumber()/a.toNumber())),
g=Math.ceil(Math.log(c)/Math.LN2),g=48>=g?1:Math.pow(2,g-48),f=b.fromNumber(c,this.unsigned),k=f.multiply(a);k.isNegative()||k.greaterThan(d);)c-=g,f=b.fromNumber(c,this.unsigned),k=f.multiply(a);f.isZero()&&(f=b.ONE);e=e.add(f);d=d.subtract(k)}return e};b.prototype.modulo=function(a){return this.subtract(this.div(a).multiply(a))};b.prototype.not=function(){return b.fromBits(~this.low,~this.high,this.unsigned)};b.prototype.and=function(a){return b.fromBits(this.low&a.low,this.high&a.high,this.unsigned)};
b.prototype.or=function(a){return b.fromBits(this.low|a.low,this.high|a.high,this.unsigned)};b.prototype.xor=function(a){return b.fromBits(this.low^a.low,this.high^a.high,this.unsigned)};b.prototype.shiftLeft=function(a){a&=63;if(0==a)return this;var c=this.low;return 32>a?b.fromBits(c<<a,this.high<<a|c>>>32-a,this.unsigned):b.fromBits(0,c<<a-32,this.unsigned)};b.prototype.shiftRight=function(a){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):
b.fromBits(c>>a-32,0<=c?0:-1,this.unsigned)};b.prototype.shiftRightUnsigned=function(a){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.clone=function(){return new b(this.low,this.high,this.unsigned)};"undefined"!=typeof module&&module.exports?module.exports=b:"undefined"!=typeof define&&define.amd?define("Math/Long",[],function(){return b}):(r.dcodeIO||
(r.dcodeIO={}),r.dcodeIO.Long=b)})(this);
{
"name": "long",
"version": "1.0.1",
"version": "1.1.0",
"author": "Daniel Wirtz <dcode@dcode.io>",
"description": "Long.js: A Long class for representing a 64-bit two's-complement integer value derived from the Closure Library.",
"description": "Long.js: A Long class for representing a 64-bit two's-complement integer value derived from the Closure Library extended with unsigned support.",
"main": "Long.js",

@@ -7,0 +7,0 @@ "repository": {

Long.js
=======
A Long class for representing a 64-bit two's-complement integer value derived from the [Closure Library](https://code.google.com/p/closure-library/)
for stand-alone use.
for stand-alone use and extended with unsigned support.

@@ -9,5 +9,11 @@ Why?

As of the [ECMAScript specification](http://ecma262-5.com/ELS5_HTML.htm#Section_8.5), number types have a maximum value
of 2^53. Beyond that, JavaScript falls back to double internally. However, in some use cases it is required to be able
to perform reliable mathematical and/or bitwise operations on the full 64bits. This is where Long.js comes into play.
of 2^53. Beyond that, JavaScript falls back to double internally. Furthermore, bitwise operations are always performed
on 32bit numbers. However, in some use cases it is required to be able to perform reliable mathematical and/or bitwise
operations on the full 64bits. This is where Long.js comes into play.
Long.js is based on the [goog.math.Long class](http://closure-library.googlecode.com/svn/docs/closure_goog_math_long.js.html)
from the Closure Library. It uses two 32bit integers internally and provides methods for comparison, common tests, math
and bitwise operations on the full 64bits. Additionally, some use cases also require to work with 64bit unsigned values,
so Long.js has been extended with unsigned support while maintaining compatibility to the Closure Library implementation.
Features

@@ -17,3 +23,3 @@ --------

* [RequireJS](http://requirejs.org/)/AMD compatible
* Shim compatible (include the script, then use var ByteBuffer = dcodeIO.ByteBuffer;)
* Shim compatible (include the script, then use var Long = dcodeIO.Long;)
* [node.js](http://nodejs.org) compatible, also available via [npm](https://npmjs.org/package/long)

@@ -26,10 +32,12 @@ * Fully documented using [jsdoc3](https://github.com/jsdoc3/jsdoc)

----
* Construction from high and low bits as 32bit integers: `new Long(low, high)` and `Long.fromBits(low, high)`
* ...from a 32bit integer: `Long.fromInt(value)` including a cache for frequently used small numbers
* ...from a number which may internally be a number or double type: `Long.fromNumber(value)`
* ...from a string: `Long.fromString(value[, radix=10])`
* Construction from high and low bits as 32bit integers: `new Long(low, high[, unsigned=false])` and
`Long.fromBits(low, high[, unsigned=false])`
* ...from a 32bit integer: `Long.fromInt(value[, unsigned=false])` including a cache for frequently used small numbers
* ...from a number which may internally be a number or double type: `Long.fromNumber(value[, unsigned=false])`
* ...from a string: `Long.fromString(value[, unsigned=false, radix=10])`
* Conversion to a 32bit integer: `Long#toInt()`
* ...to a number: `Long#toNumber()`
* ...to a string: `Long#toString([radix=10])`
* Getters for high and low bits as 32bit integers: `Long#getLowBits()`, `Long#getHighBits()`, `Long#getLowBitsUnsigned()`
* Getters for high and low bits as 32bit integers: `Long#getLowBits()`, `Long#getHighBits()` and
`Long#getLowBitsUnsigned()`, `Long#getHighBitsUnsigned()`
* Comparison: `Long#equals(other)`, `Long#notEquals(other)`, `Long#lessThan(other)`, `Long#lessThanOrEqual(other)`,

@@ -60,3 +68,8 @@ `Long#greaterThan(other)`, `Long#greaterThanOrEqual(other)`, `Long#compare(other)`

````javascript
require(["path/to/Long.js"], function(Long) {
require.config({
"paths": {
"Math/Long": "/path/to/Long.js"
}
});
require(["Math/Long"], function(Long) {
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);

@@ -63,0 +76,0 @@ console.log(longVal.toString());

@@ -18,5 +18,5 @@ /*

/**
* A pretty simple Long.js Test Suite.
* Long.js Pretty Simple Test Suite.
*/
var Long = require(__dirname+"/../Long.js");
var Long = require(__dirname+"/../Long.min.js");

@@ -27,4 +27,82 @@ var suite = {

var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
test.equal(longVal.toNumber(), 9223372036854775807);
test.equal(longVal.toString(), "9223372036854775807");
test.done();
},
// Let's assume signed goog.math.Long works as expected because the people at Google are pretty smart.
// So let's focus on my probably not-so-smart unsigned extension:
"unsigned": {
"construct_negint": function(test) {
var longVal = Long.fromInt(-1, true);
test.equal(longVal.low, -1);
test.equal(longVal.high, -1);
test.equal(longVal.unsigned, true);
test.equal(longVal.toNumber(), 18446744073709551615);
test.equal(longVal.toString(), "18446744073709551615");
test.done();
},
"construct_highlow": function(test) {
var longVal = new Long(0xFFFFFFFF, 0xFFFFFFFF, true);
test.equal(longVal.low, -1);
test.equal(longVal.high, -1);
test.equal(longVal.unsigned, true);
test.equal(longVal.toNumber(), 18446744073709551615);
test.equal(longVal.toString(), "18446744073709551615");
test.done();
},
"construct_number": function(test) {
var longVal = Long.fromNumber(0xFFFFFFFFFFFFFFFF, true);
test.equal(longVal.low, -1);
test.equal(longVal.high, -1);
test.equal(longVal.unsigned, true);
test.equal(longVal.toNumber(), 18446744073709551615);
test.equal(longVal.toString(), "18446744073709551615");
test.done();
},
"max_unsigned_sub_max_signed": function(test) {
var longVal = Long.MAX_UNSIGNED_VALUE.subtract(Long.MAX_SIGNED_VALUE).subtract(Long.ONE);
test.equal(longVal.toNumber(), Long.MAX_SIGNED_VALUE);
test.equal(longVal.toString(), Long.MAX_SIGNED_VALUE.toString());
test.done();
},
"max_sub_max": function(test) {
var longVal = Long.MAX_UNSIGNED_VALUE.subtract(Long.MAX_UNSIGNED_VALUE);
test.equal(longVal, 0);
test.equal(longVal.low, 0);
test.equal(longVal.high, 0);
test.equal(longVal.unsigned, true);
test.equal(longVal.toNumber(), 0);
test.equal(longVal.toString(), "0");
test.done();
},
"zero_sub_signed": function(test) {
var longVal = Long.fromInt(0, true).add(Long.fromInt(-1, false));
test.equal(longVal.low, -1);
test.equal(longVal.high, -1);
test.equal(longVal.unsigned, true);
test.equal(longVal.toNumber(), 18446744073709551615);
test.equal(longVal.toString(), "18446744073709551615");
test.done();
},
"max_unsigned_div_max_signed": function(test) {
var longVal = Long.MAX_UNSIGNED_VALUE.div(Long.MAX_SIGNED_VALUE);
test.equal(longVal.toNumber(), 2);
test.equal(longVal.toString(), "2");
test.done();
},
"max_unsigned_div_neg_signed": function(test) {
var longVal = Long.MAX_UNSIGNED_VALUE.div(Long.fromInt(-2));
test.equal(longVal.toNumber(), -Long.MAX_SIGNED_VALUE);
test.done();
}
}

@@ -31,0 +109,0 @@ };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc