mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
CB-11138 Bump cordova-common to 1.2.0
This commit is contained in:
+49
-43
@@ -7,17 +7,25 @@ var bigInt = (function (undefined) {
|
||||
MAX_INT_ARR = smallToArray(MAX_INT),
|
||||
LOG_MAX_INT = Math.log(MAX_INT);
|
||||
|
||||
function Integer(v, radix) {
|
||||
if (typeof v === "undefined") return Integer[0];
|
||||
if (typeof radix !== "undefined") return +radix === 10 ? parseValue(v) : parseBase(v, radix);
|
||||
return parseValue(v);
|
||||
}
|
||||
|
||||
function BigInteger(value, sign) {
|
||||
this.value = value;
|
||||
this.sign = sign;
|
||||
this.isSmall = false;
|
||||
}
|
||||
BigInteger.prototype = Object.create(Integer.prototype);
|
||||
|
||||
function SmallInteger(value) {
|
||||
this.value = value;
|
||||
this.sign = value < 0;
|
||||
this.isSmall = true;
|
||||
}
|
||||
SmallInteger.prototype = Object.create(Integer.prototype);
|
||||
|
||||
function isPrecise(n) {
|
||||
return -MAX_INT < n && n < MAX_INT;
|
||||
@@ -323,7 +331,7 @@ var bigInt = (function (undefined) {
|
||||
sign = this.sign !== n.sign,
|
||||
abs;
|
||||
if (n.isSmall) {
|
||||
if (b === 0) return CACHE[0];
|
||||
if (b === 0) return Integer[0];
|
||||
if (b === 1) return this;
|
||||
if (b === -1) return this.negate();
|
||||
abs = Math.abs(b);
|
||||
@@ -345,20 +353,20 @@ var bigInt = (function (undefined) {
|
||||
}
|
||||
return new BigInteger(multiplyLong(b, smallToArray(a)), sign);
|
||||
}
|
||||
SmallInteger.prototype["_multiplyBySmall"] = function (a) {
|
||||
SmallInteger.prototype._multiplyBySmall = function (a) {
|
||||
if (isPrecise(a.value * this.value)) {
|
||||
return new SmallInteger(a.value * this.value);
|
||||
}
|
||||
return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign);
|
||||
};
|
||||
BigInteger.prototype["_multiplyBySmall"] = function (a) {
|
||||
if (a.value === 0) return CACHE[0];
|
||||
BigInteger.prototype._multiplyBySmall = function (a) {
|
||||
if (a.value === 0) return Integer[0];
|
||||
if (a.value === 1) return this;
|
||||
if (a.value === -1) return this.negate();
|
||||
return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign);
|
||||
};
|
||||
SmallInteger.prototype.multiply = function (v) {
|
||||
return parseValue(v)["_multiplyBySmall"](this);
|
||||
return parseValue(v)._multiplyBySmall(this);
|
||||
};
|
||||
SmallInteger.prototype.times = SmallInteger.prototype.multiply;
|
||||
|
||||
@@ -506,11 +514,11 @@ var bigInt = (function (undefined) {
|
||||
if (n.isSmall) {
|
||||
return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)];
|
||||
}
|
||||
return [CACHE[0], self];
|
||||
return [Integer[0], self];
|
||||
}
|
||||
if (n.isSmall) {
|
||||
if (b === 1) return [self, CACHE[0]];
|
||||
if (b == -1) return [self.negate(), CACHE[0]];
|
||||
if (b === 1) return [self, Integer[0]];
|
||||
if (b == -1) return [self.negate(), Integer[0]];
|
||||
var abs = Math.abs(b);
|
||||
if (abs < BASE) {
|
||||
value = divModSmall(a, abs);
|
||||
@@ -526,8 +534,8 @@ var bigInt = (function (undefined) {
|
||||
b = smallToArray(abs);
|
||||
}
|
||||
var comparison = compareAbs(a, b);
|
||||
if (comparison === -1) return [CACHE[0], self];
|
||||
if (comparison === 0) return [CACHE[self.sign === n.sign ? 1 : -1], CACHE[0]];
|
||||
if (comparison === -1) return [Integer[0], self];
|
||||
if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]];
|
||||
|
||||
// divMod1 is faster on smaller input sizes
|
||||
if (a.length + b.length <= 200)
|
||||
@@ -573,12 +581,12 @@ var bigInt = (function (undefined) {
|
||||
a = this.value,
|
||||
b = n.value,
|
||||
value, x, y;
|
||||
if (b === 0) return CACHE[1];
|
||||
if (a === 0) return CACHE[0];
|
||||
if (a === 1) return CACHE[1];
|
||||
if (a === -1) return n.isEven() ? CACHE[1] : CACHE[-1];
|
||||
if (b === 0) return Integer[1];
|
||||
if (a === 0) return Integer[0];
|
||||
if (a === 1) return Integer[1];
|
||||
if (a === -1) return n.isEven() ? Integer[1] : Integer[-1];
|
||||
if (n.sign) {
|
||||
return CACHE[0];
|
||||
return Integer[0];
|
||||
}
|
||||
if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large.");
|
||||
if (this.isSmall) {
|
||||
@@ -586,7 +594,7 @@ var bigInt = (function (undefined) {
|
||||
return new SmallInteger(truncate(value));
|
||||
}
|
||||
x = this;
|
||||
y = CACHE[1];
|
||||
y = Integer[1];
|
||||
while (true) {
|
||||
if (b & 1 === 1) {
|
||||
y = y.times(x);
|
||||
@@ -604,10 +612,10 @@ var bigInt = (function (undefined) {
|
||||
exp = parseValue(exp);
|
||||
mod = parseValue(mod);
|
||||
if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
|
||||
var r = CACHE[1],
|
||||
var r = Integer[1],
|
||||
base = this.mod(mod);
|
||||
while (exp.isPositive()) {
|
||||
if (base.isZero()) return CACHE[0];
|
||||
if (base.isZero()) return Integer[0];
|
||||
if (exp.isOdd()) r = r.multiply(base).mod(mod);
|
||||
exp = exp.divide(2);
|
||||
base = base.square().mod(mod);
|
||||
@@ -765,7 +773,7 @@ var bigInt = (function (undefined) {
|
||||
if (value === 0) return false;
|
||||
if (value === 1) return true;
|
||||
if (value === 2) return this.isEven();
|
||||
return this.mod(n).equals(CACHE[0]);
|
||||
return this.mod(n).equals(Integer[0]);
|
||||
};
|
||||
SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy;
|
||||
|
||||
@@ -776,7 +784,7 @@ var bigInt = (function (undefined) {
|
||||
if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false;
|
||||
if (n.lesser(25)) return true;
|
||||
// we don't know if it's prime: let the other functions figure it out
|
||||
};
|
||||
}
|
||||
|
||||
BigInteger.prototype.isPrime = function () {
|
||||
var isPrime = isBasicPrime(this);
|
||||
@@ -789,7 +797,7 @@ var bigInt = (function (undefined) {
|
||||
while (b.isEven()) b = b.divide(2);
|
||||
for (i = 0; i < a.length; i++) {
|
||||
x = bigInt(a[i]).modPow(b, n);
|
||||
if (x.equals(CACHE[1]) || x.equals(nPrev)) continue;
|
||||
if (x.equals(Integer[1]) || x.equals(nPrev)) continue;
|
||||
for (t = true, d = b; t && d.lesser(nPrev) ; d = d.multiply(2)) {
|
||||
x = x.square().mod(n);
|
||||
if (x.equals(nPrev)) t = false;
|
||||
@@ -961,7 +969,7 @@ var bigInt = (function (undefined) {
|
||||
if (a.equals(b)) return a;
|
||||
if (a.isZero()) return b;
|
||||
if (b.isZero()) return a;
|
||||
var c = CACHE[1], d, t;
|
||||
var c = Integer[1], d, t;
|
||||
while (a.isEven() && b.isEven()) {
|
||||
d = Math.min(roughLOB(a), roughLOB(b));
|
||||
a = a.divide(d);
|
||||
@@ -1005,7 +1013,7 @@ var bigInt = (function (undefined) {
|
||||
return low.add(typeof result === "number" ? new SmallInteger(result) : new BigInteger(result, false));
|
||||
}
|
||||
var parseBase = function (text, base) {
|
||||
var val = CACHE[0], pow = CACHE[1],
|
||||
var val = Integer[0], pow = Integer[1],
|
||||
length = text.length;
|
||||
if (2 <= base && base <= 36) {
|
||||
if (length <= LOG_MAX_INT / Math.log(base)) {
|
||||
@@ -1117,7 +1125,7 @@ var bigInt = (function (undefined) {
|
||||
var sign = v[0] === "-";
|
||||
if (sign) v = v.slice(1);
|
||||
var split = v.split(/e/i);
|
||||
if (split.length > 2) throw new Error("Invalid integer: " + text.join("e"));
|
||||
if (split.length > 2) throw new Error("Invalid integer: " + split.join("e"));
|
||||
if (split.length === 2) {
|
||||
var exp = split[1];
|
||||
if (exp[0] === "+") exp = exp.slice(1);
|
||||
@@ -1147,8 +1155,11 @@ var bigInt = (function (undefined) {
|
||||
}
|
||||
|
||||
function parseNumberValue(v) {
|
||||
if (isPrecise(v)) return new SmallInteger(v);
|
||||
return parseStringValue(v.toString());
|
||||
if (isPrecise(v)) {
|
||||
if (v !== truncate(v)) throw new Error(v + " is not an integer.");
|
||||
return new SmallInteger(v);
|
||||
}
|
||||
return parseStringValue(v.toString());
|
||||
}
|
||||
|
||||
function parseValue(v) {
|
||||
@@ -1161,26 +1172,21 @@ var bigInt = (function (undefined) {
|
||||
return v;
|
||||
}
|
||||
// Pre-define numbers in range [-999,999]
|
||||
var CACHE = function (v, radix) {
|
||||
if (typeof v === "undefined") return CACHE[0];
|
||||
if (typeof radix !== "undefined") return +radix === 10 ? parseValue(v) : parseBase(v, radix);
|
||||
return parseValue(v);
|
||||
};
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
CACHE[i] = new SmallInteger(i);
|
||||
if (i > 0) CACHE[-i] = new SmallInteger(-i);
|
||||
Integer[i] = new SmallInteger(i);
|
||||
if (i > 0) Integer[-i] = new SmallInteger(-i);
|
||||
}
|
||||
// Backwards compatibility
|
||||
CACHE.one = CACHE[1];
|
||||
CACHE.zero = CACHE[0];
|
||||
CACHE.minusOne = CACHE[-1];
|
||||
CACHE.max = max;
|
||||
CACHE.min = min;
|
||||
CACHE.gcd = gcd;
|
||||
CACHE.lcm = lcm;
|
||||
CACHE.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger; };
|
||||
CACHE.randBetween = randBetween;
|
||||
return CACHE;
|
||||
Integer.one = Integer[1];
|
||||
Integer.zero = Integer[0];
|
||||
Integer.minusOne = Integer[-1];
|
||||
Integer.max = max;
|
||||
Integer.min = min;
|
||||
Integer.gcd = gcd;
|
||||
Integer.lcm = lcm;
|
||||
Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger; };
|
||||
Integer.randBetween = randBetween;
|
||||
return Integer;
|
||||
})();
|
||||
|
||||
// Node.js check
|
||||
|
||||
+33
-1
File diff suppressed because one or more lines are too long
+24
@@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
||||
+18
-18
@@ -2,18 +2,18 @@
|
||||
"_args": [
|
||||
[
|
||||
"big-integer@^1.6.7",
|
||||
"/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser"
|
||||
"d:\\cordova\\cordova-android\\node_modules\\bplist-parser"
|
||||
]
|
||||
],
|
||||
"_from": "big-integer@>=1.6.7 <2.0.0",
|
||||
"_id": "big-integer@1.6.12",
|
||||
"_id": "big-integer@1.6.15",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/big-integer",
|
||||
"_nodeVersion": "0.12.3",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-6-west.internal.npmjs.com",
|
||||
"tmp": "tmp/big-integer-1.6.12.tgz_1455702804335_0.11810904298909009"
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/big-integer-1.6.15.tgz_1460079231162_0.7087579960934818"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "peter.e.c.olson+npm@gmail.com",
|
||||
@@ -32,11 +32,11 @@
|
||||
"_requiredBy": [
|
||||
"/bplist-parser"
|
||||
],
|
||||
"_resolved": "http://registry.npmjs.org/big-integer/-/big-integer-1.6.12.tgz",
|
||||
"_shasum": "39afcddafcd5c4480864efb757337d508938bb26",
|
||||
"_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.15.tgz",
|
||||
"_shasum": "33d27d3b7388dfcc4b86d3130c10740cec01fb9e",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "big-integer@^1.6.7",
|
||||
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser",
|
||||
"_where": "d:\\cordova\\cordova-android\\node_modules\\bplist-parser",
|
||||
"author": {
|
||||
"email": "peter.e.c.olson+npm@gmail.com",
|
||||
"name": "Peter Olson"
|
||||
@@ -59,31 +59,31 @@
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "39afcddafcd5c4480864efb757337d508938bb26",
|
||||
"tarball": "http://registry.npmjs.org/big-integer/-/big-integer-1.6.12.tgz"
|
||||
"shasum": "33d27d3b7388dfcc4b86d3130c10740cec01fb9e",
|
||||
"tarball": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.15.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"gitHead": "56f449108e31542f939e701f1fe562a46e6c1fab",
|
||||
"gitHead": "cda5bcce74c3a4eb34951201d50c1b8776a56eca",
|
||||
"homepage": "https://github.com/peterolson/BigInteger.js#readme",
|
||||
"keywords": [
|
||||
"arbitrary",
|
||||
"arithmetic",
|
||||
"math",
|
||||
"big",
|
||||
"bignum",
|
||||
"bigint",
|
||||
"biginteger",
|
||||
"bignum",
|
||||
"integer",
|
||||
"math",
|
||||
"precision"
|
||||
"arbitrary",
|
||||
"precision",
|
||||
"arithmetic"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"main": "./BigInteger",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "peterolson",
|
||||
"email": "peter.e.c.olson+npm@gmail.com"
|
||||
"email": "peter.e.c.olson+npm@gmail.com",
|
||||
"name": "peterolson"
|
||||
}
|
||||
],
|
||||
"name": "big-integer",
|
||||
@@ -96,5 +96,5 @@
|
||||
"scripts": {
|
||||
"test": "karma start my.conf.js"
|
||||
},
|
||||
"version": "1.6.12"
|
||||
"version": "1.6.15"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user