@talismn/util 0.5.5 → 0.5.6
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.
|
@@ -128,9 +128,11 @@ const formatDecimals = (num, digits = MIN_DIGITS, options = {}, locale = "en-US"
|
|
|
128
128
|
// format
|
|
129
129
|
|
|
130
130
|
return Intl.NumberFormat(locale, {
|
|
131
|
-
//compact notation (K, M, B) if above 9999
|
|
131
|
+
// compact notation (K, M, B) if above 9999
|
|
132
132
|
notation: truncatedValue.gt(9999) ? "compact" : "standard",
|
|
133
|
-
|
|
133
|
+
// NOTE: possible values are from `0` to `21`
|
|
134
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumsignificantdigits
|
|
135
|
+
maximumSignificantDigits: Math.max(1, Math.min(digits + (truncatedValue.lt(1) ? 1 : 0), 21)),
|
|
134
136
|
...options
|
|
135
137
|
}).format(truncatedValue.toNumber());
|
|
136
138
|
};
|
|
@@ -128,9 +128,11 @@ const formatDecimals = (num, digits = MIN_DIGITS, options = {}, locale = "en-US"
|
|
|
128
128
|
// format
|
|
129
129
|
|
|
130
130
|
return Intl.NumberFormat(locale, {
|
|
131
|
-
//compact notation (K, M, B) if above 9999
|
|
131
|
+
// compact notation (K, M, B) if above 9999
|
|
132
132
|
notation: truncatedValue.gt(9999) ? "compact" : "standard",
|
|
133
|
-
|
|
133
|
+
// NOTE: possible values are from `0` to `21`
|
|
134
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumsignificantdigits
|
|
135
|
+
maximumSignificantDigits: Math.max(1, Math.min(digits + (truncatedValue.lt(1) ? 1 : 0), 21)),
|
|
134
136
|
...options
|
|
135
137
|
}).format(truncatedValue.toNumber());
|
|
136
138
|
};
|
package/dist/talismn-util.esm.js
CHANGED
|
@@ -122,9 +122,11 @@ const formatDecimals = (num, digits = MIN_DIGITS, options = {}, locale = "en-US"
|
|
|
122
122
|
// format
|
|
123
123
|
|
|
124
124
|
return Intl.NumberFormat(locale, {
|
|
125
|
-
//compact notation (K, M, B) if above 9999
|
|
125
|
+
// compact notation (K, M, B) if above 9999
|
|
126
126
|
notation: truncatedValue.gt(9999) ? "compact" : "standard",
|
|
127
|
-
|
|
127
|
+
// NOTE: possible values are from `0` to `21`
|
|
128
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumsignificantdigits
|
|
129
|
+
maximumSignificantDigits: Math.max(1, Math.min(digits + (truncatedValue.lt(1) ? 1 : 0), 21)),
|
|
128
130
|
...options
|
|
129
131
|
}).format(truncatedValue.toNumber());
|
|
130
132
|
};
|