@qlibs/utils 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/number.js +7 -3
- package/package.json +1 -1
package/dist/utils/number.js
CHANGED
@@ -70,7 +70,11 @@ function formatNumber(num, locale = 'id-ID', currency) {
|
|
70
70
|
num = 0;
|
71
71
|
}
|
72
72
|
if (currency) {
|
73
|
-
return new Intl.NumberFormat(locale, {
|
73
|
+
return new Intl.NumberFormat(locale, {
|
74
|
+
style: 'currency',
|
75
|
+
currency,
|
76
|
+
minimumFractionDigits: 0,
|
77
|
+
}).format(Number(num));
|
74
78
|
}
|
75
79
|
else {
|
76
80
|
return new Intl.NumberFormat(locale).format(Number(num));
|
@@ -80,8 +84,8 @@ function parseFormattedNumber(formattedString, locale = 'id-ID', currency) {
|
|
80
84
|
if (!formattedString) {
|
81
85
|
return 0;
|
82
86
|
}
|
83
|
-
const exampleNumber =
|
84
|
-
const formattedExample = new Intl.NumberFormat(locale, currency ? { style: 'currency', currency } : {}).format(exampleNumber);
|
87
|
+
const exampleNumber = 12345678912345.6;
|
88
|
+
const formattedExample = new Intl.NumberFormat(locale, currency ? { style: 'currency', currency, minimumFractionDigits: 0 } : {}).format(exampleNumber);
|
85
89
|
const nonDigitChars = formattedExample.replace(/\d/g, '');
|
86
90
|
const thousandSeparator = nonDigitChars[0] || ',';
|
87
91
|
const decimalSeparator = nonDigitChars[1] || '.';
|