@glif/filecoin-number
Advanced tools
Comparing version 2.0.45 to 2.0.47
@@ -45,2 +45,3 @@ /// <reference types="node" /> | ||
addUnit?: boolean; | ||
isWFIL?: boolean; | ||
}): string; | ||
@@ -47,0 +48,0 @@ /** |
@@ -137,3 +137,3 @@ "use strict"; | ||
value: function formatBalance(options) { | ||
var _options$truncate, _options$decimals, _options$coinType, _options$addUnit; | ||
var _options$truncate, _options$decimals, _options$coinType, _options$addUnit, _options$isWFIL; | ||
@@ -144,4 +144,6 @@ var truncate = (_options$truncate = options === null || options === void 0 ? void 0 : options.truncate) !== null && _options$truncate !== void 0 ? _options$truncate : true; | ||
var addUnit = (_options$addUnit = options === null || options === void 0 ? void 0 : options.addUnit) !== null && _options$addUnit !== void 0 ? _options$addUnit : true; | ||
var isWFIL = (_options$isWFIL = options === null || options === void 0 ? void 0 : options.isWFIL) !== null && _options$isWFIL !== void 0 ? _options$isWFIL : false; | ||
if (decimals < 0) throw new Error('Decimals must be >= 0'); | ||
if (this.isNaN()) throw new Error('Value cannot be NaN'); | ||
var unitPrefix = isWFIL ? 'w' : coinType === CoinType.TEST ? 't' : ''; | ||
var format = { | ||
@@ -151,3 +153,3 @@ decimalSeparator: '.', | ||
groupSize: 3, | ||
suffix: addUnit ? " ".concat(coinType === CoinType.TEST ? 't' : '', "FIL") : '' | ||
suffix: addUnit ? " ".concat(unitPrefix, "FIL") : '' | ||
}; // Base value is zero | ||
@@ -154,0 +156,0 @@ |
@@ -118,3 +118,3 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
value: function formatBalance(options) { | ||
var _options$truncate, _options$decimals, _options$coinType, _options$addUnit; | ||
var _options$truncate, _options$decimals, _options$coinType, _options$addUnit, _options$isWFIL; | ||
@@ -125,4 +125,6 @@ var truncate = (_options$truncate = options === null || options === void 0 ? void 0 : options.truncate) !== null && _options$truncate !== void 0 ? _options$truncate : true; | ||
var addUnit = (_options$addUnit = options === null || options === void 0 ? void 0 : options.addUnit) !== null && _options$addUnit !== void 0 ? _options$addUnit : true; | ||
var isWFIL = (_options$isWFIL = options === null || options === void 0 ? void 0 : options.isWFIL) !== null && _options$isWFIL !== void 0 ? _options$isWFIL : false; | ||
if (decimals < 0) throw new Error('Decimals must be >= 0'); | ||
if (this.isNaN()) throw new Error('Value cannot be NaN'); | ||
var unitPrefix = isWFIL ? 'w' : coinType === CoinType.TEST ? 't' : ''; | ||
var format = { | ||
@@ -132,3 +134,3 @@ decimalSeparator: '.', | ||
groupSize: 3, | ||
suffix: addUnit ? " ".concat(coinType === CoinType.TEST ? 't' : '', "FIL") : '' | ||
suffix: addUnit ? " ".concat(unitPrefix, "FIL") : '' | ||
}; // Base value is zero | ||
@@ -135,0 +137,0 @@ |
@@ -104,4 +104,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
const addUnit = (options === null || options === void 0 ? void 0 : options.addUnit) ?? true; | ||
const isWFIL = (options === null || options === void 0 ? void 0 : options.isWFIL) ?? false; | ||
if (decimals < 0) throw new Error('Decimals must be >= 0'); | ||
if (this.isNaN()) throw new Error('Value cannot be NaN'); | ||
const unitPrefix = isWFIL ? 'w' : coinType === CoinType.TEST ? 't' : ''; | ||
const format = { | ||
@@ -111,3 +113,3 @@ decimalSeparator: '.', | ||
groupSize: 3, | ||
suffix: addUnit ? ` ${coinType === CoinType.TEST ? 't' : ''}FIL` : '' | ||
suffix: addUnit ? ` ${unitPrefix}FIL` : '' | ||
}; // Base value is zero | ||
@@ -114,0 +116,0 @@ |
{ | ||
"name": "@glif/filecoin-number", | ||
"version": "2.0.45", | ||
"version": "2.0.47", | ||
"description": "a javascript package to handle Filecoin numbers like Fil and AttoFil", | ||
@@ -50,3 +50,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "a056dffd6204dded146adc80c0db7c0083fec1b5" | ||
"gitHead": "5dde2a4160c2b51eff154601f759d1247c82f409" | ||
} |
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
131367
1172