@argent/x-shared 1.41.7 → 1.42.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(r,n){let[e,t=""]=r.split(".");const i=e.startsWith("-");return i&&(e=e.slice(1)),t.length>n?Number(t[n])>=5?t=(BigInt(t.slice(0,n))+1n).toString().padStart(n,"0"):t=t.slice(0,n):t=t.padEnd(n,"0"),{value:BigInt(`${i?"-":""}${e}${t}`),decimals:n}}exports.parseUnits=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(n,t)=>{const[o,e=""]=n.split("."),s=o.startsWith("-"),i=s?o.slice(1):o,r=t??e.length,a=e.slice(0,r),c=t!==void 0&&e.length>t?l(a,e[t]):a.padEnd(r,"0");return{value:BigInt(`${s?"-":""}${i}${c}`),decimals:r}},l=(n,t)=>Number(t)>=5?(BigInt(n)+1n).toString().padStart(n.length,"0"):n;exports.parseUnits=u;
@@ -1,10 +1,10 @@
1
1
  import { BigDecimal } from './types';
2
2
  /**
3
- * Parses a string value representing a number to a BigInt, with a specified number of decimals.
4
- * If the fraction part of the string value is longer than the allowed decimal places, it rounds the value.
3
+ * Parses a string value representing a number to a BigInt, with a specified or determined number of decimals.
4
+ * If decimals are specified and the fraction part of the string value is longer than the allowed decimal places, it rounds the value.
5
5
  *
6
6
  * @param {string} value - The string value to be parsed.
7
- * @param {number} decimals - The number of decimals to consider during parsing.
8
- * @returns {bigint} The parsed BigInt value.
7
+ * @param {number} [decimals] - The number of decimals to consider during parsing. If not provided, it uses as many as needed.
8
+ * @returns {BigDecimal} The parsed BigDecimal value.
9
9
  */
10
- export declare function parseUnits(value: string, decimals: number): BigDecimal;
10
+ export declare const parseUnits: (value: string, decimals?: number) => BigDecimal;
@@ -1,11 +1,10 @@
1
- function g(r, n) {
2
- let [e, t = ""] = r.split(".");
3
- const i = e.startsWith("-");
4
- return i && (e = e.slice(1)), t.length > n ? Number(t[n]) >= 5 ? t = (BigInt(t.slice(0, n)) + 1n).toString().padStart(n, "0") : t = t.slice(0, n) : t = t.padEnd(n, "0"), {
5
- value: BigInt(`${i ? "-" : ""}${e}${t}`),
6
- decimals: n
1
+ const d = (n, t) => {
2
+ const [e, o = ""] = n.split("."), s = e.startsWith("-"), c = s ? e.slice(1) : e, r = t ?? o.length, a = o.slice(0, r), i = t !== void 0 && o.length > t ? u(a, o[t]) : a.padEnd(r, "0");
3
+ return {
4
+ value: BigInt(`${s ? "-" : ""}${c}${i}`),
5
+ decimals: r
7
6
  };
8
- }
7
+ }, u = (n, t) => Number(t) >= 5 ? (BigInt(n) + 1n).toString().padStart(n.length, "0") : n;
9
8
  export {
10
- g as parseUnits
9
+ d as parseUnits
11
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.41.7",
3
+ "version": "1.42.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"