@coingecko/cryptoformat
Advanced tools
@@ -239,3 +239,3 @@ 'use strict'; | ||
| function formatCurrency(amount, isoCode, locale = "en", raw = false) { | ||
| function formatCurrency(amount, isoCode, locale = "en", raw = false, noDecimal = false) { | ||
| isoCode = isoCode.toUpperCase(); | ||
@@ -253,2 +253,8 @@ | ||
| let price = parseFloat(amount); | ||
| if (noDecimal === true && amount > 1.0) { | ||
| return formatCurrencyOverride( | ||
| currencyFormatterNoDecimal.format(amount), | ||
| locale | ||
| ); | ||
| } | ||
@@ -296,2 +302,9 @@ if (raw) { | ||
| } else { | ||
| if (noDecimal === true && amount > 1.0) { | ||
| return formatCurrencyOverride( | ||
| currencyFormatterNoDecimal.format(amount), | ||
| locale | ||
| ); | ||
| } | ||
| if (raw) { | ||
@@ -298,0 +311,0 @@ if (amount < 0.001) { |
@@ -235,3 +235,3 @@ // A map of supported currency codes to currency symbols. | ||
| function formatCurrency(amount, isoCode, locale = "en", raw = false) { | ||
| function formatCurrency(amount, isoCode, locale = "en", raw = false, noDecimal = false) { | ||
| isoCode = isoCode.toUpperCase(); | ||
@@ -249,2 +249,8 @@ | ||
| let price = parseFloat(amount); | ||
| if (noDecimal === true && amount > 1.0) { | ||
| return formatCurrencyOverride( | ||
| currencyFormatterNoDecimal.format(amount), | ||
| locale | ||
| ); | ||
| } | ||
@@ -292,2 +298,9 @@ if (raw) { | ||
| } else { | ||
| if (noDecimal === true && amount > 1.0) { | ||
| return formatCurrencyOverride( | ||
| currencyFormatterNoDecimal.format(amount), | ||
| locale | ||
| ); | ||
| } | ||
| if (raw) { | ||
@@ -294,0 +307,0 @@ if (amount < 0.001) { |
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
| (global = global || self, factory(global.cryptoformat = {})); | ||
| }(this, function (exports) { 'use strict'; | ||
| }(this, (function (exports) { 'use strict'; | ||
@@ -242,3 +242,3 @@ // A map of supported currency codes to currency symbols. | ||
| function formatCurrency(amount, isoCode, locale = "en", raw = false) { | ||
| function formatCurrency(amount, isoCode, locale = "en", raw = false, noDecimal = false) { | ||
| isoCode = isoCode.toUpperCase(); | ||
@@ -256,2 +256,8 @@ | ||
| let price = parseFloat(amount); | ||
| if (noDecimal === true && amount > 1.0) { | ||
| return formatCurrencyOverride( | ||
| currencyFormatterNoDecimal.format(amount), | ||
| locale | ||
| ); | ||
| } | ||
@@ -299,2 +305,9 @@ if (raw) { | ||
| } else { | ||
| if (noDecimal === true && amount > 1.0) { | ||
| return formatCurrencyOverride( | ||
| currencyFormatterNoDecimal.format(amount), | ||
| locale | ||
| ); | ||
| } | ||
| if (raw) { | ||
@@ -351,2 +364,2 @@ if (amount < 0.001) { | ||
| })); | ||
| }))); |
+2
-2
| { | ||
| "name": "@coingecko/cryptoformat", | ||
| "version": "0.3.4", | ||
| "version": "0.3.5", | ||
| "description": "Javascript library to format and display cryptocurrencies and fiat", | ||
@@ -40,2 +40,2 @@ "main": "lib/cryptoformat.cjs.js", | ||
| ] | ||
| } | ||
| } |
+5
-0
@@ -39,2 +39,7 @@ # Cryptoformat | ||
| // "123.400 €" | ||
| // Provide noDecimal = true to explicitly remove decimal for numbers above > 1.0 | ||
| formatCurrency(4000.23, "USD", "en", false, true); | ||
| // "$4,000" | ||
| ``` | ||
@@ -41,0 +46,0 @@ |
35766
3.52%983
3.8%71
7.58%