Merge pull request #92 from lbryio/format-credits-tweak
use parseFloat for the amount argument
This commit is contained in:
commit
5ddcb60d31
2 changed files with 7 additions and 3 deletions
3
dist/bundle.js
vendored
3
dist/bundle.js
vendored
|
@ -5100,7 +5100,8 @@ exports.formatCredits = formatCredits;
|
|||
exports.formatFullPrice = formatFullPrice;
|
||||
exports.creditsToString = creditsToString;
|
||||
function formatCredits(amount, precision) {
|
||||
return amount.toFixed(precision || 1).replace(/\.?0+$/, '');
|
||||
if (Number.isNaN(parseFloat(amount))) return '0';
|
||||
return parseFloat(amount).toFixed(precision || 1).replace(/\.?0+$/, '');
|
||||
}
|
||||
|
||||
function formatFullPrice(amount) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
export function formatCredits(amount, precision) {
|
||||
return amount.toFixed(precision || 1).replace(/\.?0+$/, '');
|
||||
if (Number.isNaN(parseFloat(amount))) return '0';
|
||||
return parseFloat(amount)
|
||||
.toFixed(precision || 1)
|
||||
.replace(/\.?0+$/, '');
|
||||
}
|
||||
|
||||
export function formatFullPrice(amount, precision = 1) {
|
||||
|
@ -10,7 +13,7 @@ export function formatFullPrice(amount, precision = 1) {
|
|||
|
||||
if (fraction) {
|
||||
const decimals = fraction.split('');
|
||||
const first = decimals.filter(number => number !== '0')[0];
|
||||
const first = decimals.filter((number) => number !== '0')[0];
|
||||
const index = decimals.indexOf(first);
|
||||
|
||||
// Set format fraction
|
||||
|
|
Loading…
Reference in a new issue