Socket
Socket
Sign inDemoInstall

@helium/currency

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helium/currency - npm Package Compare versions

Comparing version 3.16.0 to 3.23.0

8

build/Balance.d.ts
import BigNumber from 'bignumber.js';
import { AnyCurrencyType } from './CurrencyType';
import { NetworkTokens, USDollars, DataCredits, BaseCurrencyType } from './currency_types';
declare type StringFormatOptions = {
decimalSeparator?: string;
groupSeparator?: string;
showTicker?: boolean;
};
export default class Balance<T extends BaseCurrencyType> {

@@ -12,3 +17,3 @@ type: T;

static fromFloat(float: number, currencyType: AnyCurrencyType): Balance<AnyCurrencyType>;
toString(maxDecimalPlaces?: number): string;
toString(maxDecimalPlaces?: number, options?: StringFormatOptions): string;
plus(balance: Balance<T>): Balance<T>;

@@ -22,2 +27,3 @@ minus(balance: Balance<T>): Balance<T>;

}
export {};
//# sourceMappingURL=Balance.d.ts.map

17

build/Balance.js

@@ -36,13 +36,18 @@ "use strict";

}
toString(maxDecimalPlaces) {
let numberString = this.bigBalance.toFormat(maxDecimalPlaces);
toString(maxDecimalPlaces, options) {
const decimalSeparator = (options === null || options === void 0 ? void 0 : options.decimalSeparator) || '.';
const groupSeparator = (options === null || options === void 0 ? void 0 : options.groupSeparator) || ',';
const showTicker = (options === null || options === void 0 ? void 0 : options.showTicker) === undefined ? true : options.showTicker;
let numberString = maxDecimalPlaces
? this.bigBalance.toFormat(maxDecimalPlaces, { decimalSeparator, groupSeparator, groupSize: 3 })
: this.bigBalance.toFormat({ decimalSeparator, groupSeparator, groupSize: 3 });
// if it's an integer, just show the integer
if (parseInt(numberString.split('.')[1]) === 0) {
numberString = numberString.split('.')[0];
if (parseInt(numberString.split(decimalSeparator)[1], 10) === 0) {
[numberString] = numberString.split(decimalSeparator);
}
// if the rounded amount is 0, then show the full amount
if (numberString === '0') {
numberString = this.bigBalance.toFormat();
numberString = this.bigBalance.toFormat({ decimalSeparator, groupSeparator });
}
return [numberString, this.type.ticker].join(' ');
return showTicker ? [numberString, this.type.ticker].join(' ') : numberString;
}

@@ -49,0 +54,0 @@ plus(balance) {

{
"name": "@helium/currency",
"version": "3.16.0",
"version": "3.23.0",
"description": "Utilities for handling different currency types on the Helium blockchain",

@@ -31,3 +31,3 @@ "keywords": [

},
"gitHead": "e764bb372ca18d2709ea22d0b8c84d77d35739aa"
"gitHead": "4b6c414a1745a51746a3f9a0c0c9a3a7d699a327"
}

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