@helium/currency
Advanced tools
Comparing version 4.7.0 to 4.7.2
@@ -8,2 +8,3 @@ import BigNumber from 'bignumber.js'; | ||
showTicker?: boolean; | ||
roundingMode?: BigNumber.RoundingMode; | ||
}; | ||
@@ -10,0 +11,0 @@ export default class Balance<T extends BaseCurrencyType> { |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable prefer-destructuring */ | ||
const bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
@@ -41,8 +42,13 @@ const CurrencyType_1 = __importDefault(require("./CurrencyType")); | ||
const showTicker = (options === null || options === void 0 ? void 0 : options.showTicker) === undefined ? true : options.showTicker; | ||
let numberString = maxDecimalPlaces !== undefined && maxDecimalPlaces !== null | ||
? this.bigBalance.toFormat(maxDecimalPlaces, { decimalSeparator, groupSeparator, groupSize: 3 }) | ||
: this.bigBalance.toFormat({ decimalSeparator, groupSeparator, groupSize: 3 }); | ||
const format = { decimalSeparator, groupSeparator, groupSize: 3 }; | ||
let numberString = ''; | ||
if (maxDecimalPlaces !== undefined && maxDecimalPlaces !== null) { | ||
numberString = this.bigBalance.toFormat(maxDecimalPlaces, (options === null || options === void 0 ? void 0 : options.roundingMode) || bignumber_js_1.default.ROUND_DOWN, format); | ||
} | ||
else { | ||
numberString = this.bigBalance.toFormat(format); | ||
} | ||
// if it's an integer, just show the integer | ||
if (parseInt(numberString.split(decimalSeparator)[1], 10) === 0) { | ||
[numberString] = numberString.split(decimalSeparator); | ||
numberString = numberString.split(decimalSeparator)[0]; | ||
} | ||
@@ -49,0 +55,0 @@ // if the rounded amount is 0, then show the full amount |
{ | ||
"name": "@helium/currency", | ||
"version": "4.7.0", | ||
"version": "4.7.2", | ||
"description": "Utilities for handling different currency types on the Helium blockchain", | ||
@@ -31,3 +31,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "20d7cf8f2002f3962dce732bf4c1f0ef7e88b6f7" | ||
"gitHead": "b5129be245f5c911a89c69f38f3039c196de2de7" | ||
} |
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
51345
438