@talismn/util 0.1.4 → 0.1.5
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/CHANGELOG.md +7 -0
- package/dist/formatDecimals.d.ts +2 -1
- package/dist/formatDecimals.js +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/formatDecimals.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import BigNumber from "bignumber.js";
|
1
2
|
export declare const MAX_DECIMALS_FORMAT = 12;
|
2
3
|
/**
|
3
4
|
* Custom decimal number formatting for Talisman
|
@@ -8,4 +9,4 @@ export declare const MAX_DECIMALS_FORMAT = 12;
|
|
8
9
|
* @param options formatting options
|
9
10
|
* @returns the formatted value
|
10
11
|
*/
|
11
|
-
export declare const formatDecimals: (num?: string | number | null, digits?: number, options?: Partial<Intl.NumberFormatOptions>, locale?: string) => string;
|
12
|
+
export declare const formatDecimals: (num?: string | number | null | BigNumber, digits?: number, options?: Partial<Intl.NumberFormatOptions>, locale?: string) => string;
|
package/dist/formatDecimals.js
CHANGED
@@ -47,8 +47,11 @@ const formatDecimals = (num, digits = MIN_DIGITS, options = {}, locale = "en-US"
|
|
47
47
|
.integerValue()
|
48
48
|
.multipliedBy(excessIntegerDigitsPow10);
|
49
49
|
// format
|
50
|
-
return Intl.NumberFormat(locale,
|
50
|
+
return Intl.NumberFormat(locale, {
|
51
51
|
//compact notation (K, M, B) if above 9999
|
52
|
-
notation: truncatedValue.gt(9999) ? "compact" : "standard",
|
52
|
+
notation: truncatedValue.gt(9999) ? "compact" : "standard",
|
53
|
+
maximumSignificantDigits: digits + (truncatedValue.lt(1) ? 1 : 0),
|
54
|
+
...options,
|
55
|
+
}).format(truncatedValue.toNumber());
|
53
56
|
};
|
54
57
|
exports.formatDecimals = formatDecimals;
|