@hairy/ether-lib 1.34.0 → 1.35.0
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/index.cjs +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.global.js +4 -1
- package/dist/index.js +2 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -71,12 +71,13 @@ function idprefix(errorCallString) {
|
|
|
71
71
|
var import_utils = require("@hairy/utils");
|
|
72
72
|
var import_ethers2 = require("ethers");
|
|
73
73
|
function formatEther(value = "0", options = {}) {
|
|
74
|
-
const { separator = false, decimals, delimiters = false, rounding, zeromove = true } = options;
|
|
74
|
+
const { separator = false, decimals, delimiters = false, rounding, zeromove = true, default: _default } = options;
|
|
75
75
|
const number = (0, import_ethers2.formatEther)((0, import_utils.bignum)(value).toFixed(0));
|
|
76
76
|
const groupSeparator = separator === false ? "" : ",";
|
|
77
77
|
return (0, import_utils.formatNumeric)(number, {
|
|
78
78
|
format: { groupSeparator, ...options.format },
|
|
79
79
|
delimiters: typeof delimiters === "boolean" ? delimiters && ["m", "b", "t"] : delimiters,
|
|
80
|
+
default: _default,
|
|
80
81
|
decimals,
|
|
81
82
|
rounding,
|
|
82
83
|
zeromove
|
package/dist/index.d.ts
CHANGED
package/dist/index.global.js
CHANGED
|
@@ -110,6 +110,8 @@
|
|
|
110
110
|
return options || { v: 1, d: 0, n: "" };
|
|
111
111
|
}
|
|
112
112
|
function formatNumeric(value = "0", options) {
|
|
113
|
+
if (options?.default && bignum(value).isZero())
|
|
114
|
+
return options?.default;
|
|
113
115
|
const {
|
|
114
116
|
rounding = import_bignumber.default.ROUND_DOWN,
|
|
115
117
|
delimiters,
|
|
@@ -133,12 +135,13 @@
|
|
|
133
135
|
// src/number.ts
|
|
134
136
|
var import_ethers2 = __toESM(require_ethers(), 1);
|
|
135
137
|
function formatEther(value = "0", options = {}) {
|
|
136
|
-
const { separator = false, decimals, delimiters = false, rounding, zeromove: zeromove2 = true } = options;
|
|
138
|
+
const { separator = false, decimals, delimiters = false, rounding, zeromove: zeromove2 = true, default: _default } = options;
|
|
137
139
|
const number = (0, import_ethers2.formatEther)(bignum(value).toFixed(0));
|
|
138
140
|
const groupSeparator = separator === false ? "" : ",";
|
|
139
141
|
return formatNumeric(number, {
|
|
140
142
|
format: { groupSeparator, ...options.format },
|
|
141
143
|
delimiters: typeof delimiters === "boolean" ? delimiters && ["m", "b", "t"] : delimiters,
|
|
144
|
+
default: _default,
|
|
142
145
|
decimals,
|
|
143
146
|
rounding,
|
|
144
147
|
zeromove: zeromove2
|
package/dist/index.js
CHANGED
|
@@ -32,12 +32,13 @@ function idprefix(errorCallString) {
|
|
|
32
32
|
import { bignum, formatNumeric } from "@hairy/utils";
|
|
33
33
|
import { formatEther as _formatEther } from "ethers";
|
|
34
34
|
function formatEther(value = "0", options = {}) {
|
|
35
|
-
const { separator = false, decimals, delimiters = false, rounding, zeromove = true } = options;
|
|
35
|
+
const { separator = false, decimals, delimiters = false, rounding, zeromove = true, default: _default } = options;
|
|
36
36
|
const number = _formatEther(bignum(value).toFixed(0));
|
|
37
37
|
const groupSeparator = separator === false ? "" : ",";
|
|
38
38
|
return formatNumeric(number, {
|
|
39
39
|
format: { groupSeparator, ...options.format },
|
|
40
40
|
delimiters: typeof delimiters === "boolean" ? delimiters && ["m", "b", "t"] : delimiters,
|
|
41
|
+
default: _default,
|
|
41
42
|
decimals,
|
|
42
43
|
rounding,
|
|
43
44
|
zeromove
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hairy/ether-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.35.0",
|
|
5
5
|
"description": "Library for ether",
|
|
6
6
|
"author": "Hairyf <wwu710632@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"mitt": "^3.0.1",
|
|
29
|
-
"@hairy/utils": "1.
|
|
29
|
+
"@hairy/utils": "1.35.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"ethers": "^6"
|