Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@coingecko/cryptoformat

Package Overview
Dependencies
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coingecko/cryptoformat - npm Package Compare versions

Comparing version
0.4.3
to
0.4.4
+24
-12
lib/cryptoformat.cjs.js

@@ -187,2 +187,3 @@ 'use strict';

let currencyFormatterVerySmall;
let currencyFormatterVeryVerySmall;

@@ -219,2 +220,5 @@ // If a page has to display multiple currencies, formatters would have to be created for each of them

: generateFormatter(isoCode, locale, 8);
currencyFormatterVeryVerySmall = cachedFormatter
? cachedFormatter.currencyFormatterVeryVerySmall
: generateFormatter(isoCode, locale, 12);

@@ -225,13 +229,8 @@ // Save in cache

formattersCache[cacheKey].currencyFormatterNormal = currencyFormatterNormal;
formattersCache[
cacheKey
].currencyFormatterNoDecimal = currencyFormatterNoDecimal;
formattersCache[cacheKey].currencyFormatterNoDecimal = currencyFormatterNoDecimal;
formattersCache[cacheKey].currencyFormatterMedium = currencyFormatterMedium;
formattersCache[
cacheKey
].currencyFormatterTwoDecimal = currencyFormatterTwoDecimal;
formattersCache[cacheKey].currencyFormatterTwoDecimal = currencyFormatterTwoDecimal;
formattersCache[cacheKey].currencyFormatterSmall = currencyFormatterSmall;
formattersCache[
cacheKey
].currencyFormatterVerySmall = currencyFormatterVerySmall;
formattersCache[cacheKey].currencyFormatterVerySmall = currencyFormatterVerySmall;
formattersCache[cacheKey].currencyFormatterVeryVerySmall = currencyFormatterVeryVerySmall;
}

@@ -346,4 +345,4 @@ }

);
} else {
// Crypto amount < 1, show 8 fraction digits
} else if (price >= 0.000001 && price < 1.0) {
// crypto amount, show 8 fraction digits
return formatCurrencyOverride(

@@ -353,2 +352,8 @@ currencyFormatterVerySmall.format(amount),

);
} else {
// Crypto amount < 0.000001, show 12 fraction digits
return formatCurrencyOverride(
currencyFormatterVeryVerySmall.format(amount),
locale
);
}

@@ -358,3 +363,5 @@ } else {

if (raw) {
if (unsigned_amount < 0.001) {
if (unsigned_amount < 0.00001) {
return amount.toFixed(12);
} else if (unsigned_amount < 0.001) {
return amount.toFixed(8);

@@ -373,2 +380,7 @@ } else if (unsigned_amount < 1.0) {

);
} else if (unsigned_amount < 0.000001) {
return formatCurrencyOverride(
currencyFormatterVeryVerySmall.format(amount),
locale
);
} else if (unsigned_amount < 0.05) {

@@ -375,0 +387,0 @@ return formatCurrencyOverride(

@@ -183,2 +183,3 @@ // A map of supported currency codes to currency symbols.

let currencyFormatterVerySmall;
let currencyFormatterVeryVerySmall;

@@ -215,2 +216,5 @@ // If a page has to display multiple currencies, formatters would have to be created for each of them

: generateFormatter(isoCode, locale, 8);
currencyFormatterVeryVerySmall = cachedFormatter
? cachedFormatter.currencyFormatterVeryVerySmall
: generateFormatter(isoCode, locale, 12);

@@ -221,13 +225,8 @@ // Save in cache

formattersCache[cacheKey].currencyFormatterNormal = currencyFormatterNormal;
formattersCache[
cacheKey
].currencyFormatterNoDecimal = currencyFormatterNoDecimal;
formattersCache[cacheKey].currencyFormatterNoDecimal = currencyFormatterNoDecimal;
formattersCache[cacheKey].currencyFormatterMedium = currencyFormatterMedium;
formattersCache[
cacheKey
].currencyFormatterTwoDecimal = currencyFormatterTwoDecimal;
formattersCache[cacheKey].currencyFormatterTwoDecimal = currencyFormatterTwoDecimal;
formattersCache[cacheKey].currencyFormatterSmall = currencyFormatterSmall;
formattersCache[
cacheKey
].currencyFormatterVerySmall = currencyFormatterVerySmall;
formattersCache[cacheKey].currencyFormatterVerySmall = currencyFormatterVerySmall;
formattersCache[cacheKey].currencyFormatterVeryVerySmall = currencyFormatterVeryVerySmall;
}

@@ -342,4 +341,4 @@ }

);
} else {
// Crypto amount < 1, show 8 fraction digits
} else if (price >= 0.000001 && price < 1.0) {
// crypto amount, show 8 fraction digits
return formatCurrencyOverride(

@@ -349,2 +348,8 @@ currencyFormatterVerySmall.format(amount),

);
} else {
// Crypto amount < 0.000001, show 12 fraction digits
return formatCurrencyOverride(
currencyFormatterVeryVerySmall.format(amount),
locale
);
}

@@ -354,3 +359,5 @@ } else {

if (raw) {
if (unsigned_amount < 0.001) {
if (unsigned_amount < 0.00001) {
return amount.toFixed(12);
} else if (unsigned_amount < 0.001) {
return amount.toFixed(8);

@@ -369,2 +376,7 @@ } else if (unsigned_amount < 1.0) {

);
} else if (unsigned_amount < 0.000001) {
return formatCurrencyOverride(
currencyFormatterVeryVerySmall.format(amount),
locale
);
} else if (unsigned_amount < 0.05) {

@@ -371,0 +383,0 @@ return formatCurrencyOverride(

@@ -189,2 +189,3 @@ (function (global, factory) {

let currencyFormatterVerySmall;
let currencyFormatterVeryVerySmall;

@@ -221,2 +222,5 @@ // If a page has to display multiple currencies, formatters would have to be created for each of them

: generateFormatter(isoCode, locale, 8);
currencyFormatterVeryVerySmall = cachedFormatter
? cachedFormatter.currencyFormatterVeryVerySmall
: generateFormatter(isoCode, locale, 12);

@@ -227,13 +231,8 @@ // Save in cache

formattersCache[cacheKey].currencyFormatterNormal = currencyFormatterNormal;
formattersCache[
cacheKey
].currencyFormatterNoDecimal = currencyFormatterNoDecimal;
formattersCache[cacheKey].currencyFormatterNoDecimal = currencyFormatterNoDecimal;
formattersCache[cacheKey].currencyFormatterMedium = currencyFormatterMedium;
formattersCache[
cacheKey
].currencyFormatterTwoDecimal = currencyFormatterTwoDecimal;
formattersCache[cacheKey].currencyFormatterTwoDecimal = currencyFormatterTwoDecimal;
formattersCache[cacheKey].currencyFormatterSmall = currencyFormatterSmall;
formattersCache[
cacheKey
].currencyFormatterVerySmall = currencyFormatterVerySmall;
formattersCache[cacheKey].currencyFormatterVerySmall = currencyFormatterVerySmall;
formattersCache[cacheKey].currencyFormatterVeryVerySmall = currencyFormatterVeryVerySmall;
}

@@ -348,4 +347,4 @@ }

);
} else {
// Crypto amount < 1, show 8 fraction digits
} else if (price >= 0.000001 && price < 1.0) {
// crypto amount, show 8 fraction digits
return formatCurrencyOverride(

@@ -355,2 +354,8 @@ currencyFormatterVerySmall.format(amount),

);
} else {
// Crypto amount < 0.000001, show 12 fraction digits
return formatCurrencyOverride(
currencyFormatterVeryVerySmall.format(amount),
locale
);
}

@@ -360,3 +365,5 @@ } else {

if (raw) {
if (unsigned_amount < 0.001) {
if (unsigned_amount < 0.00001) {
return amount.toFixed(12);
} else if (unsigned_amount < 0.001) {
return amount.toFixed(8);

@@ -375,2 +382,7 @@ } else if (unsigned_amount < 1.0) {

);
} else if (unsigned_amount < 0.000001) {
return formatCurrencyOverride(
currencyFormatterVeryVerySmall.format(amount),
locale
);
} else if (unsigned_amount < 0.05) {

@@ -377,0 +389,0 @@ return formatCurrencyOverride(

{
"name": "@coingecko/cryptoformat",
"version": "0.4.3",
"version": "0.4.4",
"description": "Javascript library to format and display cryptocurrencies and fiat",

@@ -5,0 +5,0 @@ "main": "lib/cryptoformat.cjs.js",