Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 26cba30

Browse files
committed
Use Intl standard instead of toLocaleString() for number formatting
1 parent 684f38d commit 26cba30

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/helper.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export const formatNumber = val => {
1414
if (isNaN(num)) {
1515
num = 0;
1616
}
17-
return num.toLocaleString(undefined, { maximumFractionDigits: 8 });
17+
const options = { maximumFractionDigits: 8 };
18+
return new Intl.NumberFormat(undefined, options).format(num);
1819
};
1920

2021
/**
@@ -28,7 +29,8 @@ export const formatFiat = (val, currency) => {
2829
if (isNaN(num)) {
2930
num = 0;
3031
}
31-
return num.toLocaleString(undefined, { style: 'currency', currency });
32+
const options = { style: 'currency', currency };
33+
return new Intl.NumberFormat(undefined, options).format(num);
3234
};
3335

3436
/**
@@ -83,10 +85,8 @@ export const toAmount = (satoshis, settings) => {
8385
const num = settings.displayFiat
8486
? calculateExchangeRate(satoshis, settings)
8587
: satoshis / UNITS[settings.unit].denominator;
86-
return num.toLocaleString('en-US', {
87-
useGrouping: false,
88-
maximumFractionDigits: 8,
89-
});
88+
const options = { useGrouping: false, maximumFractionDigits: 8 };
89+
return new Intl.NumberFormat('en-US', options).format(num);
9090
};
9191

9292
/**

0 commit comments

Comments
 (0)