@ocap/util 1.28.8 → 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 CHANGED
@@ -3,7 +3,7 @@ import BaseBN from "bn.js";
3
3
  //#region src/bn.ts
4
4
  var BN = class extends BaseBN {
5
5
  constructor(value, base, endian) {
6
- super(value === null ? "0" : value, base, endian);
6
+ super(value === null || value === void 0 ? "0" : value, base, endian);
7
7
  }
8
8
  };
9
9
 
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) fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
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
@@ -23,6 +23,7 @@ async function withRetry(handle, { retryLimit = 30, backoff = {
23
23
  await wait(Math.random() * delay);
24
24
  }
25
25
  }
26
+ throw lastError;
26
27
  }
27
28
 
28
29
  //#endregion
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) fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
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
@@ -24,6 +24,7 @@ async function withRetry(handle, { retryLimit = 30, backoff = {
24
24
  await wait(Math.random() * delay);
25
25
  }
26
26
  }
27
+ throw lastError;
27
28
  }
28
29
 
29
30
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocap/util",
3
- "version": "1.28.8",
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.28.8",
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",
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",