MISC: Update formatHashes function (#1252)

When hash/hashRate value is too small, formatHashes converts it to the useless string 0.000. This PR fixes that.
This commit is contained in:
catloversg 2024-05-10 15:38:38 +07:00 committed by GitHub
parent 309cd55085
commit 2414949c2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -148,7 +148,18 @@ export const formatFavor = formatNumberNoSuffix;
/** Standard noninteger formatting with no options set. Collapses to suffix at 1000 and shows 3 fractional digits. */ /** Standard noninteger formatting with no options set. Collapses to suffix at 1000 and shows 3 fractional digits. */
export const formatBigNumber = (n: number) => formatNumber(n); export const formatBigNumber = (n: number) => formatNumber(n);
export const formatExp = formatBigNumber; export const formatExp = formatBigNumber;
export const formatHashes = formatBigNumber; export const formatHashes = (n: number) => {
if (n < 0.00001) {
return formatNumber(n, 8);
}
if (n < 0.001) {
return formatNumber(n, 6);
}
if (n < 0.01) {
return formatNumber(n, 4);
}
return formatNumber(n);
};
export const formatReputation = formatBigNumber; export const formatReputation = formatBigNumber;
export const formatPopulation = formatBigNumber; export const formatPopulation = formatBigNumber;
export const formatSecurity = formatBigNumber; export const formatSecurity = formatBigNumber;