@burstjs/util
Advanced tools
Comparing version 0.5.0-beta.3 to 0.5.0-beta.4
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
# 0.5.0 | ||
## 0.5.0 | ||
### Added | ||
- New `BurstTime` value object class | ||
- facilitates usage of Burst Timestamps | ||
- New `BurstValue` value object class | ||
- facilitates usage of BURST/Planck | ||
- increased numeric precision | ||
- New `createDeeplink` and `parseDeeplink` methods | ||
@@ -11,4 +17,14 @@ - CIP22 implementation | ||
- `convertBase64StringToString` | ||
- New Symbols for BURST (Ƀ) and Planck (ƀ) | ||
- `BurstSymbol` | ||
- `BurstPlanckSymbol` | ||
### Deprecated | ||
- `convertBurstTimeToDate` and `convertDateToBurstTime` | ||
- Use `BurstTime` instead | ||
- `convertNumberToNQTString`, `convertNQTStringToNumber`, and `sumNQTStringToNumber` | ||
- Use `BurstValue` instead | ||
# 0.4.0 | ||
## 0.4.0 | ||
- Changed License: From GPL-3.0 to Apache 2.0 | ||
@@ -15,0 +31,0 @@ |
@@ -1,6 +0,4 @@ | ||
var b$util = (function (exports, buffer) { | ||
var b$util = (function (exports) { | ||
'use strict'; | ||
buffer = buffer && buffer.hasOwnProperty('default') ? buffer['default'] : buffer; | ||
var GenesisBlockTime = Date.UTC(2014, 7, 11, 2, 0, 0, 0) / 1000; | ||
@@ -381,11 +379,12 @@ var initialCodeword = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
// existing version for noConflict() | ||
global = global || {}; | ||
var _Base64 = global.Base64; | ||
var version = "2.4.8"; | ||
var version = "2.5.1"; | ||
// if node.js and NOT React Native, we use Buffer | ||
var buffer$1; | ||
var buffer; | ||
if ( module.exports) { | ||
if (typeof navigator != 'undefined' && navigator.product == 'ReactNative') ; else { | ||
try { | ||
buffer$1 = buffer.Buffer; | ||
} catch (err) {} | ||
try { | ||
buffer = eval("require('buffer').Buffer"); | ||
} catch (err) { | ||
buffer = undefined; | ||
} | ||
@@ -444,10 +443,10 @@ } | ||
}; | ||
var _encode = buffer$1 ? | ||
buffer$1.from && Uint8Array && buffer$1.from !== Uint8Array.from | ||
var _encode = buffer ? | ||
buffer.from && Uint8Array && buffer.from !== Uint8Array.from | ||
? function (u) { | ||
return (u.constructor === buffer$1.constructor ? u : buffer$1.from(u)) | ||
return (u.constructor === buffer.constructor ? u : buffer.from(u)) | ||
.toString('base64') | ||
} | ||
: function (u) { | ||
return (u.constructor === buffer$1.constructor ? u : new buffer$1(u)) | ||
return (u.constructor === buffer.constructor ? u : new buffer(u)) | ||
.toString('base64') | ||
@@ -512,18 +511,21 @@ } | ||
}; | ||
var atob = global.atob ? function(a) { | ||
var _atob = global.atob ? function(a) { | ||
return global.atob(a); | ||
} : function(a){ | ||
return a.replace(/[\s\S]{1,4}/g, cb_decode); | ||
return a.replace(/\S{1,4}/g, cb_decode); | ||
}; | ||
var _decode = buffer$1 ? | ||
buffer$1.from && Uint8Array && buffer$1.from !== Uint8Array.from | ||
var atob = function(a) { | ||
return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, '')); | ||
}; | ||
var _decode = buffer ? | ||
buffer.from && Uint8Array && buffer.from !== Uint8Array.from | ||
? function(a) { | ||
return (a.constructor === buffer$1.constructor | ||
? a : buffer$1.from(a, 'base64')).toString(); | ||
return (a.constructor === buffer.constructor | ||
? a : buffer.from(a, 'base64')).toString(); | ||
} | ||
: function(a) { | ||
return (a.constructor === buffer$1.constructor | ||
? a : new buffer$1(a, 'base64')).toString(); | ||
return (a.constructor === buffer.constructor | ||
? a : new buffer(a, 'base64')).toString(); | ||
} | ||
: function(a) { return btou(atob(a)) }; | ||
: function(a) { return btou(_atob(a)) }; | ||
var decode = function(a){ | ||
@@ -552,3 +554,4 @@ return _decode( | ||
decode: decode, | ||
noConflict: noConflict | ||
noConflict: noConflict, | ||
__buffer__: buffer | ||
}; | ||
@@ -699,2 +702,1133 @@ // if ES5 is available, make Base64.extendString() available | ||
var BurstSymbol = 'Ƀ'; | ||
var BurstPlanckSymbol = 'ƀ'; | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
var BurstTime = | ||
/*#__PURE__*/ | ||
function () { | ||
function BurstTime(burstTimestamp) { | ||
_classCallCheck(this, BurstTime); | ||
this._burstTimestamp = burstTimestamp; | ||
} | ||
_createClass(BurstTime, [{ | ||
key: "getBurstTimestamp", | ||
value: function getBurstTimestamp() { | ||
return this._burstTimestamp; | ||
} | ||
}, { | ||
key: "setBurstTimestamp", | ||
value: function setBurstTimestamp(burstTimestamp) { | ||
this._burstTimestamp = burstTimestamp; | ||
} | ||
}, { | ||
key: "getEpoch", | ||
value: function getEpoch() { | ||
return (GenesisBlockTime + this._burstTimestamp) * 1000; | ||
} | ||
}, { | ||
key: "getDate", | ||
value: function getDate() { | ||
return new Date(this.getEpoch()); | ||
} | ||
}, { | ||
key: "setDate", | ||
value: function setDate(date) { | ||
this._burstTimestamp = Math.round(date.getTime() / 1000) - GenesisBlockTime; | ||
} | ||
}, { | ||
key: "equals", | ||
value: function equals(burstTime) { | ||
return this._burstTimestamp === burstTime._burstTimestamp; | ||
} | ||
}, { | ||
key: "before", | ||
value: function before(burstTime) { | ||
return this._burstTimestamp < burstTime._burstTimestamp; | ||
} | ||
}, { | ||
key: "after", | ||
value: function after(burstTime) { | ||
return this._burstTimestamp > burstTime._burstTimestamp; | ||
} | ||
}], [{ | ||
key: "fromBurstTimestamp", | ||
value: function fromBurstTimestamp(burstTimestamp) { | ||
return new BurstTime(burstTimestamp); | ||
} | ||
}, { | ||
key: "fromDate", | ||
value: function fromDate(date) { | ||
var burstTime = new BurstTime(0); | ||
burstTime.setDate(date); | ||
return burstTime; | ||
} | ||
}]); | ||
return BurstTime; | ||
}(); | ||
/* | ||
* big.js v5.2.2 | ||
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic. | ||
* Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com> | ||
* https://github.com/MikeMcl/big.js/LICENCE | ||
*/ | ||
/************************************** EDITABLE DEFAULTS *****************************************/ | ||
// The default values below must be integers within the stated ranges. | ||
/* | ||
* The maximum number of decimal places (DP) of the results of operations involving division: | ||
* div and sqrt, and pow with negative exponents. | ||
*/ | ||
var DP = 20, // 0 to MAX_DP | ||
/* | ||
* The rounding mode (RM) used when rounding to the above decimal places. | ||
* | ||
* 0 Towards zero (i.e. truncate, no rounding). (ROUND_DOWN) | ||
* 1 To nearest neighbour. If equidistant, round up. (ROUND_HALF_UP) | ||
* 2 To nearest neighbour. If equidistant, to even. (ROUND_HALF_EVEN) | ||
* 3 Away from zero. (ROUND_UP) | ||
*/ | ||
RM = 1, // 0, 1, 2 or 3 | ||
// The maximum value of DP and Big.DP. | ||
MAX_DP = 1E6, // 0 to 1000000 | ||
// The maximum magnitude of the exponent argument to the pow method. | ||
MAX_POWER = 1E6, // 1 to 1000000 | ||
/* | ||
* The negative exponent (NE) at and beneath which toString returns exponential notation. | ||
* (JavaScript numbers: -7) | ||
* -1000000 is the minimum recommended exponent value of a Big. | ||
*/ | ||
NE = -7, // 0 to -1000000 | ||
/* | ||
* The positive exponent (PE) at and above which toString returns exponential notation. | ||
* (JavaScript numbers: 21) | ||
* 1000000 is the maximum recommended exponent value of a Big. | ||
* (This limit is not enforced or checked.) | ||
*/ | ||
PE = 21, // 0 to 1000000 | ||
/**************************************************************************************************/ | ||
// Error messages. | ||
NAME = '[big.js] ', | ||
INVALID = NAME + 'Invalid ', | ||
INVALID_DP = INVALID + 'decimal places', | ||
INVALID_RM = INVALID + 'rounding mode', | ||
DIV_BY_ZERO = NAME + 'Division by zero', | ||
// The shared prototype object. | ||
P = {}, | ||
UNDEFINED = void 0, | ||
NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i; | ||
/* | ||
* Create and return a Big constructor. | ||
* | ||
*/ | ||
function _Big_() { | ||
/* | ||
* The Big constructor and exported function. | ||
* Create and return a new instance of a Big number object. | ||
* | ||
* n {number|string|Big} A numeric value. | ||
*/ | ||
function Big(n) { | ||
var x = this; | ||
// Enable constructor usage without new. | ||
if (!(x instanceof Big)) return n === UNDEFINED ? _Big_() : new Big(n); | ||
// Duplicate. | ||
if (n instanceof Big) { | ||
x.s = n.s; | ||
x.e = n.e; | ||
x.c = n.c.slice(); | ||
} else { | ||
parse(x, n); | ||
} | ||
/* | ||
* Retain a reference to this Big constructor, and shadow Big.prototype.constructor which | ||
* points to Object. | ||
*/ | ||
x.constructor = Big; | ||
} | ||
Big.prototype = P; | ||
Big.DP = DP; | ||
Big.RM = RM; | ||
Big.NE = NE; | ||
Big.PE = PE; | ||
Big.version = '5.2.2'; | ||
return Big; | ||
} | ||
/* | ||
* Parse the number or string value passed to a Big constructor. | ||
* | ||
* x {Big} A Big number instance. | ||
* n {number|string} A numeric value. | ||
*/ | ||
function parse(x, n) { | ||
var e, i, nl; | ||
// Minus zero? | ||
if (n === 0 && 1 / n < 0) n = '-0'; | ||
else if (!NUMERIC.test(n += '')) throw Error(INVALID + 'number'); | ||
// Determine sign. | ||
x.s = n.charAt(0) == '-' ? (n = n.slice(1), -1) : 1; | ||
// Decimal point? | ||
if ((e = n.indexOf('.')) > -1) n = n.replace('.', ''); | ||
// Exponential form? | ||
if ((i = n.search(/e/i)) > 0) { | ||
// Determine exponent. | ||
if (e < 0) e = i; | ||
e += +n.slice(i + 1); | ||
n = n.substring(0, i); | ||
} else if (e < 0) { | ||
// Integer. | ||
e = n.length; | ||
} | ||
nl = n.length; | ||
// Determine leading zeros. | ||
for (i = 0; i < nl && n.charAt(i) == '0';) ++i; | ||
if (i == nl) { | ||
// Zero. | ||
x.c = [x.e = 0]; | ||
} else { | ||
// Determine trailing zeros. | ||
for (; nl > 0 && n.charAt(--nl) == '0';); | ||
x.e = e - i - 1; | ||
x.c = []; | ||
// Convert string to array of digits without leading/trailing zeros. | ||
for (e = 0; i <= nl;) x.c[e++] = +n.charAt(i++); | ||
} | ||
return x; | ||
} | ||
/* | ||
* Round Big x to a maximum of dp decimal places using rounding mode rm. | ||
* Called by stringify, P.div, P.round and P.sqrt. | ||
* | ||
* x {Big} The Big to round. | ||
* dp {number} Integer, 0 to MAX_DP inclusive. | ||
* rm {number} 0, 1, 2 or 3 (DOWN, HALF_UP, HALF_EVEN, UP) | ||
* [more] {boolean} Whether the result of division was truncated. | ||
*/ | ||
function round(x, dp, rm, more) { | ||
var xc = x.c, | ||
i = x.e + dp + 1; | ||
if (i < xc.length) { | ||
if (rm === 1) { | ||
// xc[i] is the digit after the digit that may be rounded up. | ||
more = xc[i] >= 5; | ||
} else if (rm === 2) { | ||
more = xc[i] > 5 || xc[i] == 5 && | ||
(more || i < 0 || xc[i + 1] !== UNDEFINED || xc[i - 1] & 1); | ||
} else if (rm === 3) { | ||
more = more || !!xc[0]; | ||
} else { | ||
more = false; | ||
if (rm !== 0) throw Error(INVALID_RM); | ||
} | ||
if (i < 1) { | ||
xc.length = 1; | ||
if (more) { | ||
// 1, 0.1, 0.01, 0.001, 0.0001 etc. | ||
x.e = -dp; | ||
xc[0] = 1; | ||
} else { | ||
// Zero. | ||
xc[0] = x.e = 0; | ||
} | ||
} else { | ||
// Remove any digits after the required decimal places. | ||
xc.length = i--; | ||
// Round up? | ||
if (more) { | ||
// Rounding up may mean the previous digit has to be rounded up. | ||
for (; ++xc[i] > 9;) { | ||
xc[i] = 0; | ||
if (!i--) { | ||
++x.e; | ||
xc.unshift(1); | ||
} | ||
} | ||
} | ||
// Remove trailing zeros. | ||
for (i = xc.length; !xc[--i];) xc.pop(); | ||
} | ||
} else if (rm < 0 || rm > 3 || rm !== ~~rm) { | ||
throw Error(INVALID_RM); | ||
} | ||
return x; | ||
} | ||
/* | ||
* Return a string representing the value of Big x in normal or exponential notation. | ||
* Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf. | ||
* | ||
* x {Big} | ||
* id? {number} Caller id. | ||
* 1 toExponential | ||
* 2 toFixed | ||
* 3 toPrecision | ||
* 4 valueOf | ||
* n? {number|undefined} Caller's argument. | ||
* k? {number|undefined} | ||
*/ | ||
function stringify(x, id, n, k) { | ||
var e, s, | ||
Big = x.constructor, | ||
z = !x.c[0]; | ||
if (n !== UNDEFINED) { | ||
if (n !== ~~n || n < (id == 3) || n > MAX_DP) { | ||
throw Error(id == 3 ? INVALID + 'precision' : INVALID_DP); | ||
} | ||
x = new Big(x); | ||
// The index of the digit that may be rounded up. | ||
n = k - x.e; | ||
// Round? | ||
if (x.c.length > ++k) round(x, n, Big.RM); | ||
// toFixed: recalculate k as x.e may have changed if value rounded up. | ||
if (id == 2) k = x.e + n + 1; | ||
// Append zeros? | ||
for (; x.c.length < k;) x.c.push(0); | ||
} | ||
e = x.e; | ||
s = x.c.join(''); | ||
n = s.length; | ||
// Exponential notation? | ||
if (id != 2 && (id == 1 || id == 3 && k <= e || e <= Big.NE || e >= Big.PE)) { | ||
s = s.charAt(0) + (n > 1 ? '.' + s.slice(1) : '') + (e < 0 ? 'e' : 'e+') + e; | ||
// Normal notation. | ||
} else if (e < 0) { | ||
for (; ++e;) s = '0' + s; | ||
s = '0.' + s; | ||
} else if (e > 0) { | ||
if (++e > n) for (e -= n; e--;) s += '0'; | ||
else if (e < n) s = s.slice(0, e) + '.' + s.slice(e); | ||
} else if (n > 1) { | ||
s = s.charAt(0) + '.' + s.slice(1); | ||
} | ||
return x.s < 0 && (!z || id == 4) ? '-' + s : s; | ||
} | ||
// Prototype/instance methods | ||
/* | ||
* Return a new Big whose value is the absolute value of this Big. | ||
*/ | ||
P.abs = function () { | ||
var x = new this.constructor(this); | ||
x.s = 1; | ||
return x; | ||
}; | ||
/* | ||
* Return 1 if the value of this Big is greater than the value of Big y, | ||
* -1 if the value of this Big is less than the value of Big y, or | ||
* 0 if they have the same value. | ||
*/ | ||
P.cmp = function (y) { | ||
var isneg, | ||
x = this, | ||
xc = x.c, | ||
yc = (y = new x.constructor(y)).c, | ||
i = x.s, | ||
j = y.s, | ||
k = x.e, | ||
l = y.e; | ||
// Either zero? | ||
if (!xc[0] || !yc[0]) return !xc[0] ? !yc[0] ? 0 : -j : i; | ||
// Signs differ? | ||
if (i != j) return i; | ||
isneg = i < 0; | ||
// Compare exponents. | ||
if (k != l) return k > l ^ isneg ? 1 : -1; | ||
j = (k = xc.length) < (l = yc.length) ? k : l; | ||
// Compare digit by digit. | ||
for (i = -1; ++i < j;) { | ||
if (xc[i] != yc[i]) return xc[i] > yc[i] ^ isneg ? 1 : -1; | ||
} | ||
// Compare lengths. | ||
return k == l ? 0 : k > l ^ isneg ? 1 : -1; | ||
}; | ||
/* | ||
* Return a new Big whose value is the value of this Big divided by the value of Big y, rounded, | ||
* if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM. | ||
*/ | ||
P.div = function (y) { | ||
var x = this, | ||
Big = x.constructor, | ||
a = x.c, // dividend | ||
b = (y = new Big(y)).c, // divisor | ||
k = x.s == y.s ? 1 : -1, | ||
dp = Big.DP; | ||
if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP); | ||
// Divisor is zero? | ||
if (!b[0]) throw Error(DIV_BY_ZERO); | ||
// Dividend is 0? Return +-0. | ||
if (!a[0]) return new Big(k * 0); | ||
var bl, bt, n, cmp, ri, | ||
bz = b.slice(), | ||
ai = bl = b.length, | ||
al = a.length, | ||
r = a.slice(0, bl), // remainder | ||
rl = r.length, | ||
q = y, // quotient | ||
qc = q.c = [], | ||
qi = 0, | ||
d = dp + (q.e = x.e - y.e) + 1; // number of digits of the result | ||
q.s = k; | ||
k = d < 0 ? 0 : d; | ||
// Create version of divisor with leading zero. | ||
bz.unshift(0); | ||
// Add zeros to make remainder as long as divisor. | ||
for (; rl++ < bl;) r.push(0); | ||
do { | ||
// n is how many times the divisor goes into current remainder. | ||
for (n = 0; n < 10; n++) { | ||
// Compare divisor and remainder. | ||
if (bl != (rl = r.length)) { | ||
cmp = bl > rl ? 1 : -1; | ||
} else { | ||
for (ri = -1, cmp = 0; ++ri < bl;) { | ||
if (b[ri] != r[ri]) { | ||
cmp = b[ri] > r[ri] ? 1 : -1; | ||
break; | ||
} | ||
} | ||
} | ||
// If divisor < remainder, subtract divisor from remainder. | ||
if (cmp < 0) { | ||
// Remainder can't be more than 1 digit longer than divisor. | ||
// Equalise lengths using divisor with extra leading zero? | ||
for (bt = rl == bl ? b : bz; rl;) { | ||
if (r[--rl] < bt[rl]) { | ||
ri = rl; | ||
for (; ri && !r[--ri];) r[ri] = 9; | ||
--r[ri]; | ||
r[rl] += 10; | ||
} | ||
r[rl] -= bt[rl]; | ||
} | ||
for (; !r[0];) r.shift(); | ||
} else { | ||
break; | ||
} | ||
} | ||
// Add the digit n to the result array. | ||
qc[qi++] = cmp ? n : ++n; | ||
// Update the remainder. | ||
if (r[0] && cmp) r[rl] = a[ai] || 0; | ||
else r = [a[ai]]; | ||
} while ((ai++ < al || r[0] !== UNDEFINED) && k--); | ||
// Leading zero? Do not remove if result is simply zero (qi == 1). | ||
if (!qc[0] && qi != 1) { | ||
// There can't be more than one zero. | ||
qc.shift(); | ||
q.e--; | ||
} | ||
// Round? | ||
if (qi > d) round(q, dp, Big.RM, r[0] !== UNDEFINED); | ||
return q; | ||
}; | ||
/* | ||
* Return true if the value of this Big is equal to the value of Big y, otherwise return false. | ||
*/ | ||
P.eq = function (y) { | ||
return !this.cmp(y); | ||
}; | ||
/* | ||
* Return true if the value of this Big is greater than the value of Big y, otherwise return | ||
* false. | ||
*/ | ||
P.gt = function (y) { | ||
return this.cmp(y) > 0; | ||
}; | ||
/* | ||
* Return true if the value of this Big is greater than or equal to the value of Big y, otherwise | ||
* return false. | ||
*/ | ||
P.gte = function (y) { | ||
return this.cmp(y) > -1; | ||
}; | ||
/* | ||
* Return true if the value of this Big is less than the value of Big y, otherwise return false. | ||
*/ | ||
P.lt = function (y) { | ||
return this.cmp(y) < 0; | ||
}; | ||
/* | ||
* Return true if the value of this Big is less than or equal to the value of Big y, otherwise | ||
* return false. | ||
*/ | ||
P.lte = function (y) { | ||
return this.cmp(y) < 1; | ||
}; | ||
/* | ||
* Return a new Big whose value is the value of this Big minus the value of Big y. | ||
*/ | ||
P.minus = P.sub = function (y) { | ||
var i, j, t, xlty, | ||
x = this, | ||
Big = x.constructor, | ||
a = x.s, | ||
b = (y = new Big(y)).s; | ||
// Signs differ? | ||
if (a != b) { | ||
y.s = -b; | ||
return x.plus(y); | ||
} | ||
var xc = x.c.slice(), | ||
xe = x.e, | ||
yc = y.c, | ||
ye = y.e; | ||
// Either zero? | ||
if (!xc[0] || !yc[0]) { | ||
// y is non-zero? x is non-zero? Or both are zero. | ||
return yc[0] ? (y.s = -b, y) : new Big(xc[0] ? x : 0); | ||
} | ||
// Determine which is the bigger number. Prepend zeros to equalise exponents. | ||
if (a = xe - ye) { | ||
if (xlty = a < 0) { | ||
a = -a; | ||
t = xc; | ||
} else { | ||
ye = xe; | ||
t = yc; | ||
} | ||
t.reverse(); | ||
for (b = a; b--;) t.push(0); | ||
t.reverse(); | ||
} else { | ||
// Exponents equal. Check digit by digit. | ||
j = ((xlty = xc.length < yc.length) ? xc : yc).length; | ||
for (a = b = 0; b < j; b++) { | ||
if (xc[b] != yc[b]) { | ||
xlty = xc[b] < yc[b]; | ||
break; | ||
} | ||
} | ||
} | ||
// x < y? Point xc to the array of the bigger number. | ||
if (xlty) { | ||
t = xc; | ||
xc = yc; | ||
yc = t; | ||
y.s = -y.s; | ||
} | ||
/* | ||
* Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only | ||
* needs to start at yc.length. | ||
*/ | ||
if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--;) xc[i++] = 0; | ||
// Subtract yc from xc. | ||
for (b = i; j > a;) { | ||
if (xc[--j] < yc[j]) { | ||
for (i = j; i && !xc[--i];) xc[i] = 9; | ||
--xc[i]; | ||
xc[j] += 10; | ||
} | ||
xc[j] -= yc[j]; | ||
} | ||
// Remove trailing zeros. | ||
for (; xc[--b] === 0;) xc.pop(); | ||
// Remove leading zeros and adjust exponent accordingly. | ||
for (; xc[0] === 0;) { | ||
xc.shift(); | ||
--ye; | ||
} | ||
if (!xc[0]) { | ||
// n - n = +0 | ||
y.s = 1; | ||
// Result must be zero. | ||
xc = [ye = 0]; | ||
} | ||
y.c = xc; | ||
y.e = ye; | ||
return y; | ||
}; | ||
/* | ||
* Return a new Big whose value is the value of this Big modulo the value of Big y. | ||
*/ | ||
P.mod = function (y) { | ||
var ygtx, | ||
x = this, | ||
Big = x.constructor, | ||
a = x.s, | ||
b = (y = new Big(y)).s; | ||
if (!y.c[0]) throw Error(DIV_BY_ZERO); | ||
x.s = y.s = 1; | ||
ygtx = y.cmp(x) == 1; | ||
x.s = a; | ||
y.s = b; | ||
if (ygtx) return new Big(x); | ||
a = Big.DP; | ||
b = Big.RM; | ||
Big.DP = Big.RM = 0; | ||
x = x.div(y); | ||
Big.DP = a; | ||
Big.RM = b; | ||
return this.minus(x.times(y)); | ||
}; | ||
/* | ||
* Return a new Big whose value is the value of this Big plus the value of Big y. | ||
*/ | ||
P.plus = P.add = function (y) { | ||
var t, | ||
x = this, | ||
Big = x.constructor, | ||
a = x.s, | ||
b = (y = new Big(y)).s; | ||
// Signs differ? | ||
if (a != b) { | ||
y.s = -b; | ||
return x.minus(y); | ||
} | ||
var xe = x.e, | ||
xc = x.c, | ||
ye = y.e, | ||
yc = y.c; | ||
// Either zero? y is non-zero? x is non-zero? Or both are zero. | ||
if (!xc[0] || !yc[0]) return yc[0] ? y : new Big(xc[0] ? x : a * 0); | ||
xc = xc.slice(); | ||
// Prepend zeros to equalise exponents. | ||
// Note: reverse faster than unshifts. | ||
if (a = xe - ye) { | ||
if (a > 0) { | ||
ye = xe; | ||
t = yc; | ||
} else { | ||
a = -a; | ||
t = xc; | ||
} | ||
t.reverse(); | ||
for (; a--;) t.push(0); | ||
t.reverse(); | ||
} | ||
// Point xc to the longer array. | ||
if (xc.length - yc.length < 0) { | ||
t = yc; | ||
yc = xc; | ||
xc = t; | ||
} | ||
a = yc.length; | ||
// Only start adding at yc.length - 1 as the further digits of xc can be left as they are. | ||
for (b = 0; a; xc[a] %= 10) b = (xc[--a] = xc[a] + yc[a] + b) / 10 | 0; | ||
// No need to check for zero, as +x + +y != 0 && -x + -y != 0 | ||
if (b) { | ||
xc.unshift(b); | ||
++ye; | ||
} | ||
// Remove trailing zeros. | ||
for (a = xc.length; xc[--a] === 0;) xc.pop(); | ||
y.c = xc; | ||
y.e = ye; | ||
return y; | ||
}; | ||
/* | ||
* Return a Big whose value is the value of this Big raised to the power n. | ||
* If n is negative, round to a maximum of Big.DP decimal places using rounding | ||
* mode Big.RM. | ||
* | ||
* n {number} Integer, -MAX_POWER to MAX_POWER inclusive. | ||
*/ | ||
P.pow = function (n) { | ||
var x = this, | ||
one = new x.constructor(1), | ||
y = one, | ||
isneg = n < 0; | ||
if (n !== ~~n || n < -MAX_POWER || n > MAX_POWER) throw Error(INVALID + 'exponent'); | ||
if (isneg) n = -n; | ||
for (;;) { | ||
if (n & 1) y = y.times(x); | ||
n >>= 1; | ||
if (!n) break; | ||
x = x.times(x); | ||
} | ||
return isneg ? one.div(y) : y; | ||
}; | ||
/* | ||
* Return a new Big whose value is the value of this Big rounded using rounding mode rm | ||
* to a maximum of dp decimal places, or, if dp is negative, to an integer which is a | ||
* multiple of 10**-dp. | ||
* If dp is not specified, round to 0 decimal places. | ||
* If rm is not specified, use Big.RM. | ||
* | ||
* dp? {number} Integer, -MAX_DP to MAX_DP inclusive. | ||
* rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP) | ||
*/ | ||
P.round = function (dp, rm) { | ||
var Big = this.constructor; | ||
if (dp === UNDEFINED) dp = 0; | ||
else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP); | ||
return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm); | ||
}; | ||
/* | ||
* Return a new Big whose value is the square root of the value of this Big, rounded, if | ||
* necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM. | ||
*/ | ||
P.sqrt = function () { | ||
var r, c, t, | ||
x = this, | ||
Big = x.constructor, | ||
s = x.s, | ||
e = x.e, | ||
half = new Big(0.5); | ||
// Zero? | ||
if (!x.c[0]) return new Big(x); | ||
// Negative? | ||
if (s < 0) throw Error(NAME + 'No square root'); | ||
// Estimate. | ||
s = Math.sqrt(x + ''); | ||
// Math.sqrt underflow/overflow? | ||
// Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent. | ||
if (s === 0 || s === 1 / 0) { | ||
c = x.c.join(''); | ||
if (!(c.length + e & 1)) c += '0'; | ||
s = Math.sqrt(c); | ||
e = ((e + 1) / 2 | 0) - (e < 0 || e & 1); | ||
r = new Big((s == 1 / 0 ? '1e' : (s = s.toExponential()).slice(0, s.indexOf('e') + 1)) + e); | ||
} else { | ||
r = new Big(s); | ||
} | ||
e = r.e + (Big.DP += 4); | ||
// Newton-Raphson iteration. | ||
do { | ||
t = r; | ||
r = half.times(t.plus(x.div(t))); | ||
} while (t.c.slice(0, e).join('') !== r.c.slice(0, e).join('')); | ||
return round(r, Big.DP -= 4, Big.RM); | ||
}; | ||
/* | ||
* Return a new Big whose value is the value of this Big times the value of Big y. | ||
*/ | ||
P.times = P.mul = function (y) { | ||
var c, | ||
x = this, | ||
Big = x.constructor, | ||
xc = x.c, | ||
yc = (y = new Big(y)).c, | ||
a = xc.length, | ||
b = yc.length, | ||
i = x.e, | ||
j = y.e; | ||
// Determine sign of result. | ||
y.s = x.s == y.s ? 1 : -1; | ||
// Return signed 0 if either 0. | ||
if (!xc[0] || !yc[0]) return new Big(y.s * 0); | ||
// Initialise exponent of result as x.e + y.e. | ||
y.e = i + j; | ||
// If array xc has fewer digits than yc, swap xc and yc, and lengths. | ||
if (a < b) { | ||
c = xc; | ||
xc = yc; | ||
yc = c; | ||
j = a; | ||
a = b; | ||
b = j; | ||
} | ||
// Initialise coefficient array of result with zeros. | ||
for (c = new Array(j = a + b); j--;) c[j] = 0; | ||
// Multiply. | ||
// i is initially xc.length. | ||
for (i = b; i--;) { | ||
b = 0; | ||
// a is yc.length. | ||
for (j = a + i; j > i;) { | ||
// Current sum of products at this digit position, plus carry. | ||
b = c[j] + yc[i] * xc[j - i - 1] + b; | ||
c[j--] = b % 10; | ||
// carry | ||
b = b / 10 | 0; | ||
} | ||
c[j] = (c[j] + b) % 10; | ||
} | ||
// Increment result exponent if there is a final carry, otherwise remove leading zero. | ||
if (b) ++y.e; | ||
else c.shift(); | ||
// Remove trailing zeros. | ||
for (i = c.length; !c[--i];) c.pop(); | ||
y.c = c; | ||
return y; | ||
}; | ||
/* | ||
* Return a string representing the value of this Big in exponential notation to dp fixed decimal | ||
* places and rounded using Big.RM. | ||
* | ||
* dp? {number} Integer, 0 to MAX_DP inclusive. | ||
*/ | ||
P.toExponential = function (dp) { | ||
return stringify(this, 1, dp, dp); | ||
}; | ||
/* | ||
* Return a string representing the value of this Big in normal notation to dp fixed decimal | ||
* places and rounded using Big.RM. | ||
* | ||
* dp? {number} Integer, 0 to MAX_DP inclusive. | ||
* | ||
* (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'. | ||
* (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'. | ||
*/ | ||
P.toFixed = function (dp) { | ||
return stringify(this, 2, dp, this.e + dp); | ||
}; | ||
/* | ||
* Return a string representing the value of this Big rounded to sd significant digits using | ||
* Big.RM. Use exponential notation if sd is less than the number of digits necessary to represent | ||
* the integer part of the value in normal notation. | ||
* | ||
* sd {number} Integer, 1 to MAX_DP inclusive. | ||
*/ | ||
P.toPrecision = function (sd) { | ||
return stringify(this, 3, sd, sd - 1); | ||
}; | ||
/* | ||
* Return a string representing the value of this Big. | ||
* Return exponential notation if this Big has a positive exponent equal to or greater than | ||
* Big.PE, or a negative exponent equal to or less than Big.NE. | ||
* Omit the sign for negative zero. | ||
*/ | ||
P.toString = function () { | ||
return stringify(this); | ||
}; | ||
/* | ||
* Return a string representing the value of this Big. | ||
* Return exponential notation if this Big has a positive exponent equal to or greater than | ||
* Big.PE, or a negative exponent equal to or less than Big.NE. | ||
* Include the sign for negative zero. | ||
*/ | ||
P.valueOf = P.toJSON = function () { | ||
return stringify(this, 4); | ||
}; | ||
// Export | ||
var Big = _Big_(); | ||
Big.NE = -9; | ||
(function (BurstValueFormat) { | ||
BurstValueFormat[BurstValueFormat["PLANCK"] = 0] = "PLANCK"; | ||
BurstValueFormat[BurstValueFormat["BURST"] = 1] = "BURST"; | ||
})(exports.BurstValueFormat || (exports.BurstValueFormat = {})); | ||
var BurstValue = | ||
/*#__PURE__*/ | ||
function () { | ||
function BurstValue(planck) { | ||
_classCallCheck(this, BurstValue); | ||
this._planck = Big(planck); | ||
} | ||
_createClass(BurstValue, [{ | ||
key: "getRaw", | ||
value: function getRaw() { | ||
return Big(this._planck); | ||
} | ||
}, { | ||
key: "getPlanck", | ||
value: function getPlanck() { | ||
return this._planck.toString(); | ||
} | ||
}, { | ||
key: "setPlanck", | ||
value: function setPlanck(p) { | ||
this._planck = Big(p); | ||
} | ||
}, { | ||
key: "getBurst", | ||
value: function getBurst() { | ||
return Big(this._planck).div(1E8).toString(); | ||
} | ||
}, { | ||
key: "setBurst", | ||
value: function setBurst(b) { | ||
this._planck = Big(b).mul(1E8); | ||
} | ||
}, { | ||
key: "equals", | ||
value: function equals(burstValue) { | ||
return this._planck.eq(burstValue._planck); | ||
} | ||
}, { | ||
key: "lessOrEqual", | ||
value: function lessOrEqual(burstValue) { | ||
return this._planck.lte(burstValue._planck); | ||
} | ||
}, { | ||
key: "less", | ||
value: function less(burstValue) { | ||
return this._planck.lt(burstValue._planck); | ||
} | ||
}, { | ||
key: "greaterOrEqual", | ||
value: function greaterOrEqual(burstValue) { | ||
return this._planck.gte(burstValue._planck); | ||
} | ||
}, { | ||
key: "greater", | ||
value: function greater(burstValue) { | ||
return this._planck.gt(burstValue._planck); | ||
} | ||
}, { | ||
key: "add", | ||
value: function add(burstValue) { | ||
this._planck = this._planck.plus(burstValue._planck); | ||
return this; | ||
} | ||
}, { | ||
key: "subtract", | ||
value: function subtract(burstValue) { | ||
this._planck = this._planck.minus(burstValue._planck); | ||
return this; | ||
} | ||
}, { | ||
key: "multiply", | ||
value: function multiply(value) { | ||
this._planck = this._planck.mul(value); | ||
return this; | ||
} | ||
}, { | ||
key: "divide", | ||
value: function divide(value) { | ||
this._planck = this._planck.div(value); | ||
return this; | ||
} | ||
}, { | ||
key: "toString", | ||
value: function toString() { | ||
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : exports.BurstValueFormat.BURST; | ||
return format === exports.BurstValueFormat.BURST ? "".concat(BurstSymbol, " ").concat(this.getBurst()) : "".concat(BurstPlanckSymbol, " ").concat(this._planck); | ||
} | ||
}], [{ | ||
key: "fromPlanck", | ||
value: function fromPlanck(planck) { | ||
return new BurstValue(planck); | ||
} | ||
}, { | ||
key: "fromBurst", | ||
value: function fromBurst(burst) { | ||
var b = new BurstValue('0'); | ||
b.setBurst(typeof burst === 'number' ? burst.toString(10) : burst); | ||
return b; | ||
} | ||
}]); | ||
return BurstValue; | ||
}(); | ||
exports.BurstPlanckSymbol = BurstPlanckSymbol; | ||
exports.BurstSymbol = BurstSymbol; | ||
exports.BurstTime = BurstTime; | ||
exports.BurstValue = BurstValue; | ||
exports.convertAddressToNumericId = convertAddressToNumericId; | ||
@@ -723,2 +1857,2 @@ exports.convertBurstTimeToDate = convertBurstTimeToDate; | ||
}({}, buffer)); | ||
}({})); |
@@ -1,2 +0,2 @@ | ||
var b$util=function(r,t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e=Date.UTC(2014,7,11,2,0,0,0)/1e3,n=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o=[1,2,4,8,16,5,10,20,13,26,17,7,14,28,29,31,27,19,3,6,12,24,21,15,30,25,23,11,22,9,18,1],a=[0,0,1,18,2,5,19,11,3,29,6,27,20,8,12,23,4,10,30,17,7,22,28,26,21,25,9,16,13,14,24,15],i=[3,2,1,0,7,6,5,4,13,14,15,16,12,8,9,10,11],c="23456789ABCDEFGHJKLMNPQRSTUVWXYZ".split(""),u=function(r,t){return 0===r||0===t?0:o[(a[r]+a[t])%31]},f=function(r){0===r.indexOf("BURST-")&&(r=r.substr(6));for(var t=n.slice(),e=0,a=0;a<r.length;a++){var f=c.indexOf(r.charAt(a));if(!(f<=-1||f>c.length)){if(e>16)return!1;t[i[e]]=f,e++}}if(17!==e)return!1;for(var s=0,d=1;d<5;d++){for(var l=0,h=0;h<31;h++)if(!(h>12&&h<27)){var g=h;h>26&&(g-=14),l^=u(t[g],o[d*h%31])}s|=l}return 0===s},s=function(r){return 1e3*(e+r)},d=function(r){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=[],n=0;n<r.length;n++)e.push((r[n]>>>4).toString(16)),e.push((15&r[n]).toString(16));return t?e.join("").toUpperCase():e.join("")},l=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(0===e)return"";var n=r;if(0!==t){var o=null===e?r.length-t:e;!function(r,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(e<0)throw new Error("Start index should not be negative");if(r.length<e+t)throw new Error("Need at least "+t+" bytes to convert to an integer")}(n,o,t),n=r.slice(t,t+o)}return decodeURIComponent(escape(String.fromCharCode.apply(null,Array.from(n))))};var h,g=function(r){if(r.length%2)throw new Error("Invalid Hex String: ".concat(r));for(var t=new Uint8Array(r.length/2),e=0;e<r.length;e+=2){var n=parseInt(r.substr(e,2),16);if(Number.isNaN(n))throw new Error("Invalid Hex String: ".concat(r));t[e/2]=n}return t},v=function(r){if(null==r||""===r)throw new Error("Invalid argument");return parseFloat(r)/1e8},p=function(r){for(var t=unescape(encodeURIComponent(r)),e=new Uint8Array(t.length),n=0;n<t.length;++n)e[n]=t.charCodeAt(n);return e},A=function(r){return d(p(r))};(h=r.EncoderFormat||(r.EncoderFormat={}))[h.Text=0]="Text",h[h.Hexadecimal=1]="Hexadecimal",h[h.Base64=2]="Base64";var m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var y,S=(function(r,e){var n;n="undefined"!=typeof self?self:"undefined"!=typeof window?window:m,r.exports=function(e){var n,o=e.Base64;if(r.exports)if("undefined"!=typeof navigator&&"ReactNative"==navigator.product);else try{n=t.Buffer}catch(r){}var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=function(r){for(var t={},e=0,n=r.length;e<n;e++)t[r.charAt(e)]=e;return t}(a),c=String.fromCharCode,u=function(r){if(r.length<2){var t=r.charCodeAt(0);return t<128?r:t<2048?c(192|t>>>6)+c(128|63&t):c(224|t>>>12&15)+c(128|t>>>6&63)+c(128|63&t)}var t=65536+1024*(r.charCodeAt(0)-55296)+(r.charCodeAt(1)-56320);return c(240|t>>>18&7)+c(128|t>>>12&63)+c(128|t>>>6&63)+c(128|63&t)},f=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,s=function(r){return r.replace(f,u)},d=function(r){var t=[0,2,1][r.length%3],e=r.charCodeAt(0)<<16|(r.length>1?r.charCodeAt(1):0)<<8|(r.length>2?r.charCodeAt(2):0),n=[a.charAt(e>>>18),a.charAt(e>>>12&63),t>=2?"=":a.charAt(e>>>6&63),t>=1?"=":a.charAt(63&e)];return n.join("")},l=e.btoa?function(r){return e.btoa(r)}:function(r){return r.replace(/[\s\S]{1,3}/g,d)},h=n?n.from&&Uint8Array&&n.from!==Uint8Array.from?function(r){return(r.constructor===n.constructor?r:n.from(r)).toString("base64")}:function(r){return(r.constructor===n.constructor?r:new n(r)).toString("base64")}:function(r){return l(s(r))},g=function(r,t){return t?h(String(r)).replace(/[+\/]/g,function(r){return"+"==r?"-":"_"}).replace(/=/g,""):h(String(r))},v=new RegExp(["[À-ß][-¿]","[à-ï][-¿]{2}","[ð-÷][-¿]{3}"].join("|"),"g"),p=function(r){switch(r.length){case 4:var t=(7&r.charCodeAt(0))<<18|(63&r.charCodeAt(1))<<12|(63&r.charCodeAt(2))<<6|63&r.charCodeAt(3),e=t-65536;return c(55296+(e>>>10))+c(56320+(1023&e));case 3:return c((15&r.charCodeAt(0))<<12|(63&r.charCodeAt(1))<<6|63&r.charCodeAt(2));default:return c((31&r.charCodeAt(0))<<6|63&r.charCodeAt(1))}},A=function(r){return r.replace(v,p)},m=function(r){var t=r.length,e=t%4,n=(t>0?i[r.charAt(0)]<<18:0)|(t>1?i[r.charAt(1)]<<12:0)|(t>2?i[r.charAt(2)]<<6:0)|(t>3?i[r.charAt(3)]:0),o=[c(n>>>16),c(n>>>8&255),c(255&n)];return o.length-=[0,0,2,1][e],o.join("")},y=e.atob?function(r){return e.atob(r)}:function(r){return r.replace(/[\s\S]{1,4}/g,m)},S=n?n.from&&Uint8Array&&n.from!==Uint8Array.from?function(r){return(r.constructor===n.constructor?r:n.from(r,"base64")).toString()}:function(r){return(r.constructor===n.constructor?r:new n(r,"base64")).toString()}:function(r){return A(y(r))},b=function(r){return S(String(r).replace(/[-_]/g,function(r){return"-"==r?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))};if(e.Base64={VERSION:"2.4.8",atob:y,btoa:l,fromBase64:b,toBase64:g,utob:s,encode:g,encodeURI:function(r){return g(r,!0)},btou:A,decode:b,noConflict:function(){var r=e.Base64;return e.Base64=o,r}},"function"==typeof Object.defineProperty){var B=function(r){return{value:r,enumerable:!1,writable:!0,configurable:!0}};e.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",B(function(){return b(this)})),Object.defineProperty(String.prototype,"toBase64",B(function(r){return g(this,r)})),Object.defineProperty(String.prototype,"toBase64URI",B(function(){return g(this,!0)}))}}return e.Meteor&&(Base64=e.Base64),r.exports&&(r.exports.Base64=e.Base64),{Base64:e.Base64}}(n)}(y={exports:{}},y.exports),y.exports).Base64,b=function(r){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?S.encodeURI(r):S.encode(r)};var B=/^burst.(.+):\/\/(v.+?)\??/i;return r.convertAddressToNumericId=function(r){if(null!=r&&0!==r.trim().length&&0===r.indexOf("BURST-")){r=r.substr(6);for(var t=n.slice(),e=0,o=0;o<r.length;o++){var a=c.indexOf(r.charAt(o));if(!(a<=-1||a>c.length)){if(e>16)return;t[i[e]]=a,e++}}if(f(r)){for(var u=13,s=[],d=0;d<u;d++)s[d]=t[u-d-1];var l,h="",g=0;do{l=0,g=0;for(var v=0;v<u;v++)(g=32*g+s[v])>=10?(s[l]=Math.floor(g/10),g%=10,l+=1):l>0&&(s[l]=0,l+=1);u=l,h+=g}while(u>0);return h.split("").reverse().join("")}}},r.convertBurstTimeToDate=function(r){return new Date(s(r))},r.convertBurstTimeToEpochTime=s,r.convertByteArrayToHexString=d,r.convertByteArrayToString=l,r.convertDateToBurstTime=function(r){return Math.round(r.getTime()/1e3)-e},r.convertHexEndianess=function(r){for(var t="",e=r,n=e.length-1;n>=0;n-=2)t+=e[n-1]+e[n];return t},r.convertHexStringToByteArray=g,r.convertHexStringToDecString=function(r){var t,e,n,o=[0];for(t=0;t<r.length;t+=1){for(n=parseInt(r.charAt(t),16),e=0;e<o.length;e+=1)o[e]=16*o[e]+n,n=o[e]/10|0,o[e]%=10;for(;n>0;)o.push(n%10),n=n/10|0}return o.reverse().join("")},r.convertHexStringToString=function(r){return l(g(r))},r.convertNQTStringToNumber=v,r.convertNumberToNQTString=function(r){if(null==r)throw new Error("Invalid argument");return parseFloat(r.toString()).toFixed(8).replace(".","")},r.convertNumericIdToAddress=function(r){if(null!=r&&0!==r.trim().length){for(var t=[],e=n.slice(),o=0,a=r.length,f=0;f<a;f++)t[f]=r.charCodeAt(f)-"0".charCodeAt(0);var s=0,d=0;do{s=0,d=0;for(var l=0;l<a;l++)(s=10*s+t[l])>=32?(t[d]=s>>5,s&=31,d++):d>0&&(t[d]=0,d++);a=d,e[o]=s,o++}while(a>0);for(var h=[0,0,0,0],g=12;g>=0;g--){var v=e[g]^h[3];h[3]=h[2]^u(30,v),h[2]=h[1]^u(6,v),h[1]=h[0]^u(9,v),h[0]=u(17,v)}e[13]=h[0],e[14]=h[1],e[15]=h[2],e[16]=h[3];for(var p="BURST-",A=0;A<17;A++)p+=c[e[i[A]]],3==(3&A)&&A<13&&(p+="-");return p}},r.convertStringToByteArray=p,r.convertStringToHexString=A,r.createDeeplink=function(t){var e=t.encoderFormat,n=void 0===e?r.EncoderFormat.Base64:e,o=t.domain,a=t.action,i=t.payload,c="burst.".concat(o,"://v1");return a&&(c+="?action=".concat(a)),i&&(c+="&payload=".concat(function(t,e){var n=t;switch("string"!=typeof t&&(n=JSON.stringify(t)),e){case r.EncoderFormat.Hexadecimal:return A(n);case r.EncoderFormat.Base64:return b(n);case r.EncoderFormat.Text:default:return n}}(i,n))),c},r.isBurstAddress=function(r){return/^BURST\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{5}/i.test(r)&&f(r)},r.isValid=f,r.parseDeeplink=function(r){var t=function(){throw new Error("Invalid deeplink: "+r)},e=function(r,e){return r.startsWith(e+"=")||t(),r.split("=")[1]},n=r.match(B);n&&3===n.length||t();var o={domain:n[1],version:n[2],action:void 0,payload:void 0,decodedPayload:void 0};try{var a=r.indexOf("?");if(-1!==a){var i=r.substring(a+1).split("&");i.length>=1&&(i.length>2&&t(),o.action=e(i[0],"action"),2===i.length&&(o.payload=e(i[1],"payload")))}}catch(r){t()}return o},r.sumNQTStringToNumber=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];return t.reduce(function(r,t){return r+v(t)},0)},r}({},buffer); | ||
var b$util=function(exports){"use strict";var GenesisBlockTime=Date.UTC(2014,7,11,2,0,0,0)/1e3,initialCodeword=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],gexp=[1,2,4,8,16,5,10,20,13,26,17,7,14,28,29,31,27,19,3,6,12,24,21,15,30,25,23,11,22,9,18,1],glog=[0,0,1,18,2,5,19,11,3,29,6,27,20,8,12,23,4,10,30,17,7,22,28,26,21,25,9,16,13,14,24,15],cwmap=[3,2,1,0,7,6,5,4,13,14,15,16,12,8,9,10,11],alphabet="23456789ABCDEFGHJKLMNPQRSTUVWXYZ".split(""),base32Length=13,gmult=function(e,r){if(0===e||0===r)return 0;var t=(glog[e]+glog[r])%31;return gexp[t]},isValid=function(e){0===e.indexOf("BURST-")&&(e=e.substr(6));for(var r=initialCodeword.slice(),t=0,n=0;n<e.length;n++){var o=alphabet.indexOf(e.charAt(n));if(!(o<=-1||o>alphabet.length)){if(t>16)return!1;r[cwmap[t]]=o,t++}}if(17!==t)return!1;for(var i=0,a=1;a<5;a++){for(var u=0,c=0;c<31;c++)if(!(c>12&&c<27)){var s=c;c>26&&(s-=14),u^=gmult(r[s],gexp[a*c%31])}i|=u}return 0===i},isBurstAddress=function(e){return/^BURST\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{5}/i.test(e)&&isValid(e)},convertAddressToNumericId=function(e){if(null!=e&&0!==e.trim().length&&0===e.indexOf("BURST-")){e=e.substr(6);for(var r=initialCodeword.slice(),t=0,n=0;n<e.length;n++){var o=alphabet.indexOf(e.charAt(n));if(!(o<=-1||o>alphabet.length)){if(t>16)return;r[cwmap[t]]=o,t++}}if(isValid(e)){for(var i=base32Length,a=[],u=0;u<i;u++)a[u]=r[i-u-1];var c,s="",l=0;do{c=0,l=0;for(var f=0;f<i;f++)(l=32*l+a[f])>=10?(a[c]=Math.floor(l/10),l%=10,c+=1):c>0&&(a[c]=0,c+=1);i=c,s+=l}while(i>0);return s.split("").reverse().join("")}}},convertBurstTimeToEpochTime=function(e){return 1e3*(GenesisBlockTime+e)},convertBurstTimeToDate=function(e){return new Date(convertBurstTimeToEpochTime(e))},convertByteArrayToHexString=function(e){for(var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return r?t.join("").toUpperCase():t.join("")},convertByteArrayToString=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(0===t)return"";var n=e;if(0!==r){var o=null===t?e.length-r:t;checkBytesToIntInput(n,o,r),n=e.slice(r,r+o)}return decodeURIComponent(escape(String.fromCharCode.apply(null,Array.from(n))))};function checkBytesToIntInput(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t<0)throw new Error("Start index should not be negative");if(e.length<t+r)throw new Error("Need at least "+r+" bytes to convert to an integer");return t}var convertDateToBurstTime=function(e){return Math.round(e.getTime()/1e3)-GenesisBlockTime},convertHexEndianess=function(e){for(var r="",t=e,n=t.length-1;n>=0;n-=2)r+=t[n-1]+t[n];return r},convertHexStringToByteArray=function(e){if(e.length%2)throw new Error("Invalid Hex String: ".concat(e));for(var r=new Uint8Array(e.length/2),t=0;t<e.length;t+=2){var n=parseInt(e.substr(t,2),16);if(Number.isNaN(n))throw new Error("Invalid Hex String: ".concat(e));r[t/2]=n}return r},convertHexStringToDecString=function(e){var r,t,n,o=[0];for(r=0;r<e.length;r+=1){for(n=parseInt(e.charAt(r),16),t=0;t<o.length;t+=1)o[t]=16*o[t]+n,n=o[t]/10|0,o[t]%=10;for(;n>0;)o.push(n%10),n=n/10|0}return o.reverse().join("")},convertHexStringToString=function(e){return convertByteArrayToString(convertHexStringToByteArray(e))},convertNQTStringToNumber=function(e){if(null==e||""===e)throw new Error("Invalid argument");return parseFloat(e)/1e8},convertNumberToNQTString=function(e){if(null==e)throw new Error("Invalid argument");return parseFloat(e.toString()).toFixed(8).replace(".","")},convertNumericIdToAddress=function(e){if(null!=e&&0!==e.trim().length){for(var r=[],t=initialCodeword.slice(),n=0,o=e.length,i=0;i<o;i++)r[i]=e.charCodeAt(i)-"0".charCodeAt(0);var a=0,u=0;do{a=0,u=0;for(var c=0;c<o;c++)(a=10*a+r[c])>=32?(r[u]=a>>5,a&=31,u++):u>0&&(r[u]=0,u++);o=u,t[n]=a,n++}while(o>0);for(var s=[0,0,0,0],l=base32Length-1;l>=0;l--){var f=t[l]^s[3];s[3]=s[2]^gmult(30,f),s[2]=s[1]^gmult(6,f),s[1]=s[0]^gmult(9,f),s[0]=gmult(17,f)}t[13]=s[0],t[14]=s[1],t[15]=s[2],t[16]=s[3];for(var h="BURST-",d=0;d<17;d++)h+=alphabet[t[cwmap[d]]],3==(3&d)&&d<13&&(h+="-");return h}},convertStringToByteArray=function(e){for(var r=unescape(encodeURIComponent(e)),t=new Uint8Array(r.length),n=0;n<r.length;++n)t[n]=r.charCodeAt(n);return t},convertStringToHexString=function(e){return convertByteArrayToHexString(convertStringToByteArray(e))},EncoderFormat;EncoderFormat=exports.EncoderFormat||(exports.EncoderFormat={}),EncoderFormat[EncoderFormat.Text=0]="Text",EncoderFormat[EncoderFormat.Hexadecimal=1]="Hexadecimal",EncoderFormat[EncoderFormat.Base64=2]="Base64";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,r){return e(r={exports:{}},r.exports),r.exports}var base64=createCommonjsModule(function(module,exports){var global,factory;global="undefined"!=typeof self?self:"undefined"!=typeof window?window:commonjsGlobal,factory=function(global){global=global||{};var _Base64=global.Base64,version="2.5.1",buffer;if(module.exports)try{buffer=eval("require('buffer').Buffer")}catch(e){buffer=void 0}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64tab=function(e){for(var r={},t=0,n=e.length;t<n;t++)r[e.charAt(t)]=t;return r}(b64chars),fromCharCode=String.fromCharCode,cb_utob=function(e){if(e.length<2)return(r=e.charCodeAt(0))<128?e:r<2048?fromCharCode(192|r>>>6)+fromCharCode(128|63&r):fromCharCode(224|r>>>12&15)+fromCharCode(128|r>>>6&63)+fromCharCode(128|63&r);var r=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return fromCharCode(240|r>>>18&7)+fromCharCode(128|r>>>12&63)+fromCharCode(128|r>>>6&63)+fromCharCode(128|63&r)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=function(e){return e.replace(re_utob,cb_utob)},cb_encode=function(e){var r=[0,2,1][e.length%3],t=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[b64chars.charAt(t>>>18),b64chars.charAt(t>>>12&63),r>=2?"=":b64chars.charAt(t>>>6&63),r>=1?"=":b64chars.charAt(63&t)].join("")},btoa=global.btoa?function(e){return global.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,cb_encode)},_encode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e)).toString("base64")}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e)).toString("base64")}:function(e){return btoa(utob(e))},encode=function(e,r){return r?_encode(String(e)).replace(/[+\/]/g,function(e){return"+"==e?"-":"_"}).replace(/=/g,""):_encode(String(e))},encodeURI=function(e){return encode(e,!0)},re_btou=new RegExp(["[À-ß][-¿]","[à-ï][-¿]{2}","[ð-÷][-¿]{3}"].join("|"),"g"),cb_btou=function(e){switch(e.length){case 4:var r=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return fromCharCode(55296+(r>>>10))+fromCharCode(56320+(1023&r));case 3:return fromCharCode((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fromCharCode((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},btou=function(e){return e.replace(re_btou,cb_btou)},cb_decode=function(e){var r=e.length,t=r%4,n=(r>0?b64tab[e.charAt(0)]<<18:0)|(r>1?b64tab[e.charAt(1)]<<12:0)|(r>2?b64tab[e.charAt(2)]<<6:0)|(r>3?b64tab[e.charAt(3)]:0),o=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(255&n)];return o.length-=[0,0,2,1][t],o.join("")},_atob=global.atob?function(e){return global.atob(e)}:function(e){return e.replace(/\S{1,4}/g,cb_decode)},atob=function(e){return _atob(String(e).replace(/[^A-Za-z0-9\+\/]/g,""))},_decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e,"base64")).toString()}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e,"base64")).toString()}:function(e){return btou(_atob(e))},decode=function(e){return _decode(String(e).replace(/[-_]/g,function(e){return"-"==e?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))},noConflict=function(){var e=global.Base64;return global.Base64=_Base64,e};if(global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer},"function"==typeof Object.defineProperty){var noEnum=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum(function(){return decode(this)})),Object.defineProperty(String.prototype,"toBase64",noEnum(function(e){return encode(this,e)})),Object.defineProperty(String.prototype,"toBase64URI",noEnum(function(){return encode(this,!0)}))}}return global.Meteor&&(Base64=global.Base64),module.exports&&(module.exports.Base64=global.Base64),{Base64:global.Base64}},module.exports=factory(global)}),base64_1=base64.Base64,convertStringToBase64String=function(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?base64_1.encodeURI(e):base64_1.encode(e)};function encodePayload(e,r){var t=e;switch("string"!=typeof e&&(t=JSON.stringify(e)),r){case exports.EncoderFormat.Hexadecimal:return convertStringToHexString(t);case exports.EncoderFormat.Base64:return convertStringToBase64String(t);case exports.EncoderFormat.Text:default:return t}}var createDeeplink=function(e){var r=e.encoderFormat,t=void 0===r?exports.EncoderFormat.Base64:r,n=e.domain,o=e.action,i=e.payload,a="burst.".concat(n,"://v1");return o&&(a+="?action=".concat(o)),i&&(a+="&payload=".concat(encodePayload(i,t))),a},MandatoryPattern=/^burst.(.+):\/\/(v.+?)\??/i,parseDeeplink=function(e){var r=function(){throw new Error("Invalid deeplink: "+e)},t=function(e,t){return e.startsWith(t+"=")||r(),e.split("=")[1]},n=e.match(MandatoryPattern);n&&3===n.length||r();var o={domain:n[1],version:n[2],action:void 0,payload:void 0,decodedPayload:void 0};try{var i=e.indexOf("?");if(-1!==i){var a=e.substring(i+1).split("&");a.length>=1&&(a.length>2&&r(),o.action=t(a[0],"action"),2===a.length&&(o.payload=t(a[1],"payload")))}}catch(e){r()}return o};function sumNQTStringToNumber(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return r.reduce(function(e,r){return e+convertNQTStringToNumber(r)},0)}var BurstSymbol="Ƀ",BurstPlanckSymbol="ƀ";function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}var BurstTime=function(){function e(r){_classCallCheck(this,e),this._burstTimestamp=r}return _createClass(e,[{key:"getBurstTimestamp",value:function(){return this._burstTimestamp}},{key:"setBurstTimestamp",value:function(e){this._burstTimestamp=e}},{key:"getEpoch",value:function(){return 1e3*(GenesisBlockTime+this._burstTimestamp)}},{key:"getDate",value:function(){return new Date(this.getEpoch())}},{key:"setDate",value:function(e){this._burstTimestamp=Math.round(e.getTime()/1e3)-GenesisBlockTime}},{key:"equals",value:function(e){return this._burstTimestamp===e._burstTimestamp}},{key:"before",value:function(e){return this._burstTimestamp<e._burstTimestamp}},{key:"after",value:function(e){return this._burstTimestamp>e._burstTimestamp}}],[{key:"fromBurstTimestamp",value:function(r){return new e(r)}},{key:"fromDate",value:function(r){var t=new e(0);return t.setDate(r),t}}]),e}(),DP=20,RM=1,MAX_DP=1e6,MAX_POWER=1e6,NE=-7,PE=21,NAME="[big.js] ",INVALID=NAME+"Invalid ",INVALID_DP=INVALID+"decimal places",INVALID_RM=INVALID+"rounding mode",DIV_BY_ZERO=NAME+"Division by zero",P={},UNDEFINED=void 0,NUMERIC=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function _Big_(){function e(r){var t=this;if(!(t instanceof e))return r===UNDEFINED?_Big_():new e(r);r instanceof e?(t.s=r.s,t.e=r.e,t.c=r.c.slice()):parse(t,r),t.constructor=e}return e.prototype=P,e.DP=DP,e.RM=RM,e.NE=NE,e.PE=PE,e.version="5.2.2",e}function parse(e,r){var t,n,o;if(0===r&&1/r<0)r="-0";else if(!NUMERIC.test(r+=""))throw Error(INVALID+"number");for(e.s="-"==r.charAt(0)?(r=r.slice(1),-1):1,(t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),o=r.length,n=0;n<o&&"0"==r.charAt(n);)++n;if(n==o)e.c=[e.e=0];else{for(;o>0&&"0"==r.charAt(--o););for(e.e=t-n-1,e.c=[],t=0;n<=o;)e.c[t++]=+r.charAt(n++)}return e}function round(e,r,t,n){var o=e.c,i=e.e+r+1;if(i<o.length){if(1===t)n=o[i]>=5;else if(2===t)n=o[i]>5||5==o[i]&&(n||i<0||o[i+1]!==UNDEFINED||1&o[i-1]);else if(3===t)n=n||!!o[0];else if(n=!1,0!==t)throw Error(INVALID_RM);if(i<1)o.length=1,n?(e.e=-r,o[0]=1):o[0]=e.e=0;else{if(o.length=i--,n)for(;++o[i]>9;)o[i]=0,i--||(++e.e,o.unshift(1));for(i=o.length;!o[--i];)o.pop()}}else if(t<0||t>3||t!==~~t)throw Error(INVALID_RM);return e}function stringify(e,r,t,n){var o,i,a=e.constructor,u=!e.c[0];if(t!==UNDEFINED){if(t!==~~t||t<(3==r)||t>MAX_DP)throw Error(3==r?INVALID+"precision":INVALID_DP);for(t=n-(e=new a(e)).e,e.c.length>++n&&round(e,t,a.RM),2==r&&(n=e.e+t+1);e.c.length<n;)e.c.push(0)}if(o=e.e,t=(i=e.c.join("")).length,2!=r&&(1==r||3==r&&n<=o||o<=a.NE||o>=a.PE))i=i.charAt(0)+(t>1?"."+i.slice(1):"")+(o<0?"e":"e+")+o;else if(o<0){for(;++o;)i="0"+i;i="0."+i}else if(o>0)if(++o>t)for(o-=t;o--;)i+="0";else o<t&&(i=i.slice(0,o)+"."+i.slice(o));else t>1&&(i=i.charAt(0)+"."+i.slice(1));return e.s<0&&(!u||4==r)?"-"+i:i}P.abs=function(){var e=new this.constructor(this);return e.s=1,e},P.cmp=function(e){var r,t=this,n=t.c,o=(e=new t.constructor(e)).c,i=t.s,a=e.s,u=t.e,c=e.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(r=i<0,u!=c)return u>c^r?1:-1;for(a=(u=n.length)<(c=o.length)?u:c,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^r?1:-1;return u==c?0:u>c^r?1:-1},P.div=function(e){var r=this,t=r.constructor,n=r.c,o=(e=new t(e)).c,i=r.s==e.s?1:-1,a=t.DP;if(a!==~~a||a<0||a>MAX_DP)throw Error(INVALID_DP);if(!o[0])throw Error(DIV_BY_ZERO);if(!n[0])return new t(0*i);var u,c,s,l,f,h=o.slice(),d=u=o.length,g=n.length,p=n.slice(0,u),m=p.length,v=e,b=v.c=[],y=0,T=a+(v.e=r.e-e.e)+1;for(v.s=i,i=T<0?0:T,h.unshift(0);m++<u;)p.push(0);do{for(s=0;s<10;s++){if(u!=(m=p.length))l=u>m?1:-1;else for(f=-1,l=0;++f<u;)if(o[f]!=p[f]){l=o[f]>p[f]?1:-1;break}if(!(l<0))break;for(c=m==u?o:h;m;){if(p[--m]<c[m]){for(f=m;f&&!p[--f];)p[f]=9;--p[f],p[m]+=10}p[m]-=c[m]}for(;!p[0];)p.shift()}b[y++]=l?s:++s,p[0]&&l?p[m]=n[d]||0:p=[n[d]]}while((d++<g||p[0]!==UNDEFINED)&&i--);return b[0]||1==y||(b.shift(),v.e--),y>T&&round(v,a,t.RM,p[0]!==UNDEFINED),v},P.eq=function(e){return!this.cmp(e)},P.gt=function(e){return this.cmp(e)>0},P.gte=function(e){return this.cmp(e)>-1},P.lt=function(e){return this.cmp(e)<0},P.lte=function(e){return this.cmp(e)<1},P.minus=P.sub=function(e){var r,t,n,o,i=this,a=i.constructor,u=i.s,c=(e=new a(e)).s;if(u!=c)return e.s=-c,i.plus(e);var s=i.c.slice(),l=i.e,f=e.c,h=e.e;if(!s[0]||!f[0])return f[0]?(e.s=-c,e):new a(s[0]?i:0);if(u=l-h){for((o=u<0)?(u=-u,n=s):(h=l,n=f),n.reverse(),c=u;c--;)n.push(0);n.reverse()}else for(t=((o=s.length<f.length)?s:f).length,u=c=0;c<t;c++)if(s[c]!=f[c]){o=s[c]<f[c];break}if(o&&(n=s,s=f,f=n,e.s=-e.s),(c=(t=f.length)-(r=s.length))>0)for(;c--;)s[r++]=0;for(c=r;t>u;){if(s[--t]<f[t]){for(r=t;r&&!s[--r];)s[r]=9;--s[r],s[t]+=10}s[t]-=f[t]}for(;0===s[--c];)s.pop();for(;0===s[0];)s.shift(),--h;return s[0]||(e.s=1,s=[h=0]),e.c=s,e.e=h,e},P.mod=function(e){var r,t=this,n=t.constructor,o=t.s,i=(e=new n(e)).s;if(!e.c[0])throw Error(DIV_BY_ZERO);return t.s=e.s=1,r=1==e.cmp(t),t.s=o,e.s=i,r?new n(t):(o=n.DP,i=n.RM,n.DP=n.RM=0,t=t.div(e),n.DP=o,n.RM=i,this.minus(t.times(e)))},P.plus=P.add=function(e){var r,t=this,n=t.constructor,o=t.s,i=(e=new n(e)).s;if(o!=i)return e.s=-i,t.minus(e);var a=t.e,u=t.c,c=e.e,s=e.c;if(!u[0]||!s[0])return s[0]?e:new n(u[0]?t:0*o);if(u=u.slice(),o=a-c){for(o>0?(c=a,r=s):(o=-o,r=u),r.reverse();o--;)r.push(0);r.reverse()}for(u.length-s.length<0&&(r=s,s=u,u=r),o=s.length,i=0;o;u[o]%=10)i=(u[--o]=u[o]+s[o]+i)/10|0;for(i&&(u.unshift(i),++c),o=u.length;0===u[--o];)u.pop();return e.c=u,e.e=c,e},P.pow=function(e){var r=this,t=new r.constructor(1),n=t,o=e<0;if(e!==~~e||e<-MAX_POWER||e>MAX_POWER)throw Error(INVALID+"exponent");for(o&&(e=-e);1&e&&(n=n.times(r)),e>>=1;)r=r.times(r);return o?t.div(n):n},P.round=function(e,r){var t=this.constructor;if(e===UNDEFINED)e=0;else if(e!==~~e||e<-MAX_DP||e>MAX_DP)throw Error(INVALID_DP);return round(new t(this),e,r===UNDEFINED?t.RM:r)},P.sqrt=function(){var e,r,t,n=this,o=n.constructor,i=n.s,a=n.e,u=new o(.5);if(!n.c[0])return new o(n);if(i<0)throw Error(NAME+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((r=n.c.join("")).length+a&1||(r+="0"),a=((a+1)/2|0)-(a<0||1&a),e=new o(((i=Math.sqrt(r))==1/0?"1e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):e=new o(i),a=e.e+(o.DP+=4);do{t=e,e=u.times(t.plus(n.div(t)))}while(t.c.slice(0,a).join("")!==e.c.slice(0,a).join(""));return round(e,o.DP-=4,o.RM)},P.times=P.mul=function(e){var r,t=this,n=t.constructor,o=t.c,i=(e=new n(e)).c,a=o.length,u=i.length,c=t.e,s=e.e;if(e.s=t.s==e.s?1:-1,!o[0]||!i[0])return new n(0*e.s);for(e.e=c+s,a<u&&(r=o,o=i,i=r,s=a,a=u,u=s),r=new Array(s=a+u);s--;)r[s]=0;for(c=u;c--;){for(u=0,s=a+c;s>c;)u=r[s]+i[c]*o[s-c-1]+u,r[s--]=u%10,u=u/10|0;r[s]=(r[s]+u)%10}for(u?++e.e:r.shift(),c=r.length;!r[--c];)r.pop();return e.c=r,e},P.toExponential=function(e){return stringify(this,1,e,e)},P.toFixed=function(e){return stringify(this,2,e,this.e+e)},P.toPrecision=function(e){return stringify(this,3,e,e-1)},P.toString=function(){return stringify(this)},P.valueOf=P.toJSON=function(){return stringify(this,4)};var Big=_Big_(),BurstValueFormat;Big.NE=-9,BurstValueFormat=exports.BurstValueFormat||(exports.BurstValueFormat={}),BurstValueFormat[BurstValueFormat.PLANCK=0]="PLANCK",BurstValueFormat[BurstValueFormat.BURST=1]="BURST";var BurstValue=function(){function e(r){_classCallCheck(this,e),this._planck=Big(r)}return _createClass(e,[{key:"getRaw",value:function(){return Big(this._planck)}},{key:"getPlanck",value:function(){return this._planck.toString()}},{key:"setPlanck",value:function(e){this._planck=Big(e)}},{key:"getBurst",value:function(){return Big(this._planck).div(1e8).toString()}},{key:"setBurst",value:function(e){this._planck=Big(e).mul(1e8)}},{key:"equals",value:function(e){return this._planck.eq(e._planck)}},{key:"lessOrEqual",value:function(e){return this._planck.lte(e._planck)}},{key:"less",value:function(e){return this._planck.lt(e._planck)}},{key:"greaterOrEqual",value:function(e){return this._planck.gte(e._planck)}},{key:"greater",value:function(e){return this._planck.gt(e._planck)}},{key:"add",value:function(e){return this._planck=this._planck.plus(e._planck),this}},{key:"subtract",value:function(e){return this._planck=this._planck.minus(e._planck),this}},{key:"multiply",value:function(e){return this._planck=this._planck.mul(e),this}},{key:"divide",value:function(e){return this._planck=this._planck.div(e),this}},{key:"toString",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:exports.BurstValueFormat.BURST)===exports.BurstValueFormat.BURST?"".concat(BurstSymbol," ").concat(this.getBurst()):"".concat(BurstPlanckSymbol," ").concat(this._planck)}}],[{key:"fromPlanck",value:function(r){return new e(r)}},{key:"fromBurst",value:function(r){var t=new e("0");return t.setBurst("number"==typeof r?r.toString(10):r),t}}]),e}();return exports.BurstPlanckSymbol=BurstPlanckSymbol,exports.BurstSymbol=BurstSymbol,exports.BurstTime=BurstTime,exports.BurstValue=BurstValue,exports.convertAddressToNumericId=convertAddressToNumericId,exports.convertBurstTimeToDate=convertBurstTimeToDate,exports.convertBurstTimeToEpochTime=convertBurstTimeToEpochTime,exports.convertByteArrayToHexString=convertByteArrayToHexString,exports.convertByteArrayToString=convertByteArrayToString,exports.convertDateToBurstTime=convertDateToBurstTime,exports.convertHexEndianess=convertHexEndianess,exports.convertHexStringToByteArray=convertHexStringToByteArray,exports.convertHexStringToDecString=convertHexStringToDecString,exports.convertHexStringToString=convertHexStringToString,exports.convertNQTStringToNumber=convertNQTStringToNumber,exports.convertNumberToNQTString=convertNumberToNQTString,exports.convertNumericIdToAddress=convertNumericIdToAddress,exports.convertStringToByteArray=convertStringToByteArray,exports.convertStringToHexString=convertStringToHexString,exports.createDeeplink=createDeeplink,exports.isBurstAddress=isBurstAddress,exports.isValid=isValid,exports.parseDeeplink=parseDeeplink,exports.sumNQTStringToNumber=sumNQTStringToNumber,exports}({}); | ||
//# sourceMappingURL=burstjs.util.min.js.map |
@@ -21,1 +21,4 @@ export * from './convertAddressToNumericId'; | ||
export * from './typings'; | ||
export * from './constants'; | ||
export * from './burstTime'; | ||
export * from './burstValue'; |
@@ -21,1 +21,4 @@ export * from './convertAddressToNumericId'; | ||
export * from './typings'; | ||
export * from './constants'; | ||
export * from './burstTime'; | ||
export * from './burstValue'; |
@@ -26,2 +26,5 @@ "use strict"; | ||
__export(require("./typings")); | ||
__export(require("./constants")); | ||
__export(require("./burstTime")); | ||
__export(require("./burstValue")); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@burstjs/util", | ||
"version": "0.5.0-beta.3", | ||
"version": "0.5.0-beta.4", | ||
"description": "Useful utilities and tools for building Burstcoin applications", | ||
@@ -58,6 +58,8 @@ "keywords": [ | ||
}, | ||
"gitHead": "3559a36c870f655b4e5db78761b0c2341695d12d", | ||
"gitHead": "44e637c36498bc4a2937228dbd774c13f17e1488", | ||
"dependencies": { | ||
"@types/big.js": "^4.0.5", | ||
"big.js": "^5.2.2", | ||
"js-base64": "^2.5.1" | ||
} | ||
} |
@@ -11,2 +11,3 @@ // tslint:disable:no-bitwise | ||
/** | ||
* @deprecated use [[BurstTime.getEpoch()]] | ||
* Converts a Burst/Block Time (seconds since genesis block) into Unix Epoch Time (milliseconds since 01.01.1970) | ||
@@ -13,0 +14,0 @@ * @param burstTimestamp The numeric Id |
@@ -9,4 +9,5 @@ /** @module util */ | ||
/** | ||
* Helper method to convert a String to number | ||
* @param amount The amount in NQT | ||
* @deprecated This method will be substituted in favor of [[BurstValue]] | ||
* Helper method to convert a Planck Value (BURST * 1E8) String to BURST number | ||
* @param amount The amount in Planck (aka NQT) | ||
* @return A number expressed in Burst (not NQT) | ||
@@ -13,0 +14,0 @@ * @throws exception if argument is invalid |
@@ -9,2 +9,3 @@ /** @module util */ | ||
/** | ||
* @deprecated This method will be substituted in favor of [[BurstValue]] | ||
* Helper method to Number to String(8 decimals) representation | ||
@@ -11,0 +12,0 @@ * @param n the number |
@@ -22,1 +22,4 @@ /** @module util */ | ||
export * from './typings'; | ||
export * from './constants'; | ||
export * from './burstTime'; | ||
export * from './burstValue'; |
@@ -9,2 +9,3 @@ /** @module util */ | ||
/** | ||
* @deprecated Use [[BurstValue.sum()]] instead | ||
* Sums various NQT values and returns in Burst | ||
@@ -11,0 +12,0 @@ * @param nqts Variable amount list with NQT string |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
477445
164
4090
3
+ Added@types/big.js@^4.0.5
+ Addedbig.js@^5.2.2
+ Added@types/big.js@4.0.5(transitive)
+ Addedbig.js@5.2.2(transitive)