@leaderty/utils 2.1.0 → 2.1.1

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/README.md CHANGED
@@ -97,7 +97,7 @@ dateToMonthYearLong('2026-10-01') // "octubre de 2026" (not September)
97
97
 
98
98
  ### `numberToDecimalString(numero)`
99
99
 
100
- Formats a number with two decimals and thousands separators. Rounds with `toFixed(2)`, so `1.005` gives `1,00`; prefer `numberToMoney(n, { decimals: 2 })` in new code. Formerly `numberToStringWithDecimals`, which stays as a deprecated alias.
100
+ Formats a number with two decimals and thousands separators. Rounds like `numberToMoney(n, { decimals: 2 })`, so `1.005` gives `1,01`. Formerly `numberToStringWithDecimals`, which stays as a deprecated alias.
101
101
 
102
102
  **Parameters:**
103
103
  - `numero` - `number`
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Formatea un número a una cadena con dos decimales y separadores de miles.
3
+ * Redondea igual que `numberToMoney(numero, { decimals: 2 })`: `1.005` da `1,01`.
3
4
  */
4
5
  export declare function numberToDecimalString(numero: number): string;
5
6
  /** @deprecated Renamed to {@link numberToDecimalString}. */
package/dist/index.js CHANGED
@@ -1,11 +1,10 @@
1
+ import { numberToMoney } from './format.js';
1
2
  /**
2
3
  * Formatea un número a una cadena con dos decimales y separadores de miles.
4
+ * Redondea igual que `numberToMoney(numero, { decimals: 2 })`: `1.005` da `1,01`.
3
5
  */
4
6
  export function numberToDecimalString(numero) {
5
- const formatted = numero.toFixed(2);
6
- const [integerPart, decimalPart] = formatted.split('.');
7
- const withThousandsSeparator = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
8
- return `${withThousandsSeparator},${decimalPart}`;
7
+ return numberToMoney(numero, { decimals: 2 });
9
8
  }
10
9
  /** @deprecated Renamed to {@link numberToDecimalString}. */
11
10
  export const numberToStringWithDecimals = numberToDecimalString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaderty/utils",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",