use parseFloat for the amount argument

This commit is contained in:
Akinwale Ariwodola 2018-10-28 18:22:00 +01:00
parent f193d38c61
commit 03eb586b30
2 changed files with 7 additions and 3 deletions

3
dist/bundle.js vendored
View file

@ -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) {

View file

@ -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