@ocap/util 1.28.9 → 1.29.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/esm/bn.mjs +1 -1
- package/esm/index.mjs +4 -1
- package/esm/retry.mjs +1 -0
- package/lib/bn.cjs +1 -1
- package/lib/index.cjs +4 -1
- package/lib/retry.cjs +1 -0
- package/package.json +4 -5
package/esm/bn.mjs
CHANGED
package/esm/index.mjs
CHANGED
|
@@ -298,7 +298,10 @@ const fromUnitToToken = (input, decimal = 18, optionsInput = {}) => {
|
|
|
298
298
|
if (negative) unit = unit.mul(negative1);
|
|
299
299
|
let fraction = unit.mod(base).toString(10);
|
|
300
300
|
while (fraction.length < baseLength) fraction = `0${fraction}`;
|
|
301
|
-
if (!options.pad)
|
|
301
|
+
if (!options.pad) {
|
|
302
|
+
const match = fraction.match(/^([0-9]*[1-9]|0)(0*)/);
|
|
303
|
+
fraction = match ? match[1] : fraction;
|
|
304
|
+
}
|
|
302
305
|
let whole = unit.div(base).toString(10);
|
|
303
306
|
if (options.commify) whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
304
307
|
let value = `${whole}${fraction === "0" ? "" : `.${fraction}`}`;
|
package/esm/retry.mjs
CHANGED
package/lib/bn.cjs
CHANGED
|
@@ -5,7 +5,7 @@ bn_js = require_rolldown_runtime.__toESM(bn_js);
|
|
|
5
5
|
//#region src/bn.ts
|
|
6
6
|
var BN = class extends bn_js.default {
|
|
7
7
|
constructor(value, base, endian) {
|
|
8
|
-
super(value === null ? "0" : value, base, endian);
|
|
8
|
+
super(value === null || value === void 0 ? "0" : value, base, endian);
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
|
package/lib/index.cjs
CHANGED
|
@@ -312,7 +312,10 @@ const fromUnitToToken = (input, decimal = 18, optionsInput = {}) => {
|
|
|
312
312
|
if (negative) unit = unit.mul(negative1);
|
|
313
313
|
let fraction = unit.mod(base).toString(10);
|
|
314
314
|
while (fraction.length < baseLength) fraction = `0${fraction}`;
|
|
315
|
-
if (!options.pad)
|
|
315
|
+
if (!options.pad) {
|
|
316
|
+
const match = fraction.match(/^([0-9]*[1-9]|0)(0*)/);
|
|
317
|
+
fraction = match ? match[1] : fraction;
|
|
318
|
+
}
|
|
316
319
|
let whole = unit.div(base).toString(10);
|
|
317
320
|
if (options.commify) whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
318
321
|
let value = `${whole}${fraction === "0" ? "" : `.${fraction}`}`;
|
package/lib/retry.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/util",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "utils shared across multiple forge js libs, works in both node.js and browser",
|
|
6
6
|
"keywords": [
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@ocap/types": "1.
|
|
15
|
+
"@ocap/types": "1.29.0",
|
|
16
16
|
"@types/bn.js": "^5.2.0",
|
|
17
17
|
"base64-url": "^2.3.3",
|
|
18
18
|
"bn.js": "5.2.2",
|
|
19
19
|
"bs58": "^5.0.0",
|
|
20
20
|
"ipaddr.js": "^2.1.0",
|
|
21
|
-
"lodash": "^4.17.
|
|
21
|
+
"lodash": "^4.17.23",
|
|
22
22
|
"utf8": "^3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"resolutions": {
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
"@types/node": "^22.7.5",
|
|
31
31
|
"@types/utf8": "^3.0.3",
|
|
32
32
|
"tsdown": "^0.18.4",
|
|
33
|
-
"type-fest": "^3.1.0"
|
|
34
|
-
"typescript": "^5.6.2"
|
|
33
|
+
"type-fest": "^3.1.0"
|
|
35
34
|
},
|
|
36
35
|
"author": {
|
|
37
36
|
"name": "wangshijun",
|