diff --git a/node_modules/base64-js/README.md b/node_modules/base64-js/README.md index e546d86d..75325117 100644 --- a/node_modules/base64-js/README.md +++ b/node_modules/base64-js/README.md @@ -15,13 +15,15 @@ Sometimes encoding/decoding binary data in the browser is useful, and that is wh With [npm](https://npmjs.org) do: -`npm install base64-js` +`npm install base64-js` and `var base64js = require('base64-js')` + +For use in web browsers do: + +`` ## methods -`var base64 = require('base64-js')` - -`base64` has three exposed functions, `byteLength`, `toByteArray` and `fromByteArray`, which both take a single argument. +`base64js` has three exposed functions, `byteLength`, `toByteArray` and `fromByteArray`, which both take a single argument. * `byteLength` - Takes a base64 string and returns length of byte array * `toByteArray` - Takes a base64 string and returns a byte array diff --git a/node_modules/base64-js/base64js.min.js b/node_modules/base64-js/base64js.min.js index 22ad8077..0c621d35 100644 --- a/node_modules/base64-js/base64js.min.js +++ b/node_modules/base64-js/base64js.min.js @@ -1 +1 @@ -(function(r){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=r()}else if(typeof define==="function"&&define.amd){define([],r)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.base64js=r()}})(function(){var r,e,t;return function r(e,t,n){function o(i,a){if(!t[i]){if(!e[i]){var u=typeof require=="function"&&require;if(!a&&u)return u(i,!0);if(f)return f(i,!0);var d=new Error("Cannot find module '"+i+"'");throw d.code="MODULE_NOT_FOUND",d}var c=t[i]={exports:{}};e[i][0].call(c.exports,function(r){var t=e[i][1][r];return o(t?t:r)},c,c.exports,r,e,t,n)}return t[i].exports}var f=typeof require=="function"&&require;for(var i=0;i0){throw new Error("Invalid string. Length must be a multiple of 4")}return r[e-2]==="="?2:r[e-1]==="="?1:0}function c(r){return r.length*3/4-d(r)}function v(r){var e,t,n,i,a,u;var c=r.length;a=d(r);u=new f(c*3/4-a);n=a>0?c-4:c;var v=0;for(e=0,t=0;e>16&255;u[v++]=i>>8&255;u[v++]=i&255}if(a===2){i=o[r.charCodeAt(e)]<<2|o[r.charCodeAt(e+1)]>>4;u[v++]=i&255}else if(a===1){i=o[r.charCodeAt(e)]<<10|o[r.charCodeAt(e+1)]<<4|o[r.charCodeAt(e+2)]>>2;u[v++]=i>>8&255;u[v++]=i&255}return u}function l(r){return n[r>>18&63]+n[r>>12&63]+n[r>>6&63]+n[r&63]}function h(r,e,t){var n;var o=[];for(var f=e;fd?d:u+a))}if(o===1){e=r[t-1];f+=n[e>>2];f+=n[e<<4&63];f+="=="}else if(o===2){e=(r[t-2]<<8)+r[t-1];f+=n[e>>10];f+=n[e>>4&63];f+=n[e<<2&63];f+="="}i.push(f);return i.join("")}},{}]},{},[])("/")}); +(function(r){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=r()}else if(typeof define==="function"&&define.amd){define([],r)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.base64js=r()}})(function(){var r,e,n;return function(){function r(e,n,t){function o(f,i){if(!n[f]){if(!e[f]){var u="function"==typeof require&&require;if(!i&&u)return u(f,!0);if(a)return a(f,!0);var v=new Error("Cannot find module '"+f+"'");throw v.code="MODULE_NOT_FOUND",v}var d=n[f]={exports:{}};e[f][0].call(d.exports,function(r){var n=e[f][1][r];return o(n||r)},d,d.exports,r,e,n,t)}return n[f].exports}for(var a="function"==typeof require&&require,f=0;f0){throw new Error("Invalid string. Length must be a multiple of 4")}var n=r.indexOf("=");if(n===-1)n=e;var t=n===e?0:4-n%4;return[n,t]}function d(r){var e=v(r);var n=e[0];var t=e[1];return(n+t)*3/4-t}function c(r,e,n){return(e+n)*3/4-n}function h(r){var e;var n=v(r);var t=n[0];var f=n[1];var i=new a(c(r,t,f));var u=0;var d=f>0?t-4:t;for(var h=0;h>16&255;i[u++]=e>>8&255;i[u++]=e&255}if(f===2){e=o[r.charCodeAt(h)]<<2|o[r.charCodeAt(h+1)]>>4;i[u++]=e&255}if(f===1){e=o[r.charCodeAt(h)]<<10|o[r.charCodeAt(h+1)]<<4|o[r.charCodeAt(h+2)]>>2;i[u++]=e>>8&255;i[u++]=e&255}return i}function s(r){return t[r>>18&63]+t[r>>12&63]+t[r>>6&63]+t[r&63]}function l(r,e,n){var t;var o=[];for(var a=e;au?u:i+f))}if(o===1){e=r[n-1];a.push(t[e>>2]+t[e<<4&63]+"==")}else if(o===2){e=(r[n-2]<<8)+r[n-1];a.push(t[e>>10]+t[e>>4&63]+t[e<<2&63]+"=")}return a.join("")}},{}]},{},[])("/")}); diff --git a/node_modules/base64-js/index.js b/node_modules/base64-js/index.js index 8e806ac4..44c67664 100644 --- a/node_modules/base64-js/index.js +++ b/node_modules/base64-js/index.js @@ -14,68 +14,102 @@ for (var i = 0, len = code.length; i < len; ++i) { revLookup[code.charCodeAt(i)] = i } +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup['-'.charCodeAt(0)] = 62 revLookup['_'.charCodeAt(0)] = 63 -function placeHoldersCount (b64) { +function getLens (b64) { var len = b64.length + if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] } +// base64 is 4/3 + up to two characters of the original data function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return b64.length * 3 / 4 - placeHoldersCount(b64) + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] - arr = new Arr(len * 3 / 4 - placeHolders) + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen - var L = 0 - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF + for (var i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF } - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF } return arr } function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { - tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') @@ -85,30 +119,33 @@ function fromByteArray (uint8) { var tmp var len = uint8.length var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' var parts = [] var maxChunkLength = 16383 // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) } - parts.push(output) - return parts.join('') } diff --git a/node_modules/base64-js/package.json b/node_modules/base64-js/package.json index fe77c0f4..32f1443d 100644 --- a/node_modules/base64-js/package.json +++ b/node_modules/base64-js/package.json @@ -1,27 +1,28 @@ { - "_from": "base64-js@1.2.0", - "_id": "base64-js@1.2.0", + "_from": "base64-js@1", + "_id": "base64-js@1.3.0", "_inBundle": false, - "_integrity": "sha1-o5mS1yNYSBGYK+XikLtqU9hnAPE=", + "_integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", "_location": "/base64-js", "_phantomChildren": {}, "_requested": { - "type": "version", + "type": "range", "registry": true, - "raw": "base64-js@1.2.0", + "raw": "base64-js@1", "name": "base64-js", "escapedName": "base64-js", - "rawSpec": "1.2.0", + "rawSpec": "1", "saveSpec": null, - "fetchSpec": "1.2.0" + "fetchSpec": "1" }, "_requiredBy": [ - "/plist" + "#USER", + "/" ], - "_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.0.tgz", - "_shasum": "a39992d723584811982be5e290bb6a53d86700f1", - "_spec": "base64-js@1.2.0", - "_where": "/Users/brodybits/Documents/cordova/cordova-android/node_modules/plist", + "_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "_shasum": "cab1e6118f051095e58b5281aea8c1cd22bfc0e3", + "_spec": "base64-js@1", + "_where": "/Users/brodybits/Documents/cordova/cordova-android", "author": { "name": "T. Jameson Little", "email": "t.jameson.little@gmail.com" @@ -33,11 +34,11 @@ "deprecated": false, "description": "Base64 encoding/decoding in pure JS", "devDependencies": { - "benchmark": "^2.1.0", - "browserify": "^13.0.0", + "benchmark": "^2.1.4", + "browserify": "^14.0.0", "standard": "*", "tape": "4.x", - "uglify-js": "^2.6.2" + "uglify-js": "^2.8.29" }, "files": [ "test", @@ -61,5 +62,5 @@ "test": "npm run lint && npm run unit", "unit": "tape test/*.js" }, - "version": "1.2.0" + "version": "1.3.0" } diff --git a/node_modules/base64-js/test/big-data.js b/node_modules/base64-js/test/big-data.js index be16ebe6..107e09ec 100644 --- a/node_modules/base64-js/test/big-data.js +++ b/node_modules/base64-js/test/big-data.js @@ -10,6 +10,7 @@ test('convert big data to base64', function (t) { b64str = b64.fromByteArray(big) arr = b64.toByteArray(b64str) t.ok(equal(arr, big)) + t.equal(b64.byteLength(b64str), arr.length) t.end() }) diff --git a/node_modules/base64-js/test/convert.js b/node_modules/base64-js/test/convert.js index d68e105d..017a1332 100644 --- a/node_modules/base64-js/test/convert.js +++ b/node_modules/base64-js/test/convert.js @@ -29,6 +29,46 @@ test('convert to base64 and back', function (t) { } }) +var data = [ + [[0, 0, 0], 'AAAA'], + [[0, 0, 1], 'AAAB'], + [[0, 1, -1], 'AAH/'], + [[1, 1, 1], 'AQEB'], + [[0, -73, 23], 'ALcX'] +] + +test('convert known data to string', function (t) { + for (var i = 0; i < data.length; i++) { + var bytes = data[i][0] + var expected = data[i][1] + var actual = b64.fromByteArray(bytes) + t.equal(actual, expected, 'Ensure that ' + bytes + ' serialise to ' + expected) + } + t.end() +}) + +test('convert known data from string', function (t) { + for (var i = 0; i < data.length; i++) { + var expected = data[i][0] + var string = data[i][1] + var actual = b64.toByteArray(string) + t.ok(equal(actual, expected), 'Ensure that ' + string + ' deserialise to ' + expected) + var length = b64.byteLength(string) + t.equal(length, expected.length, 'Ensure that ' + string + ' has byte lentgh of ' + expected.length) + } + t.end() +}) + +function equal (a, b) { + var i + var length = a.length + if (length !== b.length) return false + for (i = 0; i < length; ++i) { + if ((a[i] & 0xFF) !== (b[i] & 0xFF)) return false + } + return true +} + function map (arr, callback) { var res = [] var kValue, mappedValue diff --git a/node_modules/base64-js/test/corrupt.js b/node_modules/base64-js/test/corrupt.js new file mode 100644 index 00000000..44c6e719 --- /dev/null +++ b/node_modules/base64-js/test/corrupt.js @@ -0,0 +1,10 @@ +var test = require('tape') +var b64 = require('../') + +test('padding bytes found inside base64 string', function (t) { + // See https://github.com/beatgammit/base64-js/issues/42 + var str = 'SQ==QU0=' + t.deepEqual(b64.toByteArray(str), new Uint8Array([73])) + t.equal(b64.byteLength(str), 1) + t.end() +}) diff --git a/node_modules/base64-js/test/url-safe.js b/node_modules/base64-js/test/url-safe.js index 3203b33d..4382e06c 100644 --- a/node_modules/base64-js/test/url-safe.js +++ b/node_modules/base64-js/test/url-safe.js @@ -4,15 +4,21 @@ var b64 = require('../') test('decode url-safe style base64 strings', function (t) { var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff] - var actual = b64.toByteArray('//++/++/++//') + var str = '//++/++/++//' + var actual = b64.toByteArray(str) for (var i = 0; i < actual.length; i++) { t.equal(actual[i], expected[i]) } - actual = b64.toByteArray('__--_--_--__') + t.equal(b64.byteLength(str), actual.length) + + str = '__--_--_--__' + actual = b64.toByteArray(str) for (i = 0; i < actual.length; i++) { t.equal(actual[i], expected[i]) } + t.equal(b64.byteLength(str), actual.length) + t.end() }) diff --git a/node_modules/big-integer/BigInteger.js b/node_modules/big-integer/BigInteger.js index e5609544..12361e77 100644 --- a/node_modules/big-integer/BigInteger.js +++ b/node_modules/big-integer/BigInteger.js @@ -785,29 +785,44 @@ var bigInt = (function (undefined) { if (n.isUnit()) return false; if (n.equals(2) || n.equals(3) || n.equals(5)) return true; if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false; - if (n.lesser(25)) return true; + if (n.lesser(49)) 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); - if (isPrime !== undefined) return isPrime; - var n = this.abs(), - nPrev = n.prev(); - var a = [2, 3, 5, 7, 11, 13, 17, 19], + + function millerRabinTest(n, a) { + var nPrev = n.prev(), b = nPrev, + r = 0, d, t, i, x; - while (b.isEven()) b = b.divide(2); - for (i = 0; i < a.length; i++) { + while (b.isEven()) b = b.divide(2), r++; + next : for (i = 0; i < a.length; i++) { + if (n.lesser(a[i])) continue; x = bigInt(a[i]).modPow(b, n); if (x.equals(Integer[1]) || x.equals(nPrev)) continue; - for (t = true, d = b; t && d.lesser(nPrev); d = d.multiply(2)) { + for (d = r - 1; d != 0; d--) { x = x.square().mod(n); - if (x.equals(nPrev)) t = false; + if (x.isUnit()) return false; + if (x.equals(nPrev)) continue next; } - if (t) return false; + return false; } return true; + } + +// Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2 + BigInteger.prototype.isPrime = function (strict) { + var isPrime = isBasicPrime(this); + if (isPrime !== undefined) return isPrime; + var n = this.abs(); + var bits = n.bitLength(); + if(bits <= 64) + return millerRabinTest(n, [2, 325, 9375, 28178, 450775, 9780504, 1795265022]); + var logN = Math.log(2) * bits; + var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN); + for (var a = [], i = 0; i < t; i++) { + a.push(bigInt(i + 2)); + } + return millerRabinTest(n, a); }; SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime; @@ -816,12 +831,10 @@ var bigInt = (function (undefined) { if (isPrime !== undefined) return isPrime; var n = this.abs(); var t = iterations === undefined ? 5 : iterations; - // use the Fermat primality test - for (var i = 0; i < t; i++) { - var a = bigInt.randBetween(2, n.minus(2)); - if (!a.modPow(n.prev(), n).isUnit()) return false; // definitely composite + for (var a = [], i = 0; i < t; i++) { + a.push(bigInt.randBetween(2, n.minus(2))); } - return true; // large chance of being prime + return millerRabinTest(n, a); }; SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime; diff --git a/node_modules/big-integer/BigInteger.min.js b/node_modules/big-integer/BigInteger.min.js index 8ec9160e..c69e29ec 100644 --- a/node_modules/big-integer/BigInteger.min.js +++ b/node_modules/big-integer/BigInteger.min.js @@ -1 +1 @@ -var bigInt=function(undefined){"use strict";var BASE=1e7,LOG_BASE=7,MAX_INT=9007199254740992,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_INT0)return Math.floor(n);return Math.ceil(n)}function add(a,b){var l_a=a.length,l_b=b.length,r=new Array(l_a),carry=0,base=BASE,sum,i;for(i=0;i=base?1:0;r[i]=sum-carry*base}while(i0)r.push(carry);return r}function addAny(a,b){if(a.length>=b.length)return add(a,b);return add(b,a)}function addSmall(a,carry){var l=a.length,r=new Array(l),base=BASE,sum,i;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}BigInteger.prototype.add=function(v){var n=parseValue(v);if(this.sign!==n.sign){return this.subtract(n.negate())}var a=this.value,b=n.value;if(n.isSmall){return new BigInteger(addSmall(a,Math.abs(b)),this.sign)}return new BigInteger(addAny(a,b),this.sign)};BigInteger.prototype.plus=BigInteger.prototype.add;SmallInteger.prototype.add=function(v){var n=parseValue(v);var a=this.value;if(a<0!==n.sign){return this.subtract(n.negate())}var b=n.value;if(n.isSmall){if(isPrecise(a+b))return new SmallInteger(a+b);b=smallToArray(Math.abs(b))}return new BigInteger(addSmall(b,Math.abs(a)),a<0)};SmallInteger.prototype.plus=SmallInteger.prototype.add;function subtract(a,b){var a_l=a.length,b_l=b.length,r=new Array(a_l),borrow=0,base=BASE,i,difference;for(i=0;i=0){value=subtract(a,b)}else{value=subtract(b,a);sign=!sign}value=arrayToSmall(value);if(typeof value==="number"){if(sign)value=-value;return new SmallInteger(value)}return new BigInteger(value,sign)}function subtractSmall(a,b,sign){var l=a.length,r=new Array(l),carry=-b,base=BASE,i,difference;for(i=0;i=0)};SmallInteger.prototype.minus=SmallInteger.prototype.subtract;BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)};SmallInteger.prototype.negate=function(){var sign=this.sign;var small=new SmallInteger(-this.value);small.sign=!sign;return small};BigInteger.prototype.abs=function(){return new BigInteger(this.value,false)};SmallInteger.prototype.abs=function(){return new SmallInteger(Math.abs(this.value))};function multiplyLong(a,b){var a_l=a.length,b_l=b.length,l=a_l+b_l,r=createArray(l),base=BASE,product,carry,i,a_i,b_j;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}function shiftLeft(x,n){var r=[];while(n-- >0)r.push(0);return r.concat(x)}function multiplyKaratsuba(x,y){var n=Math.max(x.length,y.length);if(n<=30)return multiplyLong(x,y);n=Math.ceil(n/2);var b=x.slice(n),a=x.slice(0,n),d=y.slice(n),c=y.slice(0,n);var ac=multiplyKaratsuba(a,c),bd=multiplyKaratsuba(b,d),abcd=multiplyKaratsuba(addAny(a,b),addAny(c,d));var product=addAny(addAny(ac,shiftLeft(subtract(subtract(abcd,ac),bd),n)),shiftLeft(bd,2*n));trim(product);return product}function useKaratsuba(l1,l2){return-.012*l1-.012*l2+15e-6*l1*l2>0}BigInteger.prototype.multiply=function(v){var n=parseValue(v),a=this.value,b=n.value,sign=this.sign!==n.sign,abs;if(n.isSmall){if(b===0)return Integer[0];if(b===1)return this;if(b===-1)return this.negate();abs=Math.abs(b);if(abs=0;shift--){quotientDigit=base-1;if(remainder[shift+b_l]!==divisorMostSignificantDigit){quotientDigit=Math.floor((remainder[shift+b_l]*base+remainder[shift+b_l-1])/divisorMostSignificantDigit)}carry=0;borrow=0;l=divisor.length;for(i=0;ib_l){highx=(highx+1)*base}guess=Math.ceil(highx/highy);do{check=multiplySmall(b,guess);if(compareAbs(check,part)<=0)break;guess--}while(guess);result.push(guess);part=subtract(part,check)}result.reverse();return[arrayToSmall(result),arrayToSmall(part)]}function divModSmall(value,lambda){var length=value.length,quotient=createArray(length),base=BASE,i,q,remainder,divisor;remainder=0;for(i=length-1;i>=0;--i){divisor=remainder*base+value[i];q=truncate(divisor/lambda);remainder=divisor-q*lambda;quotient[i]=q|0}return[quotient,remainder|0]}function divModAny(self,v){var value,n=parseValue(v);var a=self.value,b=n.value;var quotient;if(b===0)throw new Error("Cannot divide by zero");if(self.isSmall){if(n.isSmall){return[new SmallInteger(truncate(a/b)),new SmallInteger(a%b)]}return[Integer[0],self]}if(n.isSmall){if(b===1)return[self,Integer[0]];if(b==-1)return[self.negate(),Integer[0]];var abs=Math.abs(b);if(absb.length?1:-1}for(var i=a.length-1;i>=0;i--){if(a[i]!==b[i])return a[i]>b[i]?1:-1}return 0}BigInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall)return 1;return compareAbs(a,b)};SmallInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=Math.abs(this.value),b=n.value;if(n.isSmall){b=Math.abs(b);return a===b?0:a>b?1:-1}return-1};BigInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(this.sign!==n.sign){return n.sign?1:-1}if(n.isSmall){return this.sign?-1:1}return compareAbs(a,b)*(this.sign?-1:1)};BigInteger.prototype.compareTo=BigInteger.prototype.compare;SmallInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall){return a==b?0:a>b?1:-1}if(a<0!==n.sign){return a<0?-1:1}return a<0?1:-1};SmallInteger.prototype.compareTo=SmallInteger.prototype.compare;BigInteger.prototype.equals=function(v){return this.compare(v)===0};SmallInteger.prototype.eq=SmallInteger.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals;BigInteger.prototype.notEquals=function(v){return this.compare(v)!==0};SmallInteger.prototype.neq=SmallInteger.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals;BigInteger.prototype.greater=function(v){return this.compare(v)>0};SmallInteger.prototype.gt=SmallInteger.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater;BigInteger.prototype.lesser=function(v){return this.compare(v)<0};SmallInteger.prototype.lt=SmallInteger.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser;BigInteger.prototype.greaterOrEquals=function(v){return this.compare(v)>=0};SmallInteger.prototype.geq=SmallInteger.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals;BigInteger.prototype.lesserOrEquals=function(v){return this.compare(v)<=0};SmallInteger.prototype.leq=SmallInteger.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals;BigInteger.prototype.isEven=function(){return(this.value[0]&1)===0};SmallInteger.prototype.isEven=function(){return(this.value&1)===0};BigInteger.prototype.isOdd=function(){return(this.value[0]&1)===1};SmallInteger.prototype.isOdd=function(){return(this.value&1)===1};BigInteger.prototype.isPositive=function(){return!this.sign};SmallInteger.prototype.isPositive=function(){return this.value>0};BigInteger.prototype.isNegative=function(){return this.sign};SmallInteger.prototype.isNegative=function(){return this.value<0};BigInteger.prototype.isUnit=function(){return false};SmallInteger.prototype.isUnit=function(){return Math.abs(this.value)===1};BigInteger.prototype.isZero=function(){return false};SmallInteger.prototype.isZero=function(){return this.value===0};BigInteger.prototype.isDivisibleBy=function(v){var n=parseValue(v);var value=n.value;if(value===0)return false;if(value===1)return true;if(value===2)return this.isEven();return this.mod(n).equals(Integer[0])};SmallInteger.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy;function isBasicPrime(v){var n=v.abs();if(n.isUnit())return false;if(n.equals(2)||n.equals(3)||n.equals(5))return true;if(n.isEven()||n.isDivisibleBy(3)||n.isDivisibleBy(5))return false;if(n.lesser(25))return true}BigInteger.prototype.isPrime=function(){var isPrime=isBasicPrime(this);if(isPrime!==undefined)return isPrime;var n=this.abs(),nPrev=n.prev();var a=[2,3,5,7,11,13,17,19],b=nPrev,d,t,i,x;while(b.isEven())b=b.divide(2);for(i=0;i-MAX_INT)return new SmallInteger(value-1);return new BigInteger(MAX_INT_ARR,true)};var powersOfTwo=[1];while(2*powersOfTwo[powersOfTwo.length-1]<=BASE)powersOfTwo.push(2*powersOfTwo[powersOfTwo.length-1]);var powers2Length=powersOfTwo.length,highestPower2=powersOfTwo[powers2Length-1];function shift_isSmall(n){return(typeof n==="number"||typeof n==="string")&&+Math.abs(n)<=BASE||n instanceof BigInteger&&n.value.length<=1}BigInteger.prototype.shiftLeft=function(n){if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftRight(-n);var result=this;if(result.isZero())return result;while(n>=powers2Length){result=result.multiply(highestPower2);n-=powers2Length-1}return result.multiply(powersOfTwo[n])};SmallInteger.prototype.shiftLeft=BigInteger.prototype.shiftLeft;BigInteger.prototype.shiftRight=function(n){var remQuo;if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftLeft(-n);var result=this;while(n>=powers2Length){if(result.isZero()||result.isNegative()&&result.isUnit())return result;remQuo=divModAny(result,highestPower2);result=remQuo[1].isNegative()?remQuo[0].prev():remQuo[0];n-=powers2Length-1}remQuo=divModAny(result,powersOfTwo[n]);return remQuo[1].isNegative()?remQuo[0].prev():remQuo[0]};SmallInteger.prototype.shiftRight=BigInteger.prototype.shiftRight;function bitwise(x,y,fn){y=parseValue(y);var xSign=x.isNegative(),ySign=y.isNegative();var xRem=xSign?x.not():x,yRem=ySign?y.not():y;var xDigit=0,yDigit=0;var xDivMod=null,yDivMod=null;var result=[];while(!xRem.isZero()||!yRem.isZero()){xDivMod=divModAny(xRem,highestPower2);xDigit=xDivMod[1].toJSNumber();if(xSign){xDigit=highestPower2-1-xDigit}yDivMod=divModAny(yRem,highestPower2);yDigit=yDivMod[1].toJSNumber();if(ySign){yDigit=highestPower2-1-yDigit}xRem=xDivMod[0];yRem=yDivMod[0];result.push(fn(xDigit,yDigit))}var sum=fn(xSign?1:0,ySign?1:0)!==0?bigInt(-1):bigInt(0);for(var i=result.length-1;i>=0;i-=1){sum=sum.multiply(highestPower2).add(bigInt(result[i]))}return sum}BigInteger.prototype.not=function(){return this.negate().prev()};SmallInteger.prototype.not=BigInteger.prototype.not;BigInteger.prototype.and=function(n){return bitwise(this,n,function(a,b){return a&b})};SmallInteger.prototype.and=BigInteger.prototype.and;BigInteger.prototype.or=function(n){return bitwise(this,n,function(a,b){return a|b})};SmallInteger.prototype.or=BigInteger.prototype.or;BigInteger.prototype.xor=function(n){return bitwise(this,n,function(a,b){return a^b})};SmallInteger.prototype.xor=BigInteger.prototype.xor;var LOBMASK_I=1<<30,LOBMASK_BI=(BASE&-BASE)*(BASE&-BASE)|LOBMASK_I;function roughLOB(n){var v=n.value,x=typeof v==="number"?v|LOBMASK_I:v[0]+v[1]*BASE|LOBMASK_BI;return x&-x}function integerLogarithm(value,base){if(base.compareTo(value)<=0){var tmp=integerLogarithm(value,base.square(base));var p=tmp.p;var e=tmp.e;var t=p.multiply(base);return t.compareTo(value)<=0?{p:t,e:e*2+1}:{p:p,e:e*2}}return{p:bigInt(1),e:0}}BigInteger.prototype.bitLength=function(){var n=this;if(n.compareTo(bigInt(0))<0){n=n.negate().subtract(bigInt(1))}if(n.compareTo(bigInt(0))===0){return bigInt(0)}return bigInt(integerLogarithm(n,bigInt(2)).e).add(bigInt(1))};SmallInteger.prototype.bitLength=BigInteger.prototype.bitLength;function max(a,b){a=parseValue(a);b=parseValue(b);return a.greater(b)?a:b}function min(a,b){a=parseValue(a);b=parseValue(b);return a.lesser(b)?a:b}function gcd(a,b){a=parseValue(a).abs();b=parseValue(b).abs();if(a.equals(b))return a;if(a.isZero())return b;if(b.isZero())return a;var c=Integer[1],d,t;while(a.isEven()&&b.isEven()){d=Math.min(roughLOB(a),roughLOB(b));a=a.divide(d);b=b.divide(d);c=c.multiply(d)}while(a.isEven()){a=a.divide(roughLOB(a))}do{while(b.isEven()){b=b.divide(roughLOB(b))}if(a.greater(b)){t=b;b=a;a=t}b=b.subtract(a)}while(!b.isZero());return c.isUnit()?a:a.multiply(c)}function lcm(a,b){a=parseValue(a).abs();b=parseValue(b).abs();return a.divide(gcd(a,b)).multiply(b)}function randBetween(a,b){a=parseValue(a);b=parseValue(b);var low=min(a,b),high=max(a,b);var range=high.subtract(low).add(1);if(range.isSmall)return low.add(Math.floor(Math.random()*range));var length=range.value.length-1;var result=[],restricted=true;for(var i=length;i>=0;i--){var top=restricted?range.value[i]:BASE;var digit=truncate(Math.random()*top);result.unshift(digit);if(digit=absBase){if(c==="1"&&absBase===1)continue;throw new Error(c+" is not a valid digit in base "+base+".")}else if(c.charCodeAt(0)-87>=absBase){throw new Error(c+" is not a valid digit in base "+base+".")}}}if(2<=base&&base<=36){if(length<=LOG_MAX_INT/Math.log(base)){var result=parseInt(text,base);if(isNaN(result)){throw new Error(c+" is not a valid digit in base "+base+".")}return new SmallInteger(parseInt(text,base))}}base=parseValue(base);var digits=[];var isNegative=text[0]==="-";for(i=isNegative?1:0;i");digits.push(parseValue(text.slice(start+1,i)))}else throw new Error(c+" is not a valid character")}return parseBaseFromArray(digits,base,isNegative)};function parseBaseFromArray(digits,base,isNegative){var val=Integer[0],pow=Integer[1],i;for(i=digits.length-1;i>=0;i--){val=val.add(digits[i].times(pow));pow=pow.times(base)}return isNegative?val.negate():val}function stringify(digit){if(digit<=35){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(digit)}return"<"+digit+">"}function toBase(n,base){base=bigInt(base);if(base.isZero()){if(n.isZero())return{value:[0],isNegative:false};throw new Error("Cannot convert nonzero numbers to base 0.")}if(base.equals(-1)){if(n.isZero())return{value:[0],isNegative:false};if(n.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-n)).map(Array.prototype.valueOf,[1,0])),isNegative:false};var arr=Array.apply(null,Array(+n-1)).map(Array.prototype.valueOf,[0,1]);arr.unshift([1]);return{value:[].concat.apply([],arr),isNegative:false}}var neg=false;if(n.isNegative()&&base.isPositive()){neg=true;n=n.abs()}if(base.equals(1)){if(n.isZero())return{value:[0],isNegative:false};return{value:Array.apply(null,Array(+n)).map(Number.prototype.valueOf,1),isNegative:neg}}var out=[];var left=n,divmod;while(left.isNegative()||left.compareAbs(base)>=0){divmod=left.divmod(base);left=divmod.quotient;var digit=divmod.remainder;if(digit.isNegative()){digit=base.minus(digit).abs();left=left.next()}out.push(digit.toJSNumber())}out.push(left.toJSNumber());return{value:out.reverse(),isNegative:neg}}function toBaseString(n,base){var arr=toBase(n,base);return(arr.isNegative?"-":"")+arr.value.map(stringify).join("")}BigInteger.prototype.toArray=function(radix){return toBase(this,radix)};SmallInteger.prototype.toArray=function(radix){return toBase(this,radix)};BigInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!==10)return toBaseString(this,radix);var v=this.value,l=v.length,str=String(v[--l]),zeros="0000000",digit;while(--l>=0){digit=String(v[l]);str+=zeros.slice(digit.length)+digit}var sign=this.sign?"-":"";return sign+str};SmallInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!=10)return toBaseString(this,radix);return String(this.value)};BigInteger.prototype.toJSON=SmallInteger.prototype.toJSON=function(){return this.toString()};BigInteger.prototype.valueOf=function(){return parseInt(this.toString(),10)};BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf;SmallInteger.prototype.valueOf=function(){return this.value};SmallInteger.prototype.toJSNumber=SmallInteger.prototype.valueOf;function parseStringValue(v){if(isPrecise(+v)){var x=+v;if(x===truncate(x))return new SmallInteger(x);throw new Error("Invalid integer: "+v)}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: "+split.join("e"));if(split.length===2){var exp=split[1];if(exp[0]==="+")exp=exp.slice(1);exp=+exp;if(exp!==truncate(exp)||!isPrecise(exp))throw new Error("Invalid integer: "+exp+" is not a valid exponent.");var text=split[0];var decimalPlace=text.indexOf(".");if(decimalPlace>=0){exp-=text.length-decimalPlace-1;text=text.slice(0,decimalPlace)+text.slice(decimalPlace+1)}if(exp<0)throw new Error("Cannot include negative exponent part for integers");text+=new Array(exp+1).join("0");v=text}var isValid=/^([0-9][0-9]*)$/.test(v);if(!isValid)throw new Error("Invalid integer: "+v);var r=[],max=v.length,l=LOG_BASE,min=max-l;while(max>0){r.push(+v.slice(min,max));min-=l;if(min<0)min=0;max-=l}trim(r);return new BigInteger(r,sign)}function parseNumberValue(v){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){if(typeof v==="number"){return parseNumberValue(v)}if(typeof v==="string"){return parseStringValue(v)}return v}for(var i=0;i<1e3;i++){Integer[i]=new SmallInteger(i);if(i>0)Integer[-i]=new SmallInteger(-i)}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;Integer.fromArray=function(digits,base,isNegative){return parseBaseFromArray(digits.map(parseValue),parseValue(base||10),isNegative)};return Integer}();if(typeof module!=="undefined"&&module.hasOwnProperty("exports")){module.exports=bigInt}if(typeof define==="function"&&define.amd){define("big-integer",[],function(){return bigInt})} \ No newline at end of file +var bigInt=function(undefined){"use strict";var BASE=1e7,LOG_BASE=7,MAX_INT=9007199254740992,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_INT0)return Math.floor(n);return Math.ceil(n)}function add(a,b){var l_a=a.length,l_b=b.length,r=new Array(l_a),carry=0,base=BASE,sum,i;for(i=0;i=base?1:0;r[i]=sum-carry*base}while(i0)r.push(carry);return r}function addAny(a,b){if(a.length>=b.length)return add(a,b);return add(b,a)}function addSmall(a,carry){var l=a.length,r=new Array(l),base=BASE,sum,i;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}BigInteger.prototype.add=function(v){var n=parseValue(v);if(this.sign!==n.sign){return this.subtract(n.negate())}var a=this.value,b=n.value;if(n.isSmall){return new BigInteger(addSmall(a,Math.abs(b)),this.sign)}return new BigInteger(addAny(a,b),this.sign)};BigInteger.prototype.plus=BigInteger.prototype.add;SmallInteger.prototype.add=function(v){var n=parseValue(v);var a=this.value;if(a<0!==n.sign){return this.subtract(n.negate())}var b=n.value;if(n.isSmall){if(isPrecise(a+b))return new SmallInteger(a+b);b=smallToArray(Math.abs(b))}return new BigInteger(addSmall(b,Math.abs(a)),a<0)};SmallInteger.prototype.plus=SmallInteger.prototype.add;function subtract(a,b){var a_l=a.length,b_l=b.length,r=new Array(a_l),borrow=0,base=BASE,i,difference;for(i=0;i=0){value=subtract(a,b)}else{value=subtract(b,a);sign=!sign}value=arrayToSmall(value);if(typeof value==="number"){if(sign)value=-value;return new SmallInteger(value)}return new BigInteger(value,sign)}function subtractSmall(a,b,sign){var l=a.length,r=new Array(l),carry=-b,base=BASE,i,difference;for(i=0;i=0)};SmallInteger.prototype.minus=SmallInteger.prototype.subtract;BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)};SmallInteger.prototype.negate=function(){var sign=this.sign;var small=new SmallInteger(-this.value);small.sign=!sign;return small};BigInteger.prototype.abs=function(){return new BigInteger(this.value,false)};SmallInteger.prototype.abs=function(){return new SmallInteger(Math.abs(this.value))};function multiplyLong(a,b){var a_l=a.length,b_l=b.length,l=a_l+b_l,r=createArray(l),base=BASE,product,carry,i,a_i,b_j;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}function shiftLeft(x,n){var r=[];while(n-- >0)r.push(0);return r.concat(x)}function multiplyKaratsuba(x,y){var n=Math.max(x.length,y.length);if(n<=30)return multiplyLong(x,y);n=Math.ceil(n/2);var b=x.slice(n),a=x.slice(0,n),d=y.slice(n),c=y.slice(0,n);var ac=multiplyKaratsuba(a,c),bd=multiplyKaratsuba(b,d),abcd=multiplyKaratsuba(addAny(a,b),addAny(c,d));var product=addAny(addAny(ac,shiftLeft(subtract(subtract(abcd,ac),bd),n)),shiftLeft(bd,2*n));trim(product);return product}function useKaratsuba(l1,l2){return-.012*l1-.012*l2+15e-6*l1*l2>0}BigInteger.prototype.multiply=function(v){var n=parseValue(v),a=this.value,b=n.value,sign=this.sign!==n.sign,abs;if(n.isSmall){if(b===0)return Integer[0];if(b===1)return this;if(b===-1)return this.negate();abs=Math.abs(b);if(abs=0;shift--){quotientDigit=base-1;if(remainder[shift+b_l]!==divisorMostSignificantDigit){quotientDigit=Math.floor((remainder[shift+b_l]*base+remainder[shift+b_l-1])/divisorMostSignificantDigit)}carry=0;borrow=0;l=divisor.length;for(i=0;ib_l){highx=(highx+1)*base}guess=Math.ceil(highx/highy);do{check=multiplySmall(b,guess);if(compareAbs(check,part)<=0)break;guess--}while(guess);result.push(guess);part=subtract(part,check)}result.reverse();return[arrayToSmall(result),arrayToSmall(part)]}function divModSmall(value,lambda){var length=value.length,quotient=createArray(length),base=BASE,i,q,remainder,divisor;remainder=0;for(i=length-1;i>=0;--i){divisor=remainder*base+value[i];q=truncate(divisor/lambda);remainder=divisor-q*lambda;quotient[i]=q|0}return[quotient,remainder|0]}function divModAny(self,v){var value,n=parseValue(v);var a=self.value,b=n.value;var quotient;if(b===0)throw new Error("Cannot divide by zero");if(self.isSmall){if(n.isSmall){return[new SmallInteger(truncate(a/b)),new SmallInteger(a%b)]}return[Integer[0],self]}if(n.isSmall){if(b===1)return[self,Integer[0]];if(b==-1)return[self.negate(),Integer[0]];var abs=Math.abs(b);if(absb.length?1:-1}for(var i=a.length-1;i>=0;i--){if(a[i]!==b[i])return a[i]>b[i]?1:-1}return 0}BigInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall)return 1;return compareAbs(a,b)};SmallInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=Math.abs(this.value),b=n.value;if(n.isSmall){b=Math.abs(b);return a===b?0:a>b?1:-1}return-1};BigInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(this.sign!==n.sign){return n.sign?1:-1}if(n.isSmall){return this.sign?-1:1}return compareAbs(a,b)*(this.sign?-1:1)};BigInteger.prototype.compareTo=BigInteger.prototype.compare;SmallInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall){return a==b?0:a>b?1:-1}if(a<0!==n.sign){return a<0?-1:1}return a<0?1:-1};SmallInteger.prototype.compareTo=SmallInteger.prototype.compare;BigInteger.prototype.equals=function(v){return this.compare(v)===0};SmallInteger.prototype.eq=SmallInteger.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals;BigInteger.prototype.notEquals=function(v){return this.compare(v)!==0};SmallInteger.prototype.neq=SmallInteger.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals;BigInteger.prototype.greater=function(v){return this.compare(v)>0};SmallInteger.prototype.gt=SmallInteger.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater;BigInteger.prototype.lesser=function(v){return this.compare(v)<0};SmallInteger.prototype.lt=SmallInteger.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser;BigInteger.prototype.greaterOrEquals=function(v){return this.compare(v)>=0};SmallInteger.prototype.geq=SmallInteger.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals;BigInteger.prototype.lesserOrEquals=function(v){return this.compare(v)<=0};SmallInteger.prototype.leq=SmallInteger.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals;BigInteger.prototype.isEven=function(){return(this.value[0]&1)===0};SmallInteger.prototype.isEven=function(){return(this.value&1)===0};BigInteger.prototype.isOdd=function(){return(this.value[0]&1)===1};SmallInteger.prototype.isOdd=function(){return(this.value&1)===1};BigInteger.prototype.isPositive=function(){return!this.sign};SmallInteger.prototype.isPositive=function(){return this.value>0};BigInteger.prototype.isNegative=function(){return this.sign};SmallInteger.prototype.isNegative=function(){return this.value<0};BigInteger.prototype.isUnit=function(){return false};SmallInteger.prototype.isUnit=function(){return Math.abs(this.value)===1};BigInteger.prototype.isZero=function(){return false};SmallInteger.prototype.isZero=function(){return this.value===0};BigInteger.prototype.isDivisibleBy=function(v){var n=parseValue(v);var value=n.value;if(value===0)return false;if(value===1)return true;if(value===2)return this.isEven();return this.mod(n).equals(Integer[0])};SmallInteger.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy;function isBasicPrime(v){var n=v.abs();if(n.isUnit())return false;if(n.equals(2)||n.equals(3)||n.equals(5))return true;if(n.isEven()||n.isDivisibleBy(3)||n.isDivisibleBy(5))return false;if(n.lesser(49))return true}function millerRabinTest(n,a){var nPrev=n.prev(),b=nPrev,r=0,d,t,i,x;while(b.isEven())b=b.divide(2),r++;next:for(i=0;i-MAX_INT)return new SmallInteger(value-1);return new BigInteger(MAX_INT_ARR,true)};var powersOfTwo=[1];while(2*powersOfTwo[powersOfTwo.length-1]<=BASE)powersOfTwo.push(2*powersOfTwo[powersOfTwo.length-1]);var powers2Length=powersOfTwo.length,highestPower2=powersOfTwo[powers2Length-1];function shift_isSmall(n){return(typeof n==="number"||typeof n==="string")&&+Math.abs(n)<=BASE||n instanceof BigInteger&&n.value.length<=1}BigInteger.prototype.shiftLeft=function(n){if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftRight(-n);var result=this;if(result.isZero())return result;while(n>=powers2Length){result=result.multiply(highestPower2);n-=powers2Length-1}return result.multiply(powersOfTwo[n])};SmallInteger.prototype.shiftLeft=BigInteger.prototype.shiftLeft;BigInteger.prototype.shiftRight=function(n){var remQuo;if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftLeft(-n);var result=this;while(n>=powers2Length){if(result.isZero()||result.isNegative()&&result.isUnit())return result;remQuo=divModAny(result,highestPower2);result=remQuo[1].isNegative()?remQuo[0].prev():remQuo[0];n-=powers2Length-1}remQuo=divModAny(result,powersOfTwo[n]);return remQuo[1].isNegative()?remQuo[0].prev():remQuo[0]};SmallInteger.prototype.shiftRight=BigInteger.prototype.shiftRight;function bitwise(x,y,fn){y=parseValue(y);var xSign=x.isNegative(),ySign=y.isNegative();var xRem=xSign?x.not():x,yRem=ySign?y.not():y;var xDigit=0,yDigit=0;var xDivMod=null,yDivMod=null;var result=[];while(!xRem.isZero()||!yRem.isZero()){xDivMod=divModAny(xRem,highestPower2);xDigit=xDivMod[1].toJSNumber();if(xSign){xDigit=highestPower2-1-xDigit}yDivMod=divModAny(yRem,highestPower2);yDigit=yDivMod[1].toJSNumber();if(ySign){yDigit=highestPower2-1-yDigit}xRem=xDivMod[0];yRem=yDivMod[0];result.push(fn(xDigit,yDigit))}var sum=fn(xSign?1:0,ySign?1:0)!==0?bigInt(-1):bigInt(0);for(var i=result.length-1;i>=0;i-=1){sum=sum.multiply(highestPower2).add(bigInt(result[i]))}return sum}BigInteger.prototype.not=function(){return this.negate().prev()};SmallInteger.prototype.not=BigInteger.prototype.not;BigInteger.prototype.and=function(n){return bitwise(this,n,function(a,b){return a&b})};SmallInteger.prototype.and=BigInteger.prototype.and;BigInteger.prototype.or=function(n){return bitwise(this,n,function(a,b){return a|b})};SmallInteger.prototype.or=BigInteger.prototype.or;BigInteger.prototype.xor=function(n){return bitwise(this,n,function(a,b){return a^b})};SmallInteger.prototype.xor=BigInteger.prototype.xor;var LOBMASK_I=1<<30,LOBMASK_BI=(BASE&-BASE)*(BASE&-BASE)|LOBMASK_I;function roughLOB(n){var v=n.value,x=typeof v==="number"?v|LOBMASK_I:v[0]+v[1]*BASE|LOBMASK_BI;return x&-x}function integerLogarithm(value,base){if(base.compareTo(value)<=0){var tmp=integerLogarithm(value,base.square(base));var p=tmp.p;var e=tmp.e;var t=p.multiply(base);return t.compareTo(value)<=0?{p:t,e:e*2+1}:{p:p,e:e*2}}return{p:bigInt(1),e:0}}BigInteger.prototype.bitLength=function(){var n=this;if(n.compareTo(bigInt(0))<0){n=n.negate().subtract(bigInt(1))}if(n.compareTo(bigInt(0))===0){return bigInt(0)}return bigInt(integerLogarithm(n,bigInt(2)).e).add(bigInt(1))};SmallInteger.prototype.bitLength=BigInteger.prototype.bitLength;function max(a,b){a=parseValue(a);b=parseValue(b);return a.greater(b)?a:b}function min(a,b){a=parseValue(a);b=parseValue(b);return a.lesser(b)?a:b}function gcd(a,b){a=parseValue(a).abs();b=parseValue(b).abs();if(a.equals(b))return a;if(a.isZero())return b;if(b.isZero())return a;var c=Integer[1],d,t;while(a.isEven()&&b.isEven()){d=Math.min(roughLOB(a),roughLOB(b));a=a.divide(d);b=b.divide(d);c=c.multiply(d)}while(a.isEven()){a=a.divide(roughLOB(a))}do{while(b.isEven()){b=b.divide(roughLOB(b))}if(a.greater(b)){t=b;b=a;a=t}b=b.subtract(a)}while(!b.isZero());return c.isUnit()?a:a.multiply(c)}function lcm(a,b){a=parseValue(a).abs();b=parseValue(b).abs();return a.divide(gcd(a,b)).multiply(b)}function randBetween(a,b){a=parseValue(a);b=parseValue(b);var low=min(a,b),high=max(a,b);var range=high.subtract(low).add(1);if(range.isSmall)return low.add(Math.floor(Math.random()*range));var length=range.value.length-1;var result=[],restricted=true;for(var i=length;i>=0;i--){var top=restricted?range.value[i]:BASE;var digit=truncate(Math.random()*top);result.unshift(digit);if(digit=absBase){if(c==="1"&&absBase===1)continue;throw new Error(c+" is not a valid digit in base "+base+".")}else if(c.charCodeAt(0)-87>=absBase){throw new Error(c+" is not a valid digit in base "+base+".")}}}if(2<=base&&base<=36){if(length<=LOG_MAX_INT/Math.log(base)){var result=parseInt(text,base);if(isNaN(result)){throw new Error(c+" is not a valid digit in base "+base+".")}return new SmallInteger(parseInt(text,base))}}base=parseValue(base);var digits=[];var isNegative=text[0]==="-";for(i=isNegative?1:0;i");digits.push(parseValue(text.slice(start+1,i)))}else throw new Error(c+" is not a valid character")}return parseBaseFromArray(digits,base,isNegative)};function parseBaseFromArray(digits,base,isNegative){var val=Integer[0],pow=Integer[1],i;for(i=digits.length-1;i>=0;i--){val=val.add(digits[i].times(pow));pow=pow.times(base)}return isNegative?val.negate():val}function stringify(digit){if(digit<=35){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(digit)}return"<"+digit+">"}function toBase(n,base){base=bigInt(base);if(base.isZero()){if(n.isZero())return{value:[0],isNegative:false};throw new Error("Cannot convert nonzero numbers to base 0.")}if(base.equals(-1)){if(n.isZero())return{value:[0],isNegative:false};if(n.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-n)).map(Array.prototype.valueOf,[1,0])),isNegative:false};var arr=Array.apply(null,Array(+n-1)).map(Array.prototype.valueOf,[0,1]);arr.unshift([1]);return{value:[].concat.apply([],arr),isNegative:false}}var neg=false;if(n.isNegative()&&base.isPositive()){neg=true;n=n.abs()}if(base.equals(1)){if(n.isZero())return{value:[0],isNegative:false};return{value:Array.apply(null,Array(+n)).map(Number.prototype.valueOf,1),isNegative:neg}}var out=[];var left=n,divmod;while(left.isNegative()||left.compareAbs(base)>=0){divmod=left.divmod(base);left=divmod.quotient;var digit=divmod.remainder;if(digit.isNegative()){digit=base.minus(digit).abs();left=left.next()}out.push(digit.toJSNumber())}out.push(left.toJSNumber());return{value:out.reverse(),isNegative:neg}}function toBaseString(n,base){var arr=toBase(n,base);return(arr.isNegative?"-":"")+arr.value.map(stringify).join("")}BigInteger.prototype.toArray=function(radix){return toBase(this,radix)};SmallInteger.prototype.toArray=function(radix){return toBase(this,radix)};BigInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!==10)return toBaseString(this,radix);var v=this.value,l=v.length,str=String(v[--l]),zeros="0000000",digit;while(--l>=0){digit=String(v[l]);str+=zeros.slice(digit.length)+digit}var sign=this.sign?"-":"";return sign+str};SmallInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!=10)return toBaseString(this,radix);return String(this.value)};BigInteger.prototype.toJSON=SmallInteger.prototype.toJSON=function(){return this.toString()};BigInteger.prototype.valueOf=function(){return parseInt(this.toString(),10)};BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf;SmallInteger.prototype.valueOf=function(){return this.value};SmallInteger.prototype.toJSNumber=SmallInteger.prototype.valueOf;function parseStringValue(v){if(isPrecise(+v)){var x=+v;if(x===truncate(x))return new SmallInteger(x);throw new Error("Invalid integer: "+v)}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: "+split.join("e"));if(split.length===2){var exp=split[1];if(exp[0]==="+")exp=exp.slice(1);exp=+exp;if(exp!==truncate(exp)||!isPrecise(exp))throw new Error("Invalid integer: "+exp+" is not a valid exponent.");var text=split[0];var decimalPlace=text.indexOf(".");if(decimalPlace>=0){exp-=text.length-decimalPlace-1;text=text.slice(0,decimalPlace)+text.slice(decimalPlace+1)}if(exp<0)throw new Error("Cannot include negative exponent part for integers");text+=new Array(exp+1).join("0");v=text}var isValid=/^([0-9][0-9]*)$/.test(v);if(!isValid)throw new Error("Invalid integer: "+v);var r=[],max=v.length,l=LOG_BASE,min=max-l;while(max>0){r.push(+v.slice(min,max));min-=l;if(min<0)min=0;max-=l}trim(r);return new BigInteger(r,sign)}function parseNumberValue(v){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){if(typeof v==="number"){return parseNumberValue(v)}if(typeof v==="string"){return parseStringValue(v)}return v}for(var i=0;i<1e3;i++){Integer[i]=new SmallInteger(i);if(i>0)Integer[-i]=new SmallInteger(-i)}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;Integer.fromArray=function(digits,base,isNegative){return parseBaseFromArray(digits.map(parseValue),parseValue(base||10),isNegative)};return Integer}();if(typeof module!=="undefined"&&module.hasOwnProperty("exports")){module.exports=bigInt}if(typeof define==="function"&&define.amd){define("big-integer",[],function(){return bigInt})} \ No newline at end of file diff --git a/node_modules/big-integer/README.md b/node_modules/big-integer/README.md index 55ab8d33..325c0a84 100644 --- a/node_modules/big-integer/README.md +++ b/node_modules/big-integer/README.md @@ -219,15 +219,15 @@ Returns `true` if the number is prime, `false` otherwise. Returns `true` if the number is very likely to be prime, `false` otherwise. Argument is optional and determines the amount of iterations of the test (default: `5`). The more iterations, the lower chance of getting a false positive. -This uses the [Fermat primality test](https://en.wikipedia.org/wiki/Fermat_primality_test). +This uses the [Miller Rabin test](https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test). - `bigInt(5).isProbablePrime()` => `true` - `bigInt(49).isProbablePrime()` => `false` - - `bigInt(1729).isProbablePrime(50)` => `false` + - `bigInt(1729).isProbablePrime()` => `false` -Note that this function is not deterministic, since it relies on random sampling of factors, so the result for some numbers is not always the same. [Carmichael numbers](https://en.wikipedia.org/wiki/Carmichael_number) are particularly prone to give unreliable results. - -For example, `bigInt(1729).isProbablePrime()` returns `false` about 76% of the time and `true` about 24% of the time. The correct result is `false`. +Note that this function is not deterministic, since it relies on random sampling of factors, so the result for some numbers is not always the same. +If the number is composite then the Miller–Rabin primality test declares the number probably prime with a probability at most `4` to the power `−iterations`. +If the number is prime, this function always returns `true`. #### `isUnit()` diff --git a/node_modules/big-integer/package.json b/node_modules/big-integer/package.json index 1e5a3abf..d7552f1f 100644 --- a/node_modules/big-integer/package.json +++ b/node_modules/big-integer/package.json @@ -1,27 +1,29 @@ { - "_from": "big-integer@^1.6.7", - "_id": "big-integer@1.6.32", + "_from": "big-integer@1", + "_id": "big-integer@1.6.36", "_inBundle": false, - "_integrity": "sha512-ljKJdR3wk9thHfLj4DtrNiOSTxvGFaMjWrG4pW75juXC4j7+XuKJVFdg4kgFMYp85PVkO05dFMj2dk2xVsH4xw==", + "_integrity": "sha512-t70bfa7HYEA1D9idDbmuv7YbsbVkQ+Hp+8KFSul4aE5e/i1bjCNIRYJZlA8Q8p0r9T8cF/RVvwUgRA//FydEyg==", "_location": "/big-integer", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "big-integer@^1.6.7", + "raw": "big-integer@1", "name": "big-integer", "escapedName": "big-integer", - "rawSpec": "^1.6.7", + "rawSpec": "1", "saveSpec": null, - "fetchSpec": "^1.6.7" + "fetchSpec": "1" }, "_requiredBy": [ + "#USER", + "/", "/bplist-parser" ], - "_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.32.tgz", - "_shasum": "5867458b25ecd5bcb36b627c30bb501a13c07e89", - "_spec": "big-integer@^1.6.7", - "_where": "/Users/brodybits/Documents/cordova/cordova-android/node_modules/bplist-parser", + "_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.36.tgz", + "_shasum": "78631076265d4ae3555c04f85e7d9d2f3a071a36", + "_spec": "big-integer@1", + "_where": "/Users/brodybits/Documents/cordova/cordova-android", "author": { "name": "Peter Olson", "email": "peter.e.c.olson+npm@gmail.com" @@ -76,5 +78,5 @@ "test": "tsc && karma start my.conf.js && node spec/tsDefinitions.js" }, "typings": "./BigInteger.d.ts", - "version": "1.6.32" + "version": "1.6.36" } diff --git a/node_modules/path-is-absolute/package.json b/node_modules/path-is-absolute/package.json index dbbfb583..719747ae 100644 --- a/node_modules/path-is-absolute/package.json +++ b/node_modules/path-is-absolute/package.json @@ -1,5 +1,5 @@ { - "_from": "path-is-absolute@^1.0.0", + "_from": "path-is-absolute@1", "_id": "path-is-absolute@1.0.1", "_inBundle": false, "_integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", @@ -8,24 +8,25 @@ "_requested": { "type": "range", "registry": true, - "raw": "path-is-absolute@^1.0.0", + "raw": "path-is-absolute@1", "name": "path-is-absolute", "escapedName": "path-is-absolute", - "rawSpec": "^1.0.0", + "rawSpec": "1", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1" }, "_requiredBy": [ + "#USER", + "/", "/eslint/glob", "/glob", - "/globby/glob", "/jasmine/glob", "/rimraf/glob" ], - "_resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "_resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "_shasum": "174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f", - "_spec": "path-is-absolute@^1.0.0", - "_where": "/Users/brodybits/Documents/cordova/cordova-android/node_modules/glob", + "_spec": "path-is-absolute@1", + "_where": "/Users/brodybits/Documents/cordova/cordova-android", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", diff --git a/node_modules/semver/README.md b/node_modules/semver/README.md index 951c5395..e0edbb73 100644 --- a/node_modules/semver/README.md +++ b/node_modules/semver/README.md @@ -29,8 +29,6 @@ As a command-line utility: ``` $ semver -h -SemVer 5.3.0 - A JavaScript implementation of the http://semver.org/ specification Copyright Isaac Z. Schlueter @@ -54,6 +52,9 @@ Options: -l --loose Interpret versions and ranges loosely +-p --include-prerelease + Always include prerelease versions in range matching + -c --coerce Coerce a string into SemVer if possible (does not imply --loose) @@ -274,7 +275,7 @@ logical-or ::= ( ' ' ) * '||' ( ' ' ) * range ::= hyphen | simple ( ' ' simple ) * | '' hyphen ::= partial ' - ' partial simple ::= primitive | partial | tilde | caret -primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial +primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? xr ::= 'x' | 'X' | '*' | nr nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) * @@ -289,9 +290,19 @@ part ::= nr | [-0-9A-Za-z]+ ## Functions -All methods and classes take a final `loose` boolean argument that, if -true, will be more forgiving about not-quite-valid semver strings. -The resulting output will always be 100% strict, of course. +All methods and classes take a final `options` object argument. All +options in this object are `false` by default. The options supported +are: + +- `loose` Be more forgiving about not-quite-valid semver strings. + (Any resulting output will always be 100% strict compliant, of + course.) For backwards compatibility reasons, if the `options` + argument is a boolean value instead of an object, it is interpreted + to be the `loose` param. +- `includePrerelease` Set to suppress the [default + behavior](https://github.com/npm/node-semver#prerelease-tags) of + excluding prerelease tagged versions from ranges unless they are + explicitly opted into. Strict-mode Comparators and Ranges will be strict about the SemVer strings that they parse. diff --git a/node_modules/semver/bin/semver b/node_modules/semver/bin/semver index dddbcdf1..9100ed42 100755 --- a/node_modules/semver/bin/semver +++ b/node_modules/semver/bin/semver @@ -12,10 +12,12 @@ var argv = process.argv.slice(2) , inc = null , version = require("../package.json").version , loose = false + , includePrerelease = false , coerce = false , identifier = undefined , semver = require("../semver") , reverse = false + , options = {} main() @@ -35,6 +37,9 @@ function main () { case "-l": case "--loose": loose = true break + case "-p": case "--include-prerelease": + includePrerelease = true + break case "-v": case "--version": versions.push(argv.shift()) break @@ -66,6 +71,8 @@ function main () { } } + var options = { loose: loose, includePrerelease: includePrerelease } + versions = versions.map(function (v) { return coerce ? (semver.coerce(v) || {version: v}).version : v }).filter(function (v) { @@ -77,7 +84,7 @@ function main () { for (var i = 0, l = range.length; i < l ; i ++) { versions = versions.filter(function (v) { - return semver.satisfies(v, range[i], loose) + return semver.satisfies(v, range[i], options) }) if (!versions.length) return fail() } @@ -94,11 +101,11 @@ function fail () { process.exit(1) } function success () { var compare = reverse ? "rcompare" : "compare" versions.sort(function (a, b) { - return semver[compare](a, b, loose) + return semver[compare](a, b, options) }).map(function (v) { - return semver.clean(v, loose) + return semver.clean(v, options) }).map(function (v) { - return inc ? semver.inc(v, inc, loose, identifier) : v + return inc ? semver.inc(v, inc, options, identifier) : v }).forEach(function (v,i,_) { console.log(v) }) } @@ -128,6 +135,9 @@ function help () { ,"-l --loose" ," Interpret versions and ranges loosely" ,"" + ,"-p --include-prerelease" + ," Always include prerelease versions in range matching" + ,"" ,"-c --coerce" ," Coerce a string into SemVer if possible" ," (does not imply --loose)" diff --git a/node_modules/semver/package.json b/node_modules/semver/package.json index 80915c3a..7559c62a 100644 --- a/node_modules/semver/package.json +++ b/node_modules/semver/package.json @@ -1,28 +1,30 @@ { - "_from": "semver@^5.4.1", - "_id": "semver@5.5.0", + "_from": "semver@5", + "_id": "semver@5.6.0", "_inBundle": false, - "_integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "_integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "_location": "/semver", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "semver@^5.4.1", + "raw": "semver@5", "name": "semver", "escapedName": "semver", - "rawSpec": "^5.4.1", + "rawSpec": "5", "saveSpec": null, - "fetchSpec": "^5.4.1" + "fetchSpec": "5" }, "_requiredBy": [ + "#USER", + "/", "/android-versions", "/normalize-package-data" ], - "_resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "_shasum": "dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab", - "_spec": "semver@^5.4.1", - "_where": "/Users/brodybits/Documents/cordova/cordova-android/node_modules/android-versions", + "_resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "_shasum": "7e74256fbaa49c75aa7c7a205cc22799cac80004", + "_spec": "semver@5", + "_where": "/Users/brodybits/Documents/cordova/cordova-android", "bin": { "semver": "./bin/semver" }, @@ -33,7 +35,7 @@ "deprecated": false, "description": "The semantic version parser used by npm.", "devDependencies": { - "tap": "^10.7.0" + "tap": "^12.0.1" }, "files": [ "bin", @@ -51,5 +53,5 @@ "scripts": { "test": "tap test/*.js --cov -J" }, - "version": "5.5.0" + "version": "5.6.0" } diff --git a/node_modules/semver/semver.js b/node_modules/semver/semver.js index 9cf9f6e5..0cc57350 100644 --- a/node_modules/semver/semver.js +++ b/node_modules/semver/semver.js @@ -245,7 +245,10 @@ for (var i = 0; i < R; i++) { } exports.parse = parse; -function parse(version, loose) { +function parse(version, options) { + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + if (version instanceof SemVer) return version; @@ -255,35 +258,37 @@ function parse(version, loose) { if (version.length > MAX_LENGTH) return null; - var r = loose ? re[LOOSE] : re[FULL]; + var r = options.loose ? re[LOOSE] : re[FULL]; if (!r.test(version)) return null; try { - return new SemVer(version, loose); + return new SemVer(version, options); } catch (er) { return null; } } exports.valid = valid; -function valid(version, loose) { - var v = parse(version, loose); +function valid(version, options) { + var v = parse(version, options); return v ? v.version : null; } exports.clean = clean; -function clean(version, loose) { - var s = parse(version.trim().replace(/^[=v]+/, ''), loose); +function clean(version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options); return s ? s.version : null; } exports.SemVer = SemVer; -function SemVer(version, loose) { +function SemVer(version, options) { + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } if (version instanceof SemVer) { - if (version.loose === loose) + if (version.loose === options.loose) return version; else version = version.version; @@ -295,11 +300,13 @@ function SemVer(version, loose) { throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') if (!(this instanceof SemVer)) - return new SemVer(version, loose); + return new SemVer(version, options); - debug('SemVer', version, loose); - this.loose = loose; - var m = version.trim().match(loose ? re[LOOSE] : re[FULL]); + debug('SemVer', version, options); + this.options = options; + this.loose = !!options.loose; + + var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]); if (!m) throw new TypeError('Invalid Version: ' + version); @@ -349,16 +356,16 @@ SemVer.prototype.toString = function() { }; SemVer.prototype.compare = function(other) { - debug('SemVer.compare', this.version, this.loose, other); + debug('SemVer.compare', this.version, this.options, other); if (!(other instanceof SemVer)) - other = new SemVer(other, this.loose); + other = new SemVer(other, this.options); return this.compareMain(other) || this.comparePre(other); }; SemVer.prototype.compareMain = function(other) { if (!(other instanceof SemVer)) - other = new SemVer(other, this.loose); + other = new SemVer(other, this.options); return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || @@ -367,7 +374,7 @@ SemVer.prototype.compareMain = function(other) { SemVer.prototype.comparePre = function(other) { if (!(other instanceof SemVer)) - other = new SemVer(other, this.loose); + other = new SemVer(other, this.options); // NOT having a prerelease is > having one if (this.prerelease.length && !other.prerelease.length) @@ -658,19 +665,23 @@ function cmp(a, op, b, loose) { } exports.Comparator = Comparator; -function Comparator(comp, loose) { +function Comparator(comp, options) { + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + if (comp instanceof Comparator) { - if (comp.loose === loose) + if (comp.loose === !!options.loose) return comp; else comp = comp.value; } if (!(this instanceof Comparator)) - return new Comparator(comp, loose); + return new Comparator(comp, options); - debug('comparator', comp, loose); - this.loose = loose; + debug('comparator', comp, options); + this.options = options; + this.loose = !!options.loose; this.parse(comp); if (this.semver === ANY) @@ -683,7 +694,7 @@ function Comparator(comp, loose) { var ANY = {}; Comparator.prototype.parse = function(comp) { - var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; + var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; var m = comp.match(r); if (!m) @@ -697,7 +708,7 @@ Comparator.prototype.parse = function(comp) { if (!m[2]) this.semver = ANY; else - this.semver = new SemVer(m[2], this.loose); + this.semver = new SemVer(m[2], this.options.loose); }; Comparator.prototype.toString = function() { @@ -705,30 +716,33 @@ Comparator.prototype.toString = function() { }; Comparator.prototype.test = function(version) { - debug('Comparator.test', version, this.loose); + debug('Comparator.test', version, this.options.loose); if (this.semver === ANY) return true; if (typeof version === 'string') - version = new SemVer(version, this.loose); + version = new SemVer(version, this.options); - return cmp(version, this.operator, this.semver, this.loose); + return cmp(version, this.operator, this.semver, this.options); }; -Comparator.prototype.intersects = function(comp, loose) { +Comparator.prototype.intersects = function(comp, options) { if (!(comp instanceof Comparator)) { throw new TypeError('a Comparator is required'); } + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + var rangeTmp; if (this.operator === '') { - rangeTmp = new Range(comp.value, loose); - return satisfies(this.value, rangeTmp, loose); + rangeTmp = new Range(comp.value, options); + return satisfies(this.value, rangeTmp, options); } else if (comp.operator === '') { - rangeTmp = new Range(this.value, loose); - return satisfies(comp.semver, rangeTmp, loose); + rangeTmp = new Range(this.value, options); + return satisfies(comp.semver, rangeTmp, options); } var sameDirectionIncreasing = @@ -742,11 +756,11 @@ Comparator.prototype.intersects = function(comp, loose) { (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<='); var oppositeDirectionsLessThan = - cmp(this.semver, '<', comp.semver, loose) && + cmp(this.semver, '<', comp.semver, options) && ((this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<')); var oppositeDirectionsGreaterThan = - cmp(this.semver, '>', comp.semver, loose) && + cmp(this.semver, '>', comp.semver, options) && ((this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>')); @@ -757,23 +771,29 @@ Comparator.prototype.intersects = function(comp, loose) { exports.Range = Range; -function Range(range, loose) { +function Range(range, options) { + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + if (range instanceof Range) { - if (range.loose === loose) { + if (range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease) { return range; } else { - return new Range(range.raw, loose); + return new Range(range.raw, options); } } if (range instanceof Comparator) { - return new Range(range.value, loose); + return new Range(range.value, options); } if (!(this instanceof Range)) - return new Range(range, loose); + return new Range(range, options); - this.loose = loose; + this.options = options; + this.loose = !!options.loose; + this.includePrerelease = !!options.includePrerelease // First, split based on boolean or || this.raw = range; @@ -803,9 +823,8 @@ Range.prototype.toString = function() { }; Range.prototype.parseRange = function(range) { - var loose = this.loose; + var loose = this.options.loose; range = range.trim(); - debug('range', range, loose); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]; range = range.replace(hr, hyphenReplace); @@ -828,22 +847,22 @@ Range.prototype.parseRange = function(range) { var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; var set = range.split(' ').map(function(comp) { - return parseComparator(comp, loose); - }).join(' ').split(/\s+/); - if (this.loose) { + return parseComparator(comp, this.options); + }, this).join(' ').split(/\s+/); + if (this.options.loose) { // in loose mode, throw out any that are not valid comparators set = set.filter(function(comp) { return !!comp.match(compRe); }); } set = set.map(function(comp) { - return new Comparator(comp, loose); - }); + return new Comparator(comp, this.options); + }, this); return set; }; -Range.prototype.intersects = function(range, loose) { +Range.prototype.intersects = function(range, options) { if (!(range instanceof Range)) { throw new TypeError('a Range is required'); } @@ -852,7 +871,7 @@ Range.prototype.intersects = function(range, loose) { return thisComparators.every(function(thisComparator) { return range.set.some(function(rangeComparators) { return rangeComparators.every(function(rangeComparator) { - return thisComparator.intersects(rangeComparator, loose); + return thisComparator.intersects(rangeComparator, options); }); }); }); @@ -861,8 +880,8 @@ Range.prototype.intersects = function(range, loose) { // Mostly just for testing and legacy API reasons exports.toComparators = toComparators; -function toComparators(range, loose) { - return new Range(range, loose).set.map(function(comp) { +function toComparators(range, options) { + return new Range(range, options).set.map(function(comp) { return comp.map(function(c) { return c.value; }).join(' ').trim().split(' '); @@ -872,15 +891,15 @@ function toComparators(range, loose) { // comprised of xranges, tildes, stars, and gtlt's at this point. // already replaced the hyphen ranges // turn into a set of JUST comparators. -function parseComparator(comp, loose) { - debug('comp', comp); - comp = replaceCarets(comp, loose); +function parseComparator(comp, options) { + debug('comp', comp, options); + comp = replaceCarets(comp, options); debug('caret', comp); - comp = replaceTildes(comp, loose); + comp = replaceTildes(comp, options); debug('tildes', comp); - comp = replaceXRanges(comp, loose); + comp = replaceXRanges(comp, options); debug('xrange', comp); - comp = replaceStars(comp, loose); + comp = replaceStars(comp, options); debug('stars', comp); return comp; } @@ -895,14 +914,16 @@ function isX(id) { // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 -function replaceTildes(comp, loose) { +function replaceTildes(comp, options) { return comp.trim().split(/\s+/).map(function(comp) { - return replaceTilde(comp, loose); + return replaceTilde(comp, options); }).join(' '); } -function replaceTilde(comp, loose) { - var r = loose ? re[TILDELOOSE] : re[TILDE]; +function replaceTilde(comp, options) { + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + var r = options.loose ? re[TILDELOOSE] : re[TILDE]; return comp.replace(r, function(_, M, m, p, pr) { debug('tilde', comp, _, M, m, p, pr); var ret; @@ -936,15 +957,17 @@ function replaceTilde(comp, loose) { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 // ^1.2.3 --> >=1.2.3 <2.0.0 // ^1.2.0 --> >=1.2.0 <2.0.0 -function replaceCarets(comp, loose) { +function replaceCarets(comp, options) { return comp.trim().split(/\s+/).map(function(comp) { - return replaceCaret(comp, loose); + return replaceCaret(comp, options); }).join(' '); } -function replaceCaret(comp, loose) { - debug('caret', comp, loose); - var r = loose ? re[CARETLOOSE] : re[CARET]; +function replaceCaret(comp, options) { + debug('caret', comp, options); + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + var r = options.loose ? re[CARETLOOSE] : re[CARET]; return comp.replace(r, function(_, M, m, p, pr) { debug('caret', comp, _, M, m, p, pr); var ret; @@ -991,16 +1014,18 @@ function replaceCaret(comp, loose) { }); } -function replaceXRanges(comp, loose) { - debug('replaceXRanges', comp, loose); +function replaceXRanges(comp, options) { + debug('replaceXRanges', comp, options); return comp.split(/\s+/).map(function(comp) { - return replaceXRange(comp, loose); + return replaceXRange(comp, options); }).join(' '); } -function replaceXRange(comp, loose) { +function replaceXRange(comp, options) { comp = comp.trim(); - var r = loose ? re[XRANGELOOSE] : re[XRANGE]; + if (!options || typeof options !== 'object') + options = { loose: !!options, includePrerelease: false } + var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]; return comp.replace(r, function(ret, gtlt, M, m, p, pr) { debug('xRange', comp, ret, gtlt, M, m, p, pr); var xM = isX(M); @@ -1064,8 +1089,8 @@ function replaceXRange(comp, loose) { // Because * is AND-ed with everything else in the comparator, // and '' means "any version", just remove the *s entirely. -function replaceStars(comp, loose) { - debug('replaceStars', comp, loose); +function replaceStars(comp, options) { + debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets! return comp.trim().replace(re[STAR], ''); } @@ -1109,22 +1134,25 @@ Range.prototype.test = function(version) { return false; if (typeof version === 'string') - version = new SemVer(version, this.loose); + version = new SemVer(version, this.options); for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version)) + if (testSet(this.set[i], version, this.options)) return true; } return false; }; -function testSet(set, version) { +function testSet(set, version, options) { for (var i = 0; i < set.length; i++) { if (!set[i].test(version)) return false; } - if (version.prerelease.length) { + if (!options) + options = {} + + if (version.prerelease.length && !options.includePrerelease) { // Find the set of versions that are allowed to have prereleases // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 // That should allow `1.2.3-pr.2` to pass. @@ -1152,9 +1180,9 @@ function testSet(set, version) { } exports.satisfies = satisfies; -function satisfies(version, range, loose) { +function satisfies(version, range, options) { try { - range = new Range(range, loose); + range = new Range(range, options); } catch (er) { return false; } @@ -1162,19 +1190,19 @@ function satisfies(version, range, loose) { } exports.maxSatisfying = maxSatisfying; -function maxSatisfying(versions, range, loose) { +function maxSatisfying(versions, range, options) { var max = null; var maxSV = null; try { - var rangeObj = new Range(range, loose); + var rangeObj = new Range(range, options); } catch (er) { return null; } versions.forEach(function (v) { - if (rangeObj.test(v)) { // satisfies(v, range, loose) + if (rangeObj.test(v)) { // satisfies(v, range, options) if (!max || maxSV.compare(v) === -1) { // compare(max, v, true) max = v; - maxSV = new SemVer(max, loose); + maxSV = new SemVer(max, options); } } }) @@ -1182,19 +1210,19 @@ function maxSatisfying(versions, range, loose) { } exports.minSatisfying = minSatisfying; -function minSatisfying(versions, range, loose) { +function minSatisfying(versions, range, options) { var min = null; var minSV = null; try { - var rangeObj = new Range(range, loose); + var rangeObj = new Range(range, options); } catch (er) { return null; } versions.forEach(function (v) { - if (rangeObj.test(v)) { // satisfies(v, range, loose) + if (rangeObj.test(v)) { // satisfies(v, range, options) if (!min || minSV.compare(v) === 1) { // compare(min, v, true) min = v; - minSV = new SemVer(min, loose); + minSV = new SemVer(min, options); } } }) @@ -1202,11 +1230,11 @@ function minSatisfying(versions, range, loose) { } exports.validRange = validRange; -function validRange(range, loose) { +function validRange(range, options) { try { // Return '*' instead of '' so that truthiness works. // This will throw if it's invalid anyway - return new Range(range, loose).range || '*'; + return new Range(range, options).range || '*'; } catch (er) { return null; } @@ -1214,20 +1242,20 @@ function validRange(range, loose) { // Determine if version is less than all the versions possible in the range exports.ltr = ltr; -function ltr(version, range, loose) { - return outside(version, range, '<', loose); +function ltr(version, range, options) { + return outside(version, range, '<', options); } // Determine if version is greater than all the versions possible in the range. exports.gtr = gtr; -function gtr(version, range, loose) { - return outside(version, range, '>', loose); +function gtr(version, range, options) { + return outside(version, range, '>', options); } exports.outside = outside; -function outside(version, range, hilo, loose) { - version = new SemVer(version, loose); - range = new Range(range, loose); +function outside(version, range, hilo, options) { + version = new SemVer(version, options); + range = new Range(range, options); var gtfn, ltefn, ltfn, comp, ecomp; switch (hilo) { @@ -1250,7 +1278,7 @@ function outside(version, range, hilo, loose) { } // If it satisifes the range it is not outside - if (satisfies(version, range, loose)) { + if (satisfies(version, range, options)) { return false; } @@ -1269,9 +1297,9 @@ function outside(version, range, hilo, loose) { } high = high || comparator; low = low || comparator; - if (gtfn(comparator.semver, high.semver, loose)) { + if (gtfn(comparator.semver, high.semver, options)) { high = comparator; - } else if (ltfn(comparator.semver, low.semver, loose)) { + } else if (ltfn(comparator.semver, low.semver, options)) { low = comparator; } }); @@ -1295,15 +1323,15 @@ function outside(version, range, hilo, loose) { } exports.prerelease = prerelease; -function prerelease(version, loose) { - var parsed = parse(version, loose); +function prerelease(version, options) { + var parsed = parse(version, options); return (parsed && parsed.prerelease.length) ? parsed.prerelease : null; } exports.intersects = intersects; -function intersects(r1, r2, loose) { - r1 = new Range(r1, loose) - r2 = new Range(r2, loose) +function intersects(r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) return r1.intersects(r2) } diff --git a/package.json b/package.json index 0b2eab74..53650c0c 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ "license": "Apache-2.0", "dependencies": { "android-versions": "1.4.0", - "base64-js": "1.2.0", - "big-integer": "1.6.32", + "base64-js": "1.3.0", + "big-integer": "1.6.36", "cordova-common": "2.2.5", "elementtree": "0.1.6", "glob": "5.0.15", @@ -41,7 +41,7 @@ "properties-parser": "0.2.3", "q": "1.4.1", "sax": "0.3.5", - "semver": "5.5.0", + "semver": "5.6.0", "shelljs": "0.5.3", "xmlbuilder": "8.2.2" },