@etsoo/shared 1.1.76 → 1.1.78
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 +0 -1
- package/lib/cjs/DataTypes.d.ts +4 -4
- package/lib/cjs/NumberUtils.d.ts +16 -2
- package/lib/cjs/NumberUtils.js +0 -4
- package/lib/cjs/types/DelayedExecutorType.d.ts +1 -1
- package/lib/cjs/types/EColor.js +13 -13
- package/lib/cjs/types/EHistory.d.ts +2 -2
- package/lib/cjs/types/EHistory.js +14 -14
- package/lib/cjs/types/EventClass.d.ts +1 -1
- package/lib/cjs/types/EventClass.js +11 -11
- package/lib/cjs/types/FormData.d.ts +1 -1
- package/lib/mjs/DataTypes.d.ts +4 -4
- package/lib/mjs/NumberUtils.d.ts +16 -2
- package/lib/mjs/NumberUtils.js +0 -4
- package/lib/mjs/types/DelayedExecutorType.d.ts +1 -1
- package/lib/mjs/types/EColor.js +13 -13
- package/lib/mjs/types/EHistory.d.ts +2 -2
- package/lib/mjs/types/EHistory.js +14 -14
- package/lib/mjs/types/EventClass.d.ts +1 -1
- package/lib/mjs/types/EventClass.js +11 -11
- package/lib/mjs/types/FormData.d.ts +1 -1
- package/package.json +5 -5
- package/src/NumberUtils.ts +2 -31
package/__tests__/NumberUtils.ts
CHANGED
package/lib/cjs/DataTypes.d.ts
CHANGED
|
@@ -371,20 +371,20 @@ export declare namespace DataTypes {
|
|
|
371
371
|
/**
|
|
372
372
|
* List item with number id type
|
|
373
373
|
*/
|
|
374
|
-
export
|
|
374
|
+
export type ListType = DataTypes.IdLabelItem<number>;
|
|
375
375
|
/**
|
|
376
376
|
* List item with string id type
|
|
377
377
|
*/
|
|
378
|
-
export
|
|
378
|
+
export type ListType1 = DataTypes.IdLabelItem<string>;
|
|
379
379
|
/**
|
|
380
380
|
* Id default type
|
|
381
381
|
*/
|
|
382
|
-
export
|
|
382
|
+
export type IdDefaultType<T extends object> = T extends {
|
|
383
383
|
id: number | string;
|
|
384
384
|
} ? DataTypes.Keys<T> & 'id' : DataTypes.Keys<T>;
|
|
385
385
|
/**
|
|
386
386
|
* Label default type
|
|
387
387
|
*/
|
|
388
|
-
export
|
|
388
|
+
export type LabelDefaultType<T extends object> = T extends {
|
|
389
389
|
label: string;
|
|
390
390
|
} ? DataTypes.Keys<T, string> & 'label' : DataTypes.Keys<T, string>;
|
package/lib/cjs/NumberUtils.d.ts
CHANGED
|
@@ -8,9 +8,23 @@ declare global {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare namespace NumberUtils {
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Format number
|
|
13
|
+
* @param input Input
|
|
14
|
+
* @param locale Locale
|
|
15
|
+
* @param options Options
|
|
16
|
+
* @returns Result
|
|
17
|
+
*/
|
|
12
18
|
function format(input: number | bigint, locale?: string | string[], options?: Intl.NumberFormatOptions): string;
|
|
13
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Format money
|
|
21
|
+
* @param input Input
|
|
22
|
+
* @param currency Currency, like USD for US dollar
|
|
23
|
+
* @param locale Locale
|
|
24
|
+
* @param isInteger Is integer value
|
|
25
|
+
* @param options Options
|
|
26
|
+
* @returns Result
|
|
27
|
+
*/
|
|
14
28
|
function formatMoney(input: number | bigint, currency?: string, locale?: string | string[], isInteger?: boolean, options?: Intl.NumberFormatOptions): string;
|
|
15
29
|
/**
|
|
16
30
|
* Parse float value
|
package/lib/cjs/NumberUtils.js
CHANGED
|
@@ -19,8 +19,6 @@ var NumberUtils;
|
|
|
19
19
|
* @returns Result
|
|
20
20
|
*/
|
|
21
21
|
function format(input, locale, options) {
|
|
22
|
-
if (input == null)
|
|
23
|
-
return undefined;
|
|
24
22
|
// Formatter
|
|
25
23
|
const intl = new Intl.NumberFormat(locale, options);
|
|
26
24
|
return intl.format(input);
|
|
@@ -37,8 +35,6 @@ var NumberUtils;
|
|
|
37
35
|
*/
|
|
38
36
|
function formatMoney(input, currency, locale, isInteger = false, options = {}) {
|
|
39
37
|
var _a, _b, _c, _d;
|
|
40
|
-
if (input == null)
|
|
41
|
-
return format(input, locale, options);
|
|
42
38
|
if (currency) {
|
|
43
39
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
|
|
44
40
|
options.style = 'currency';
|
package/lib/cjs/types/EColor.js
CHANGED
|
@@ -5,19 +5,6 @@ exports.EColor = void 0;
|
|
|
5
5
|
* Etsoo implmented Color
|
|
6
6
|
*/
|
|
7
7
|
class EColor {
|
|
8
|
-
/**
|
|
9
|
-
* Constructor
|
|
10
|
-
* @param r Reg
|
|
11
|
-
* @param g Green
|
|
12
|
-
* @param b Blue
|
|
13
|
-
* @param alpha Alpha
|
|
14
|
-
*/
|
|
15
|
-
constructor(r, g, b, alpha) {
|
|
16
|
-
this.r = r;
|
|
17
|
-
this.g = g;
|
|
18
|
-
this.b = b;
|
|
19
|
-
this.alpha = alpha;
|
|
20
|
-
}
|
|
21
8
|
/**
|
|
22
9
|
* Adjust value
|
|
23
10
|
* @param value Current value
|
|
@@ -100,6 +87,19 @@ class EColor {
|
|
|
100
87
|
}
|
|
101
88
|
return undefined;
|
|
102
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Constructor
|
|
92
|
+
* @param r Reg
|
|
93
|
+
* @param g Green
|
|
94
|
+
* @param b Blue
|
|
95
|
+
* @param alpha Alpha
|
|
96
|
+
*/
|
|
97
|
+
constructor(r, g, b, alpha) {
|
|
98
|
+
this.r = r;
|
|
99
|
+
this.g = g;
|
|
100
|
+
this.b = b;
|
|
101
|
+
this.alpha = alpha;
|
|
102
|
+
}
|
|
103
103
|
/**
|
|
104
104
|
* Clone color with adjustments
|
|
105
105
|
* @param adjustR Adjust R value
|
|
@@ -11,13 +11,13 @@ interface EHistoryNavigateEventData extends EHistoryEventData {
|
|
|
11
11
|
*/
|
|
12
12
|
delta: number;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
type EHistoryEventDef = {
|
|
15
15
|
clear: EHistoryEventData;
|
|
16
16
|
navigate: EHistoryNavigateEventData;
|
|
17
17
|
push: EHistoryEventData;
|
|
18
18
|
replace: EHistoryEventData;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type EHistoryEventType = Exclude<keyof EHistoryEventDef, 'navigate'>;
|
|
21
21
|
/**
|
|
22
22
|
* ETSOO Extended history event
|
|
23
23
|
*/
|
|
@@ -21,20 +21,6 @@ exports.EHistoryNavigateEvent = EHistoryNavigateEvent;
|
|
|
21
21
|
* ETSOO Extended abstract history class
|
|
22
22
|
*/
|
|
23
23
|
class EHistory extends EventClass_1.EventClass {
|
|
24
|
-
/**
|
|
25
|
-
* Constructor
|
|
26
|
-
* @param maxDepth Max depth of the history
|
|
27
|
-
*/
|
|
28
|
-
constructor(maxDepth = 20) {
|
|
29
|
-
super();
|
|
30
|
-
this.maxDepth = maxDepth;
|
|
31
|
-
// Index
|
|
32
|
-
this._index = -1;
|
|
33
|
-
/**
|
|
34
|
-
* States
|
|
35
|
-
*/
|
|
36
|
-
this.states = [];
|
|
37
|
-
}
|
|
38
24
|
/**
|
|
39
25
|
* States length
|
|
40
26
|
*/
|
|
@@ -55,6 +41,20 @@ class EHistory extends EventClass_1.EventClass {
|
|
|
55
41
|
return undefined;
|
|
56
42
|
return this.states[this._index];
|
|
57
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Constructor
|
|
46
|
+
* @param maxDepth Max depth of the history
|
|
47
|
+
*/
|
|
48
|
+
constructor(maxDepth = 20) {
|
|
49
|
+
super();
|
|
50
|
+
this.maxDepth = maxDepth;
|
|
51
|
+
// Index
|
|
52
|
+
this._index = -1;
|
|
53
|
+
/**
|
|
54
|
+
* States
|
|
55
|
+
*/
|
|
56
|
+
this.states = [];
|
|
57
|
+
}
|
|
58
58
|
/**
|
|
59
59
|
* Back to the previous state
|
|
60
60
|
*/
|
|
@@ -7,17 +7,6 @@ exports.EventClass = exports.EventBase = void 0;
|
|
|
7
7
|
* D for data
|
|
8
8
|
*/
|
|
9
9
|
class EventBase {
|
|
10
|
-
/**
|
|
11
|
-
* Constructor
|
|
12
|
-
* @param type Type
|
|
13
|
-
*/
|
|
14
|
-
constructor(target, type, data) {
|
|
15
|
-
this.target = target;
|
|
16
|
-
this.type = type;
|
|
17
|
-
this.data = data;
|
|
18
|
-
this._propagationStopped = false;
|
|
19
|
-
this._timeStamp = Date.now();
|
|
20
|
-
}
|
|
21
10
|
/**
|
|
22
11
|
* stopImmediatePropagation called
|
|
23
12
|
*/
|
|
@@ -30,6 +19,17 @@ class EventBase {
|
|
|
30
19
|
get timeStamp() {
|
|
31
20
|
return this._timeStamp;
|
|
32
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Constructor
|
|
24
|
+
* @param type Type
|
|
25
|
+
*/
|
|
26
|
+
constructor(target, type, data) {
|
|
27
|
+
this.target = target;
|
|
28
|
+
this.type = type;
|
|
29
|
+
this.data = data;
|
|
30
|
+
this._propagationStopped = false;
|
|
31
|
+
this._timeStamp = Date.now();
|
|
32
|
+
}
|
|
33
33
|
/**
|
|
34
34
|
* Prevent all other listeners from being called
|
|
35
35
|
*/
|
|
@@ -22,7 +22,7 @@ export interface IFile {
|
|
|
22
22
|
/**
|
|
23
23
|
* FormDataFieldValue like type
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export type FormDataFieldValue = string | IFile;
|
|
26
26
|
/**
|
|
27
27
|
* FormData like interface
|
|
28
28
|
* https://developer.mozilla.org/en-US/docs/Web/API/FormData
|
package/lib/mjs/DataTypes.d.ts
CHANGED
|
@@ -371,20 +371,20 @@ export declare namespace DataTypes {
|
|
|
371
371
|
/**
|
|
372
372
|
* List item with number id type
|
|
373
373
|
*/
|
|
374
|
-
export
|
|
374
|
+
export type ListType = DataTypes.IdLabelItem<number>;
|
|
375
375
|
/**
|
|
376
376
|
* List item with string id type
|
|
377
377
|
*/
|
|
378
|
-
export
|
|
378
|
+
export type ListType1 = DataTypes.IdLabelItem<string>;
|
|
379
379
|
/**
|
|
380
380
|
* Id default type
|
|
381
381
|
*/
|
|
382
|
-
export
|
|
382
|
+
export type IdDefaultType<T extends object> = T extends {
|
|
383
383
|
id: number | string;
|
|
384
384
|
} ? DataTypes.Keys<T> & 'id' : DataTypes.Keys<T>;
|
|
385
385
|
/**
|
|
386
386
|
* Label default type
|
|
387
387
|
*/
|
|
388
|
-
export
|
|
388
|
+
export type LabelDefaultType<T extends object> = T extends {
|
|
389
389
|
label: string;
|
|
390
390
|
} ? DataTypes.Keys<T, string> & 'label' : DataTypes.Keys<T, string>;
|
package/lib/mjs/NumberUtils.d.ts
CHANGED
|
@@ -8,9 +8,23 @@ declare global {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare namespace NumberUtils {
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Format number
|
|
13
|
+
* @param input Input
|
|
14
|
+
* @param locale Locale
|
|
15
|
+
* @param options Options
|
|
16
|
+
* @returns Result
|
|
17
|
+
*/
|
|
12
18
|
function format(input: number | bigint, locale?: string | string[], options?: Intl.NumberFormatOptions): string;
|
|
13
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Format money
|
|
21
|
+
* @param input Input
|
|
22
|
+
* @param currency Currency, like USD for US dollar
|
|
23
|
+
* @param locale Locale
|
|
24
|
+
* @param isInteger Is integer value
|
|
25
|
+
* @param options Options
|
|
26
|
+
* @returns Result
|
|
27
|
+
*/
|
|
14
28
|
function formatMoney(input: number | bigint, currency?: string, locale?: string | string[], isInteger?: boolean, options?: Intl.NumberFormatOptions): string;
|
|
15
29
|
/**
|
|
16
30
|
* Parse float value
|
package/lib/mjs/NumberUtils.js
CHANGED
|
@@ -16,8 +16,6 @@ export var NumberUtils;
|
|
|
16
16
|
* @returns Result
|
|
17
17
|
*/
|
|
18
18
|
function format(input, locale, options) {
|
|
19
|
-
if (input == null)
|
|
20
|
-
return undefined;
|
|
21
19
|
// Formatter
|
|
22
20
|
const intl = new Intl.NumberFormat(locale, options);
|
|
23
21
|
return intl.format(input);
|
|
@@ -34,8 +32,6 @@ export var NumberUtils;
|
|
|
34
32
|
*/
|
|
35
33
|
function formatMoney(input, currency, locale, isInteger = false, options = {}) {
|
|
36
34
|
var _a, _b, _c, _d;
|
|
37
|
-
if (input == null)
|
|
38
|
-
return format(input, locale, options);
|
|
39
35
|
if (currency) {
|
|
40
36
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
|
|
41
37
|
options.style = 'currency';
|
package/lib/mjs/types/EColor.js
CHANGED
|
@@ -2,19 +2,6 @@
|
|
|
2
2
|
* Etsoo implmented Color
|
|
3
3
|
*/
|
|
4
4
|
export class EColor {
|
|
5
|
-
/**
|
|
6
|
-
* Constructor
|
|
7
|
-
* @param r Reg
|
|
8
|
-
* @param g Green
|
|
9
|
-
* @param b Blue
|
|
10
|
-
* @param alpha Alpha
|
|
11
|
-
*/
|
|
12
|
-
constructor(r, g, b, alpha) {
|
|
13
|
-
this.r = r;
|
|
14
|
-
this.g = g;
|
|
15
|
-
this.b = b;
|
|
16
|
-
this.alpha = alpha;
|
|
17
|
-
}
|
|
18
5
|
/**
|
|
19
6
|
* Adjust value
|
|
20
7
|
* @param value Current value
|
|
@@ -97,6 +84,19 @@ export class EColor {
|
|
|
97
84
|
}
|
|
98
85
|
return undefined;
|
|
99
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Constructor
|
|
89
|
+
* @param r Reg
|
|
90
|
+
* @param g Green
|
|
91
|
+
* @param b Blue
|
|
92
|
+
* @param alpha Alpha
|
|
93
|
+
*/
|
|
94
|
+
constructor(r, g, b, alpha) {
|
|
95
|
+
this.r = r;
|
|
96
|
+
this.g = g;
|
|
97
|
+
this.b = b;
|
|
98
|
+
this.alpha = alpha;
|
|
99
|
+
}
|
|
100
100
|
/**
|
|
101
101
|
* Clone color with adjustments
|
|
102
102
|
* @param adjustR Adjust R value
|
|
@@ -11,13 +11,13 @@ interface EHistoryNavigateEventData extends EHistoryEventData {
|
|
|
11
11
|
*/
|
|
12
12
|
delta: number;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
type EHistoryEventDef = {
|
|
15
15
|
clear: EHistoryEventData;
|
|
16
16
|
navigate: EHistoryNavigateEventData;
|
|
17
17
|
push: EHistoryEventData;
|
|
18
18
|
replace: EHistoryEventData;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type EHistoryEventType = Exclude<keyof EHistoryEventDef, 'navigate'>;
|
|
21
21
|
/**
|
|
22
22
|
* ETSOO Extended history event
|
|
23
23
|
*/
|
|
@@ -16,20 +16,6 @@ export class EHistoryNavigateEvent extends EventBase {
|
|
|
16
16
|
* ETSOO Extended abstract history class
|
|
17
17
|
*/
|
|
18
18
|
export class EHistory extends EventClass {
|
|
19
|
-
/**
|
|
20
|
-
* Constructor
|
|
21
|
-
* @param maxDepth Max depth of the history
|
|
22
|
-
*/
|
|
23
|
-
constructor(maxDepth = 20) {
|
|
24
|
-
super();
|
|
25
|
-
this.maxDepth = maxDepth;
|
|
26
|
-
// Index
|
|
27
|
-
this._index = -1;
|
|
28
|
-
/**
|
|
29
|
-
* States
|
|
30
|
-
*/
|
|
31
|
-
this.states = [];
|
|
32
|
-
}
|
|
33
19
|
/**
|
|
34
20
|
* States length
|
|
35
21
|
*/
|
|
@@ -50,6 +36,20 @@ export class EHistory extends EventClass {
|
|
|
50
36
|
return undefined;
|
|
51
37
|
return this.states[this._index];
|
|
52
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Constructor
|
|
41
|
+
* @param maxDepth Max depth of the history
|
|
42
|
+
*/
|
|
43
|
+
constructor(maxDepth = 20) {
|
|
44
|
+
super();
|
|
45
|
+
this.maxDepth = maxDepth;
|
|
46
|
+
// Index
|
|
47
|
+
this._index = -1;
|
|
48
|
+
/**
|
|
49
|
+
* States
|
|
50
|
+
*/
|
|
51
|
+
this.states = [];
|
|
52
|
+
}
|
|
53
53
|
/**
|
|
54
54
|
* Back to the previous state
|
|
55
55
|
*/
|
|
@@ -4,17 +4,6 @@
|
|
|
4
4
|
* D for data
|
|
5
5
|
*/
|
|
6
6
|
export class EventBase {
|
|
7
|
-
/**
|
|
8
|
-
* Constructor
|
|
9
|
-
* @param type Type
|
|
10
|
-
*/
|
|
11
|
-
constructor(target, type, data) {
|
|
12
|
-
this.target = target;
|
|
13
|
-
this.type = type;
|
|
14
|
-
this.data = data;
|
|
15
|
-
this._propagationStopped = false;
|
|
16
|
-
this._timeStamp = Date.now();
|
|
17
|
-
}
|
|
18
7
|
/**
|
|
19
8
|
* stopImmediatePropagation called
|
|
20
9
|
*/
|
|
@@ -27,6 +16,17 @@ export class EventBase {
|
|
|
27
16
|
get timeStamp() {
|
|
28
17
|
return this._timeStamp;
|
|
29
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Constructor
|
|
21
|
+
* @param type Type
|
|
22
|
+
*/
|
|
23
|
+
constructor(target, type, data) {
|
|
24
|
+
this.target = target;
|
|
25
|
+
this.type = type;
|
|
26
|
+
this.data = data;
|
|
27
|
+
this._propagationStopped = false;
|
|
28
|
+
this._timeStamp = Date.now();
|
|
29
|
+
}
|
|
30
30
|
/**
|
|
31
31
|
* Prevent all other listeners from being called
|
|
32
32
|
*/
|
|
@@ -22,7 +22,7 @@ export interface IFile {
|
|
|
22
22
|
/**
|
|
23
23
|
* FormDataFieldValue like type
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export type FormDataFieldValue = string | IFile;
|
|
26
26
|
/**
|
|
27
27
|
* FormData like interface
|
|
28
28
|
* https://developer.mozilla.org/en-US/docs/Web/API/FormData
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/shared",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.78",
|
|
4
4
|
"description": "TypeScript shared utilities and functions",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://github.com/ETSOO/Shared#readme",
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@types/jest": "^29.2.
|
|
57
|
+
"@types/jest": "^29.2.3",
|
|
58
58
|
"@types/lodash.isequal": "^4.5.6",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
60
|
-
"@typescript-eslint/parser": "^5.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^5.43.0",
|
|
60
|
+
"@typescript-eslint/parser": "^5.43.0",
|
|
61
61
|
"eslint": "^8.27.0",
|
|
62
62
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
63
63
|
"eslint-plugin-import": "^2.26.0",
|
|
64
64
|
"jest": "^29.3.1",
|
|
65
65
|
"jest-environment-jsdom": "^29.3.1",
|
|
66
66
|
"ts-jest": "^29.0.3",
|
|
67
|
-
"typescript": "^4.
|
|
67
|
+
"typescript": "^4.9.3"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"lodash.isequal": "^4.5.0"
|
package/src/NumberUtils.ts
CHANGED
|
@@ -18,16 +18,6 @@ Number.prototype.toExact = function (this: number, precision?: number) {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export namespace NumberUtils {
|
|
21
|
-
export function format(
|
|
22
|
-
input: undefined | null,
|
|
23
|
-
locale?: string | string[],
|
|
24
|
-
options?: Intl.NumberFormatOptions
|
|
25
|
-
): undefined;
|
|
26
|
-
export function format(
|
|
27
|
-
input: number | bigint,
|
|
28
|
-
locale?: string | string[],
|
|
29
|
-
options?: Intl.NumberFormatOptions
|
|
30
|
-
): string;
|
|
31
21
|
/**
|
|
32
22
|
* Format number
|
|
33
23
|
* @param input Input
|
|
@@ -36,32 +26,15 @@ export namespace NumberUtils {
|
|
|
36
26
|
* @returns Result
|
|
37
27
|
*/
|
|
38
28
|
export function format(
|
|
39
|
-
input: number | bigint
|
|
29
|
+
input: number | bigint,
|
|
40
30
|
locale?: string | string[],
|
|
41
31
|
options?: Intl.NumberFormatOptions
|
|
42
32
|
) {
|
|
43
|
-
if (input == null) return undefined;
|
|
44
|
-
|
|
45
33
|
// Formatter
|
|
46
34
|
const intl = new Intl.NumberFormat(locale, options);
|
|
47
|
-
|
|
48
35
|
return intl.format(input);
|
|
49
36
|
}
|
|
50
37
|
|
|
51
|
-
export function formatMoney(
|
|
52
|
-
input: undefined | null,
|
|
53
|
-
currency?: string,
|
|
54
|
-
locale?: string | string[],
|
|
55
|
-
isInteger?: boolean,
|
|
56
|
-
options?: Intl.NumberFormatOptions
|
|
57
|
-
): undefined;
|
|
58
|
-
export function formatMoney(
|
|
59
|
-
input: number | bigint,
|
|
60
|
-
currency?: string,
|
|
61
|
-
locale?: string | string[],
|
|
62
|
-
isInteger?: boolean,
|
|
63
|
-
options?: Intl.NumberFormatOptions
|
|
64
|
-
): string;
|
|
65
38
|
/**
|
|
66
39
|
* Format money
|
|
67
40
|
* @param input Input
|
|
@@ -72,14 +45,12 @@ export namespace NumberUtils {
|
|
|
72
45
|
* @returns Result
|
|
73
46
|
*/
|
|
74
47
|
export function formatMoney(
|
|
75
|
-
input: number | bigint
|
|
48
|
+
input: number | bigint,
|
|
76
49
|
currency?: string,
|
|
77
50
|
locale?: string | string[],
|
|
78
51
|
isInteger: boolean = false,
|
|
79
52
|
options: Intl.NumberFormatOptions = {}
|
|
80
53
|
) {
|
|
81
|
-
if (input == null) return format(input, locale, options);
|
|
82
|
-
|
|
83
54
|
if (currency) {
|
|
84
55
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
|
|
85
56
|
options.style = 'currency';
|