@etsoo/shared 1.1.75 → 1.1.77
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/__tests__/NumberUtils.ts
CHANGED
package/lib/cjs/NumberUtils.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare namespace NumberUtils {
|
|
|
15
15
|
* @param options Options
|
|
16
16
|
* @returns Result
|
|
17
17
|
*/
|
|
18
|
-
function format(input
|
|
18
|
+
function format(input: number | bigint, locale?: string | string[], options?: Intl.NumberFormatOptions): string;
|
|
19
19
|
/**
|
|
20
20
|
* Format money
|
|
21
21
|
* @param input Input
|
|
@@ -25,12 +25,12 @@ export declare namespace NumberUtils {
|
|
|
25
25
|
* @param options Options
|
|
26
26
|
* @returns Result
|
|
27
27
|
*/
|
|
28
|
-
function formatMoney(input
|
|
28
|
+
function formatMoney(input: number | bigint, currency?: string, locale?: string | string[], isInteger?: boolean, options?: Intl.NumberFormatOptions): string;
|
|
29
29
|
/**
|
|
30
30
|
* Parse float value
|
|
31
31
|
* @param rawData Raw data
|
|
32
32
|
*/
|
|
33
|
-
const parse: (rawData:
|
|
33
|
+
const parse: (rawData: unknown) => number;
|
|
34
34
|
/**
|
|
35
35
|
* Parse float value and unit
|
|
36
36
|
* @param input Input string
|
package/lib/cjs/NumberUtils.js
CHANGED
package/lib/mjs/NumberUtils.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare namespace NumberUtils {
|
|
|
15
15
|
* @param options Options
|
|
16
16
|
* @returns Result
|
|
17
17
|
*/
|
|
18
|
-
function format(input
|
|
18
|
+
function format(input: number | bigint, locale?: string | string[], options?: Intl.NumberFormatOptions): string;
|
|
19
19
|
/**
|
|
20
20
|
* Format money
|
|
21
21
|
* @param input Input
|
|
@@ -25,12 +25,12 @@ export declare namespace NumberUtils {
|
|
|
25
25
|
* @param options Options
|
|
26
26
|
* @returns Result
|
|
27
27
|
*/
|
|
28
|
-
function formatMoney(input
|
|
28
|
+
function formatMoney(input: number | bigint, currency?: string, locale?: string | string[], isInteger?: boolean, options?: Intl.NumberFormatOptions): string;
|
|
29
29
|
/**
|
|
30
30
|
* Parse float value
|
|
31
31
|
* @param rawData Raw data
|
|
32
32
|
*/
|
|
33
|
-
const parse: (rawData:
|
|
33
|
+
const parse: (rawData: unknown) => number;
|
|
34
34
|
/**
|
|
35
35
|
* Parse float value and unit
|
|
36
36
|
* @param input Input string
|
package/lib/mjs/NumberUtils.js
CHANGED
package/package.json
CHANGED
package/src/NumberUtils.ts
CHANGED
|
@@ -26,15 +26,12 @@ export namespace NumberUtils {
|
|
|
26
26
|
* @returns Result
|
|
27
27
|
*/
|
|
28
28
|
export function format(
|
|
29
|
-
input
|
|
29
|
+
input: number | bigint,
|
|
30
30
|
locale?: string | string[],
|
|
31
31
|
options?: Intl.NumberFormatOptions
|
|
32
32
|
) {
|
|
33
|
-
if (input == null) return undefined;
|
|
34
|
-
|
|
35
33
|
// Formatter
|
|
36
34
|
const intl = new Intl.NumberFormat(locale, options);
|
|
37
|
-
|
|
38
35
|
return intl.format(input);
|
|
39
36
|
}
|
|
40
37
|
|
|
@@ -48,7 +45,7 @@ export namespace NumberUtils {
|
|
|
48
45
|
* @returns Result
|
|
49
46
|
*/
|
|
50
47
|
export function formatMoney(
|
|
51
|
-
input
|
|
48
|
+
input: number | bigint,
|
|
52
49
|
currency?: string,
|
|
53
50
|
locale?: string | string[],
|
|
54
51
|
isInteger: boolean = false,
|
|
@@ -73,9 +70,7 @@ export namespace NumberUtils {
|
|
|
73
70
|
* Parse float value
|
|
74
71
|
* @param rawData Raw data
|
|
75
72
|
*/
|
|
76
|
-
export const parse = (
|
|
77
|
-
rawData: string | number | undefined | object
|
|
78
|
-
): number => {
|
|
73
|
+
export const parse = (rawData: unknown): number => {
|
|
79
74
|
if (rawData == null) {
|
|
80
75
|
return Number.NaN;
|
|
81
76
|
}
|