@glif/filecoin-number
Advanced tools
Comparing version 2.0.67 to 2.0.68
@@ -19,3 +19,3 @@ /// <reference types="node" /> | ||
* @param denom The denomination of value (fil, picofil or attofil) | ||
* @param unit a custom unit to display with formatBalance, defaults to (t)FIL | ||
* @param unit a custom unit to display with formatBalance, defaults to FIL | ||
*/ | ||
@@ -25,4 +25,4 @@ export declare class FilecoinNumber extends BigNumber { | ||
private static zeroMap; | ||
private readonly _coinType; | ||
private readonly _unit; | ||
readonly coinType: CoinType; | ||
readonly unit: string; | ||
constructor(value: BigNumber.Value, denom: FilecoinDenomination, coinType?: CoinType, unit?: string); | ||
@@ -39,5 +39,5 @@ /** | ||
/** | ||
* Returns the unit derived from constructor params | ||
* Returns the unit with a 't' prefix for testnets | ||
*/ | ||
get unit(): string; | ||
get displayUnit(): string; | ||
/** | ||
@@ -44,0 +44,0 @@ * Checks whether the unit is the default unit |
@@ -77,3 +77,3 @@ "use strict"; | ||
* @param denom The denomination of value (fil, picofil or attofil) | ||
* @param unit a custom unit to display with formatBalance, defaults to (t)FIL | ||
* @param unit a custom unit to display with formatBalance, defaults to FIL | ||
*/ | ||
@@ -96,6 +96,6 @@ | ||
_this = _super.call(this, toBigNumberValue(value, denom)); | ||
(0, _defineProperty3["default"])((0, _assertThisInitialized2["default"])(_this), "_coinType", void 0); | ||
(0, _defineProperty3["default"])((0, _assertThisInitialized2["default"])(_this), "_unit", void 0); | ||
_this._coinType = coinType; | ||
_this._unit = unit; | ||
(0, _defineProperty3["default"])((0, _assertThisInitialized2["default"])(_this), "coinType", void 0); | ||
(0, _defineProperty3["default"])((0, _assertThisInitialized2["default"])(_this), "unit", void 0); | ||
_this.coinType = coinType; | ||
_this.unit = unit; | ||
return _this; | ||
@@ -117,3 +117,3 @@ } | ||
var unitDenom = denom.replace(/fil$/, ''); | ||
return unitDenom ? "".concat(unitDenom).concat(this._unit) : this.unit; | ||
return unitDenom ? "".concat(unitDenom).concat(this.unit) : this.displayUnit; | ||
} | ||
@@ -187,3 +187,3 @@ /** | ||
groupSize: 3, | ||
suffix: addUnit ? " ".concat(this.unit) : '' | ||
suffix: addUnit ? " ".concat(this.displayUnit) : '' | ||
}; // When not rounding, it doesn't make sense to truncate either. | ||
@@ -250,3 +250,3 @@ // Return the original value when it's zero or when not rounding. | ||
value: function clone() { | ||
return new FilecoinNumber(this, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(this, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -262,3 +262,3 @@ /** | ||
var bigNr = (0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "dp", this).call(this, decimalPlaces, _bignumber.BigNumber.ROUND_UP); | ||
return new FilecoinNumber(bigNr, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(bigNr, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -274,3 +274,3 @@ /** | ||
var bigNr = (0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "dp", this).call(this, decimalPlaces, _bignumber.BigNumber.ROUND_DOWN); | ||
return new FilecoinNumber(bigNr, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(bigNr, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -284,3 +284,3 @@ /** | ||
value: function abs() { | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "abs", this).call(this), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "abs", this).call(this), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -303,3 +303,3 @@ /** | ||
value: function negated() { | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "negated", this).call(this), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "negated", this).call(this), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -313,3 +313,3 @@ /** | ||
value: function div(n) { | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "div", this).call(this, n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "div", this).call(this, n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -332,3 +332,3 @@ /** | ||
value: function times(n) { | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "times", this).call(this, n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "times", this).call(this, n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -352,3 +352,3 @@ /** | ||
value: function plus(n) { | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "plus", this).call(this, n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "plus", this).call(this, n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -363,3 +363,3 @@ /** | ||
value: function minus(n) { | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "minus", this).call(this, n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "minus", this).call(this, n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -467,10 +467,10 @@ /** | ||
}, { | ||
key: "unit", | ||
key: "displayUnit", | ||
/** | ||
* Returns the unit derived from constructor params | ||
* Returns the unit with a 't' prefix for testnets | ||
*/ | ||
get: function get() { | ||
var addT = this._coinType === CoinType.TEST && this._unit === FilecoinNumber.DefaultUnit; | ||
return "".concat(addT ? 't' : '').concat(this._unit); | ||
var addT = this.coinType === CoinType.TEST && this.unit === FilecoinNumber.DefaultUnit; | ||
return "".concat(addT ? 't' : '').concat(this.unit); | ||
} | ||
@@ -484,3 +484,3 @@ /** | ||
get: function get() { | ||
return this._unit === FilecoinNumber.DefaultUnit; | ||
return this.unit === FilecoinNumber.DefaultUnit; | ||
} | ||
@@ -487,0 +487,0 @@ }], [{ |
@@ -56,3 +56,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
* @param denom The denomination of value (fil, picofil or attofil) | ||
* @param unit a custom unit to display with formatBalance, defaults to (t)FIL | ||
* @param unit a custom unit to display with formatBalance, defaults to FIL | ||
*/ | ||
@@ -78,8 +78,8 @@ | ||
_defineProperty(_assertThisInitialized(_this), "_coinType", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "coinType", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "_unit", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "unit", void 0); | ||
_this._coinType = coinType; | ||
_this._unit = unit; | ||
_this.coinType = coinType; | ||
_this.unit = unit; | ||
return _this; | ||
@@ -101,3 +101,3 @@ } | ||
var unitDenom = denom.replace(/fil$/, ''); | ||
return unitDenom ? "".concat(unitDenom).concat(this._unit) : this.unit; | ||
return unitDenom ? "".concat(unitDenom).concat(this.unit) : this.displayUnit; | ||
} | ||
@@ -171,3 +171,3 @@ /** | ||
groupSize: 3, | ||
suffix: addUnit ? " ".concat(this.unit) : '' | ||
suffix: addUnit ? " ".concat(this.displayUnit) : '' | ||
}; // When not rounding, it doesn't make sense to truncate either. | ||
@@ -234,3 +234,3 @@ // Return the original value when it's zero or when not rounding. | ||
value: function clone() { | ||
return new FilecoinNumber(this, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(this, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -248,3 +248,3 @@ /** | ||
return new FilecoinNumber(bigNr, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(bigNr, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -262,3 +262,3 @@ /** | ||
return new FilecoinNumber(bigNr, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(bigNr, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -272,3 +272,3 @@ /** | ||
value: function abs() { | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "abs", this).call(this), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "abs", this).call(this), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -291,3 +291,3 @@ /** | ||
value: function negated() { | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "negated", this).call(this), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "negated", this).call(this), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -301,3 +301,3 @@ /** | ||
value: function div(n) { | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "div", this).call(this, n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "div", this).call(this, n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -320,3 +320,3 @@ /** | ||
value: function times(n) { | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "times", this).call(this, n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "times", this).call(this, n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -340,3 +340,3 @@ /** | ||
value: function plus(n) { | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "plus", this).call(this, n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "plus", this).call(this, n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -351,3 +351,3 @@ /** | ||
value: function minus(n) { | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "minus", this).call(this, n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "minus", this).call(this, n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -455,10 +455,10 @@ /** | ||
}, { | ||
key: "unit", | ||
key: "displayUnit", | ||
/** | ||
* Returns the unit derived from constructor params | ||
* Returns the unit with a 't' prefix for testnets | ||
*/ | ||
get: function get() { | ||
var addT = this._coinType === CoinType.TEST && this._unit === FilecoinNumber.DefaultUnit; | ||
return "".concat(addT ? 't' : '').concat(this._unit); | ||
var addT = this.coinType === CoinType.TEST && this.unit === FilecoinNumber.DefaultUnit; | ||
return "".concat(addT ? 't' : '').concat(this.unit); | ||
} | ||
@@ -472,3 +472,3 @@ /** | ||
get: function get() { | ||
return this._unit === FilecoinNumber.DefaultUnit; | ||
return this.unit === FilecoinNumber.DefaultUnit; | ||
} | ||
@@ -475,0 +475,0 @@ }], [{ |
@@ -43,3 +43,3 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
* @param denom The denomination of value (fil, picofil or attofil) | ||
* @param unit a custom unit to display with formatBalance, defaults to (t)FIL | ||
* @param unit a custom unit to display with formatBalance, defaults to FIL | ||
*/ | ||
@@ -54,8 +54,8 @@ | ||
_defineProperty(this, "_coinType", void 0); | ||
_defineProperty(this, "coinType", void 0); | ||
_defineProperty(this, "_unit", void 0); | ||
_defineProperty(this, "unit", void 0); | ||
this._coinType = coinType; | ||
this._unit = unit; | ||
this.coinType = coinType; | ||
this.unit = unit; | ||
} | ||
@@ -81,9 +81,9 @@ /** | ||
/** | ||
* Returns the unit derived from constructor params | ||
* Returns the unit with a 't' prefix for testnets | ||
*/ | ||
get unit() { | ||
const addT = this._coinType === CoinType.TEST && this._unit === FilecoinNumber.DefaultUnit; | ||
return `${addT ? 't' : ''}${this._unit}`; | ||
get displayUnit() { | ||
const addT = this.coinType === CoinType.TEST && this.unit === FilecoinNumber.DefaultUnit; | ||
return `${addT ? 't' : ''}${this.unit}`; | ||
} | ||
@@ -96,3 +96,3 @@ /** | ||
get isDefaultUnit() { | ||
return this._unit === FilecoinNumber.DefaultUnit; | ||
return this.unit === FilecoinNumber.DefaultUnit; | ||
} | ||
@@ -106,3 +106,3 @@ /** | ||
const unitDenom = denom.replace(/fil$/, ''); | ||
return unitDenom ? `${unitDenom}${this._unit}` : this.unit; | ||
return unitDenom ? `${unitDenom}${this.unit}` : this.displayUnit; | ||
} | ||
@@ -167,3 +167,3 @@ /** | ||
groupSize: 3, | ||
suffix: addUnit ? ` ${this.unit}` : '' | ||
suffix: addUnit ? ` ${this.displayUnit}` : '' | ||
}; // When not rounding, it doesn't make sense to truncate either. | ||
@@ -226,3 +226,3 @@ // Return the original value when it's zero or when not rounding. | ||
clone() { | ||
return new FilecoinNumber(this, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(this, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -236,3 +236,3 @@ /** | ||
const bigNr = super.dp(decimalPlaces, BigNumber.ROUND_UP); | ||
return new FilecoinNumber(bigNr, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(bigNr, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -246,3 +246,3 @@ /** | ||
const bigNr = super.dp(decimalPlaces, BigNumber.ROUND_DOWN); | ||
return new FilecoinNumber(bigNr, 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(bigNr, 'fil', this.coinType, this.unit); | ||
} | ||
@@ -255,3 +255,3 @@ /** | ||
abs() { | ||
return new FilecoinNumber(super.abs(), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(super.abs(), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -272,3 +272,3 @@ /** | ||
negated() { | ||
return new FilecoinNumber(super.negated(), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(super.negated(), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -281,3 +281,3 @@ /** | ||
div(n) { | ||
return new FilecoinNumber(super.div(n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(super.div(n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -298,3 +298,3 @@ /** | ||
times(n) { | ||
return new FilecoinNumber(super.times(n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(super.times(n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -316,3 +316,3 @@ /** | ||
plus(n) { | ||
return new FilecoinNumber(super.plus(n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(super.plus(n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -326,3 +326,3 @@ /** | ||
minus(n) { | ||
return new FilecoinNumber(super.minus(n), 'fil', this._coinType, this._unit); | ||
return new FilecoinNumber(super.minus(n), 'fil', this.coinType, this.unit); | ||
} | ||
@@ -329,0 +329,0 @@ /** |
{ | ||
"name": "@glif/filecoin-number", | ||
"version": "2.0.67", | ||
"version": "2.0.68", | ||
"description": "a javascript package to handle Filecoin numbers like Fil and AttoFil", | ||
@@ -50,3 +50,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "2caaa6aee28c69f49f5a5e6b9322b78694145562" | ||
"gitHead": "67f72cdbbca4a592cc273d0856187a66af6e9a5e" | ||
} |
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
184187