@davigomesdev/format 0.0.1 → 0.0.2
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/format.d.ts.map +1 -1
- package/dist/format.js +4 -1
- package/package.json +1 -1
package/dist/format.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,qBAAa,MAAM;WACH,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAE,MAAW,GAAG,MAAM;WAKhE,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,GAAE,MAAW,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,qBAAa,MAAM;WACH,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAE,MAAW,GAAG,MAAM;WAKhE,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,GAAE,MAAW,GAAG,MAAM;WASjE,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,GAAE,MAAW,EAAE,SAAS,GAAE,MAAW,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;WAWxH,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,WAAW,GAAE,MAAW,GAAG,MAAM;WAoB1E,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,GAAE,MAAU,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM;WAWpF,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;WAItC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,GAAE,MAAW,GAAG,MAAM;WAgBpE,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAOzD"}
|
package/dist/format.js
CHANGED
|
@@ -7,7 +7,10 @@ export class Format {
|
|
|
7
7
|
}
|
|
8
8
|
static formatFromWei(value, decimals = 18) {
|
|
9
9
|
const num = Format.formatTrimDecimals(value.toString(), decimals);
|
|
10
|
-
|
|
10
|
+
const fromWei = formatUnits(num, decimals);
|
|
11
|
+
if (!fromWei.includes('.'))
|
|
12
|
+
return fromWei;
|
|
13
|
+
return fromWei.replace(/\.?0+$/, '');
|
|
11
14
|
}
|
|
12
15
|
static formatCompareWei(valueA, valueB, decimalsA = 18, decimalsB = 18) {
|
|
13
16
|
const a = BigInt(valueA.toString());
|