@talismn/util 0.1.3 → 0.1.4
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 +6 -0
- package/dist/formatDecimals.js +4 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/sleep.d.ts +1 -0
- package/dist/sleep.js +5 -0
- package/dist/throwAfter.d.ts +1 -0
- package/dist/throwAfter.js +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/formatDecimals.js
CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.formatDecimals = exports.MAX_DECIMALS_FORMAT = void 0;
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
8
|
+
const MIN_DIGITS = 4; // less truncates more than what compact formating is
|
8
9
|
exports.MAX_DECIMALS_FORMAT = 12;
|
9
10
|
/**
|
10
11
|
* Custom decimal number formatting for Talisman
|
@@ -15,9 +16,11 @@ exports.MAX_DECIMALS_FORMAT = 12;
|
|
15
16
|
* @param options formatting options
|
16
17
|
* @returns the formatted value
|
17
18
|
*/
|
18
|
-
const formatDecimals = (num, digits =
|
19
|
+
const formatDecimals = (num, digits = MIN_DIGITS, options = {}, locale = "en-US") => {
|
19
20
|
if (num === null || num === undefined)
|
20
21
|
return "";
|
22
|
+
if (digits < MIN_DIGITS)
|
23
|
+
digits = MIN_DIGITS;
|
21
24
|
const value = new bignumber_js_1.default(num);
|
22
25
|
// very small numbers should display "< 0.0001"
|
23
26
|
const minDisplayVal = 1 / Math.pow(10, digits);
|
package/dist/index.d.ts
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
export * from "./BigMath";
|
2
|
-
export * from "./FunctionPropertyNames";
|
3
2
|
export * from "./blake2Concat";
|
4
3
|
export * from "./decodeAnyAddress";
|
5
4
|
export * from "./encodeAnyAddress";
|
6
5
|
export * from "./formatDecimals";
|
6
|
+
export * from "./FunctionPropertyNames";
|
7
7
|
export * from "./getBase64ImageUrl";
|
8
8
|
export * from "./hasOwnProperty";
|
9
9
|
export * from "./isArrayOf";
|
10
10
|
export * from "./planckToTokens";
|
11
|
+
export * from "./sleep";
|
12
|
+
export * from "./throwAfter";
|
11
13
|
export * from "./tokensToPlanck";
|
12
14
|
export * from "./twox64Concat";
|
package/dist/index.js
CHANGED
@@ -15,14 +15,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./BigMath"), exports);
|
18
|
-
__exportStar(require("./FunctionPropertyNames"), exports);
|
19
18
|
__exportStar(require("./blake2Concat"), exports);
|
20
19
|
__exportStar(require("./decodeAnyAddress"), exports);
|
21
20
|
__exportStar(require("./encodeAnyAddress"), exports);
|
22
21
|
__exportStar(require("./formatDecimals"), exports);
|
22
|
+
__exportStar(require("./FunctionPropertyNames"), exports);
|
23
23
|
__exportStar(require("./getBase64ImageUrl"), exports);
|
24
24
|
__exportStar(require("./hasOwnProperty"), exports);
|
25
25
|
__exportStar(require("./isArrayOf"), exports);
|
26
26
|
__exportStar(require("./planckToTokens"), exports);
|
27
|
+
__exportStar(require("./sleep"), exports);
|
28
|
+
__exportStar(require("./throwAfter"), exports);
|
27
29
|
__exportStar(require("./tokensToPlanck"), exports);
|
28
30
|
__exportStar(require("./twox64Concat"), exports);
|
package/dist/sleep.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const sleep: (ms: number) => Promise<void>;
|
package/dist/sleep.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const throwAfter: (ms: number, reason: string) => Promise<void>;
|