@ledgerhq/lumen-utils-shared 0.1.5 → 0.1.6

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.js CHANGED
@@ -30,13 +30,14 @@ function Q(t, e = {}) {
30
30
  return n = n.replace(/\D/g, ""), s > 0 && n.length > s && (n = n.slice(0, s)), o ? A(n) : n;
31
31
  n === "." && (n = "0.");
32
32
  const u = n.indexOf(".");
33
- if (u !== -1) {
33
+ if (u === -1)
34
+ s > 0 && n.length > s && (n = n.slice(0, s));
35
+ else {
34
36
  let a = n.slice(0, u), f = n.slice(u + 1).replace(/\./g, "");
35
37
  s > 0 && a.length > s && (a = a.slice(0, s)), f = f.slice(0, l), a === "" && (a = "0");
36
38
  const h = i.endsWith(".") || n.endsWith(".");
37
39
  n = f.length > 0 ? `${a}.${f}` : h ? `${a}.` : a;
38
- } else
39
- s > 0 && n.length > s && (n = n.slice(0, s));
40
+ }
40
41
  return o ? A(n) : n;
41
42
  }
42
43
  function q(t, e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/lumen-utils-shared",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -61,7 +61,12 @@ export function textFormatter(
61
61
  }
62
62
 
63
63
  const firstDot = cleaned.indexOf('.');
64
- if (firstDot !== -1) {
64
+ if (firstDot === -1) {
65
+ // No decimal point, just apply integer length limit
66
+ if (maxIntegerLength > 0 && cleaned.length > maxIntegerLength) {
67
+ cleaned = cleaned.slice(0, maxIntegerLength);
68
+ }
69
+ } else {
65
70
  // Split integer and decimal parts
66
71
  let integerPart = cleaned.slice(0, firstDot);
67
72
  let decimalPart = cleaned.slice(firstDot + 1).replace(/\./g, '');
@@ -84,11 +89,6 @@ export function textFormatter(
84
89
  : hasTrailingDot
85
90
  ? `${integerPart}.`
86
91
  : integerPart;
87
- } else {
88
- // No decimal point, just apply integer length limit
89
- if (maxIntegerLength > 0 && cleaned.length > maxIntegerLength) {
90
- cleaned = cleaned.slice(0, maxIntegerLength);
91
- }
92
92
  }
93
93
 
94
94
  return thousandsSeparator ? formatThousands(cleaned) : cleaned;