@heyform-inc/utils 1.2.0 → 1.2.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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -36,7 +36,7 @@ declare function toInteger(value: unknown, defaults?: number, maxValue?: number)
|
|
|
36
36
|
declare const parseNumber: typeof toInteger;
|
|
37
37
|
declare const toInt: typeof toInteger;
|
|
38
38
|
declare function toFloat(value: unknown, defaults?: number, maxValue?: number): number | undefined;
|
|
39
|
-
declare function toFixed(value: number, precision?: number): string;
|
|
39
|
+
declare function toFixed(value: number, precision?: number): string | undefined;
|
|
40
40
|
declare function toJSON<T extends object>(str: unknown, defaults?: T): T | undefined;
|
|
41
41
|
declare const parseJson: typeof toJSON;
|
|
42
42
|
declare function toIntlNumber(value: number): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ declare function toInteger(value: unknown, defaults?: number, maxValue?: number)
|
|
|
36
36
|
declare const parseNumber: typeof toInteger;
|
|
37
37
|
declare const toInt: typeof toInteger;
|
|
38
38
|
declare function toFloat(value: unknown, defaults?: number, maxValue?: number): number | undefined;
|
|
39
|
-
declare function toFixed(value: number, precision?: number): string;
|
|
39
|
+
declare function toFixed(value: number, precision?: number): string | undefined;
|
|
40
40
|
declare function toJSON<T extends object>(str: unknown, defaults?: T): T | undefined;
|
|
41
41
|
declare const parseJson: typeof toJSON;
|
|
42
42
|
declare function toIntlNumber(value: number): string;
|
package/dist/index.js
CHANGED
|
@@ -433,7 +433,9 @@ function toFloat(value, defaults, maxValue) {
|
|
|
433
433
|
return maxValue ? Math.min(maxValue, val) : val;
|
|
434
434
|
}
|
|
435
435
|
function toFixed(value, precision = 2) {
|
|
436
|
-
|
|
436
|
+
if (isNumber(value)) {
|
|
437
|
+
return value.toFixed(precision).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
438
|
+
}
|
|
437
439
|
}
|
|
438
440
|
function toJSON(str, defaults) {
|
|
439
441
|
let value;
|