Socket
Socket
Sign inDemoInstall

@glif/filecoin-number

Package Overview
Dependencies
Maintainers
3
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glif/filecoin-number - npm Package Compare versions

Comparing version 2.0.63 to 2.0.64

2

dist/FilecoinNumber.d.ts

@@ -62,2 +62,3 @@ /// <reference types="node" />

* @param options.decimals How many decimals to display, `null` disables rounding, defaults to `3`
* @param options.padZeros Whether add trailing zeros to the end of the string, defaults to `false`
* @param options.addUnit Whether to display the unit, defaults to `true`

@@ -68,2 +69,3 @@ */

decimals?: number | null;
padZeros?: boolean;
addUnit?: boolean;

@@ -70,0 +72,0 @@ }): string;

21

dist/FilecoinNumber.js

@@ -160,2 +160,3 @@ "use strict";

* @param options.decimals How many decimals to display, `null` disables rounding, defaults to `3`
* @param options.padZeros Whether add trailing zeros to the end of the string, defaults to `false`
* @param options.addUnit Whether to display the unit, defaults to `true`

@@ -167,3 +168,3 @@ */

value: function formatBalance(options) {
var _options$truncate, _options$decimals, _options$addUnit;
var _options$truncate, _options$decimals, _options$padZeros, _options$addUnit;

@@ -173,4 +174,10 @@ var truncate = (_options$truncate = options === null || options === void 0 ? void 0 : options.truncate) !== null && _options$truncate !== void 0 ? _options$truncate : true;

var decimals = (_options$decimals = options === null || options === void 0 ? void 0 : options.decimals) !== null && _options$decimals !== void 0 ? _options$decimals : 3;
var addUnit = (_options$addUnit = options === null || options === void 0 ? void 0 : options.addUnit) !== null && _options$addUnit !== void 0 ? _options$addUnit : true; // Create format configuration
var padZeros = (_options$padZeros = options === null || options === void 0 ? void 0 : options.padZeros) !== null && _options$padZeros !== void 0 ? _options$padZeros : false;
var addUnit = (_options$addUnit = options === null || options === void 0 ? void 0 : options.addUnit) !== null && _options$addUnit !== void 0 ? _options$addUnit : true;
var toFormat = function toFormat(value, format) {
return padZeros ? value.toFormat(decimals, _bignumber.BigNumber.ROUND_DOWN, format) : value.toFormat(format);
}; // Create format configuration
var format = {

@@ -184,3 +191,3 @@ decimalSeparator: '.',

if (this.isZero() || !round) return this.toFormat(format); // Round down by default to avoid showing higher balance
if (this.isZero() || !round) return toFormat(this, format); // Round down by default to avoid showing higher balance

@@ -196,3 +203,3 @@ var rounded = this.dp(decimals, _bignumber.BigNumber.ROUND_DOWN); // Value is zero after rounding

var prefix = isNegative ? '< ' : '> ';
return rounded.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(rounded, _objectSpread(_objectSpread({}, format), {}, {
prefix: prefix

@@ -206,3 +213,3 @@ }));

var roundedUp = this.dp(decimals, _bignumber.BigNumber.ROUND_UP);
return roundedUp.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(roundedUp, _objectSpread(_objectSpread({}, format), {}, {
prefix: _prefix

@@ -215,3 +222,3 @@ }));

var isLt1K = rounded.isGreaterThan(-1000) && rounded.isLessThan(1000);
if (isLt1K || !truncate) return rounded.toFormat(format); // Truncate values below -1000 or above 1000
if (isLt1K || !truncate) return toFormat(rounded, format); // Truncate values below -1000 or above 1000

@@ -230,3 +237,3 @@ var power = 0;

var suffix = "".concat(unit).concat(format.suffix);
return unitVal.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(unitVal, _objectSpread(_objectSpread({}, format), {}, {
suffix: suffix

@@ -233,0 +240,0 @@ }));

@@ -144,2 +144,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";

* @param options.decimals How many decimals to display, `null` disables rounding, defaults to `3`
* @param options.padZeros Whether add trailing zeros to the end of the string, defaults to `false`
* @param options.addUnit Whether to display the unit, defaults to `true`

@@ -151,3 +152,3 @@ */

value: function formatBalance(options) {
var _options$truncate, _options$decimals, _options$addUnit;
var _options$truncate, _options$decimals, _options$padZeros, _options$addUnit;

@@ -157,4 +158,10 @@ var truncate = (_options$truncate = options === null || options === void 0 ? void 0 : options.truncate) !== null && _options$truncate !== void 0 ? _options$truncate : true;

var decimals = (_options$decimals = options === null || options === void 0 ? void 0 : options.decimals) !== null && _options$decimals !== void 0 ? _options$decimals : 3;
var addUnit = (_options$addUnit = options === null || options === void 0 ? void 0 : options.addUnit) !== null && _options$addUnit !== void 0 ? _options$addUnit : true; // Create format configuration
var padZeros = (_options$padZeros = options === null || options === void 0 ? void 0 : options.padZeros) !== null && _options$padZeros !== void 0 ? _options$padZeros : false;
var addUnit = (_options$addUnit = options === null || options === void 0 ? void 0 : options.addUnit) !== null && _options$addUnit !== void 0 ? _options$addUnit : true;
var toFormat = function toFormat(value, format) {
return padZeros ? value.toFormat(decimals, BigNumber.ROUND_DOWN, format) : value.toFormat(format);
}; // Create format configuration
var format = {

@@ -168,3 +175,3 @@ decimalSeparator: '.',

if (this.isZero() || !round) return this.toFormat(format); // Round down by default to avoid showing higher balance
if (this.isZero() || !round) return toFormat(this, format); // Round down by default to avoid showing higher balance

@@ -180,3 +187,3 @@ var rounded = this.dp(decimals, BigNumber.ROUND_DOWN); // Value is zero after rounding

var prefix = isNegative ? '< ' : '> ';
return rounded.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(rounded, _objectSpread(_objectSpread({}, format), {}, {
prefix: prefix

@@ -190,3 +197,3 @@ }));

var roundedUp = this.dp(decimals, BigNumber.ROUND_UP);
return roundedUp.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(roundedUp, _objectSpread(_objectSpread({}, format), {}, {
prefix: _prefix

@@ -199,3 +206,3 @@ }));

var isLt1K = rounded.isGreaterThan(-1000) && rounded.isLessThan(1000);
if (isLt1K || !truncate) return rounded.toFormat(format); // Truncate values below -1000 or above 1000
if (isLt1K || !truncate) return toFormat(rounded, format); // Truncate values below -1000 or above 1000

@@ -214,3 +221,3 @@ var power = 0;

var suffix = "".concat(unit).concat(format.suffix);
return unitVal.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(unitVal, _objectSpread(_objectSpread({}, format), {}, {
suffix: suffix

@@ -217,0 +224,0 @@ }));

@@ -143,2 +143,3 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

* @param options.decimals How many decimals to display, `null` disables rounding, defaults to `3`
* @param options.padZeros Whether add trailing zeros to the end of the string, defaults to `false`
* @param options.addUnit Whether to display the unit, defaults to `true`

@@ -152,4 +153,8 @@ */

const decimals = (options === null || options === void 0 ? void 0 : options.decimals) ?? 3;
const addUnit = (options === null || options === void 0 ? void 0 : options.addUnit) ?? true; // Create format configuration
const padZeros = (options === null || options === void 0 ? void 0 : options.padZeros) ?? false;
const addUnit = (options === null || options === void 0 ? void 0 : options.addUnit) ?? true;
const toFormat = (value, format) => padZeros ? value.toFormat(decimals, BigNumber.ROUND_DOWN, format) : value.toFormat(format); // Create format configuration
const format = {

@@ -163,3 +168,3 @@ decimalSeparator: '.',

if (this.isZero() || !round) return this.toFormat(format); // Round down by default to avoid showing higher balance
if (this.isZero() || !round) return toFormat(this, format); // Round down by default to avoid showing higher balance

@@ -175,3 +180,3 @@ const rounded = this.dp(decimals, BigNumber.ROUND_DOWN); // Value is zero after rounding

const prefix = isNegative ? '< ' : '> ';
return rounded.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(rounded, _objectSpread(_objectSpread({}, format), {}, {
prefix

@@ -184,3 +189,3 @@ }));

const roundedUp = this.dp(decimals, BigNumber.ROUND_UP);
return roundedUp.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(roundedUp, _objectSpread(_objectSpread({}, format), {}, {
prefix

@@ -193,3 +198,3 @@ }));

const isLt1K = rounded.isGreaterThan(-1000) && rounded.isLessThan(1000);
if (isLt1K || !truncate) return rounded.toFormat(format); // Truncate values below -1000 or above 1000
if (isLt1K || !truncate) return toFormat(rounded, format); // Truncate values below -1000 or above 1000

@@ -206,3 +211,3 @@ let power = 0;

const suffix = `${unit}${format.suffix}`;
return unitVal.toFormat(_objectSpread(_objectSpread({}, format), {}, {
return toFormat(unitVal, _objectSpread(_objectSpread({}, format), {}, {
suffix

@@ -209,0 +214,0 @@ }));

{
"name": "@glif/filecoin-number",
"version": "2.0.63",
"version": "2.0.64",
"description": "a javascript package to handle Filecoin numbers like Fil and AttoFil",

@@ -50,3 +50,3 @@ "main": "./dist/index.js",

},
"gitHead": "440144735f715f645d2b3d730d588fad75586f8e"
"gitHead": "8cb274682f7c3d90fdea6a4d87c11949c31781ac"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc