@ng-util/util 11.2.0 → 12.1.2
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/bundles/convert.umd.js +7 -53
- package/bundles/convert.umd.js.map +1 -1
- package/bundles/util.umd.js +9 -33
- package/bundles/util.umd.js.map +1 -1
- package/convert/package.json +1 -1
- package/esm2015/convert/convert.js +2 -7
- package/esm2015/convert/prop.js +6 -44
- package/esm2015/convert/public-api.js +2 -7
- package/esm2015/public-api.js +2 -7
- package/esm2015/util.js +2 -7
- package/fesm2015/convert.js +6 -52
- package/fesm2015/convert.js.map +1 -1
- package/fesm2015/util.js +2 -10
- package/fesm2015/util.js.map +1 -1
- package/package.json +3 -3
- package/bundles/convert.umd.min.js +0 -7
- package/bundles/convert.umd.min.js.map +0 -1
- package/bundles/util.umd.min.js +0 -7
- package/bundles/util.umd.min.js.map +0 -1
package/bundles/convert.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license ng-util(cipchk@qq.com)
|
|
2
|
+
* @license ng-util(cipchk@qq.com) v12.1.2
|
|
3
3
|
* (c) 2020 cipchk https://github.com/ng-util
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -9,27 +9,8 @@
|
|
|
9
9
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['ng-util'] = global['ng-util'] || {}, global['ng-util'].util = global['ng-util'].util || {}, global['ng-util'].util.convert = {})));
|
|
10
10
|
}(this, (function (exports) { 'use strict';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* @fileoverview added by tsickle
|
|
14
|
-
* Generated from: prop.ts
|
|
15
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* @template T, D
|
|
19
|
-
* @param {?} name
|
|
20
|
-
* @param {?} fallback
|
|
21
|
-
* @param {?} defaultValue
|
|
22
|
-
* @return {?}
|
|
23
|
-
*/
|
|
24
12
|
function propDecoratorFactory(name, fallback, defaultValue) {
|
|
25
|
-
/**
|
|
26
|
-
* @param {?} target
|
|
27
|
-
* @param {?} propName
|
|
28
|
-
* @param {?=} originalDescriptor
|
|
29
|
-
* @return {?}
|
|
30
|
-
*/
|
|
31
13
|
function propDecorator(target, propName, originalDescriptor) {
|
|
32
|
-
/** @type {?} */
|
|
33
14
|
var privatePropName = "$$__" + propName;
|
|
34
15
|
if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
|
|
35
16
|
console.warn("The prop \"" + privatePropName + "\" is already exist, it will be overrided by " + name + " decorator.");
|
|
@@ -39,16 +20,9 @@
|
|
|
39
20
|
writable: true,
|
|
40
21
|
});
|
|
41
22
|
return {
|
|
42
|
-
/**
|
|
43
|
-
* @return {?}
|
|
44
|
-
*/
|
|
45
23
|
get: function () {
|
|
46
24
|
return originalDescriptor && originalDescriptor.get ? originalDescriptor.get.bind(this)() : this[privatePropName];
|
|
47
25
|
},
|
|
48
|
-
/**
|
|
49
|
-
* @param {?} value
|
|
50
|
-
* @return {?}
|
|
51
|
-
*/
|
|
52
26
|
set: function (value) {
|
|
53
27
|
if (originalDescriptor && originalDescriptor.set) {
|
|
54
28
|
originalDescriptor.set.bind(this)(fallback(value, defaultValue));
|
|
@@ -59,11 +33,6 @@
|
|
|
59
33
|
}
|
|
60
34
|
return propDecorator;
|
|
61
35
|
}
|
|
62
|
-
/**
|
|
63
|
-
* @param {?} value
|
|
64
|
-
* @param {?=} allowUndefined
|
|
65
|
-
* @return {?}
|
|
66
|
-
*/
|
|
67
36
|
function toBoolean(value, allowUndefined) {
|
|
68
37
|
if (allowUndefined === void 0) { allowUndefined = false; }
|
|
69
38
|
return allowUndefined && typeof value === 'undefined' ? undefined : value != null && "" + value !== 'false';
|
|
@@ -72,32 +41,25 @@
|
|
|
72
41
|
* Input decorator that handle a prop to do get/set automatically with toBoolean
|
|
73
42
|
*
|
|
74
43
|
* ```ts
|
|
75
|
-
*
|
|
44
|
+
* @Input() InputBoolean() visible: boolean = false;
|
|
45
|
+
* @Input() @InputBoolean(null) visible: boolean = false;
|
|
76
46
|
* ```
|
|
77
|
-
* @param {?=} defaultValue
|
|
78
|
-
* @return {?}
|
|
79
47
|
*/
|
|
80
48
|
function InputBoolean(defaultValue) {
|
|
81
49
|
if (defaultValue === void 0) { defaultValue = false; }
|
|
82
50
|
return propDecoratorFactory('InputNumber', toBoolean, defaultValue);
|
|
83
51
|
}
|
|
84
|
-
/**
|
|
85
|
-
* @param {?} value
|
|
86
|
-
* @param {?=} fallbackValue
|
|
87
|
-
* @return {?}
|
|
88
|
-
*/
|
|
89
52
|
function toNumber(value, fallbackValue) {
|
|
90
53
|
if (fallbackValue === void 0) { fallbackValue = 0; }
|
|
91
|
-
return !isNaN(parseFloat(
|
|
54
|
+
return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
|
|
92
55
|
}
|
|
93
56
|
/**
|
|
94
57
|
* Input decorator that handle a prop to do get/set automatically with toNumber
|
|
95
58
|
*
|
|
96
59
|
* ```ts
|
|
97
|
-
*
|
|
60
|
+
* @Input() @InputNumber() visible: number = 1;
|
|
61
|
+
* @Input() @InputNumber(null) visible: number = 2;
|
|
98
62
|
* ```
|
|
99
|
-
* @param {?=} defaultValue
|
|
100
|
-
* @return {?}
|
|
101
63
|
*/
|
|
102
64
|
function InputNumber(defaultValue) {
|
|
103
65
|
if (defaultValue === void 0) { defaultValue = 0; }
|
|
@@ -105,15 +67,7 @@
|
|
|
105
67
|
}
|
|
106
68
|
|
|
107
69
|
/**
|
|
108
|
-
*
|
|
109
|
-
* Generated from: public-api.ts
|
|
110
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @fileoverview added by tsickle
|
|
115
|
-
* Generated from: convert.ts
|
|
116
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
70
|
+
* Generated bundle index. Do not edit.
|
|
117
71
|
*/
|
|
118
72
|
|
|
119
73
|
exports.InputBoolean = InputBoolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.umd.js","sources":["
|
|
1
|
+
{"version":3,"file":"convert.umd.js","sources":["../../../../packages/util/convert/prop.ts","../../../../packages/util/convert/convert.ts"],"sourcesContent":["function propDecoratorFactory<T, D>(\n name: string,\n fallback: (v: T, defaultValue: D) => D,\n defaultValue: any,\n): (target: any, propName: string) => void {\n function propDecorator(target: any, propName: string, originalDescriptor?: TypedPropertyDescriptor<any>): any {\n const privatePropName = `$$__${propName}`;\n\n if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {\n console.warn(`The prop \"${privatePropName}\" is already exist, it will be overrided by ${name} decorator.`);\n }\n\n Object.defineProperty(target, privatePropName, {\n configurable: true,\n writable: true,\n });\n\n return {\n get(): string {\n return originalDescriptor && originalDescriptor.get ? originalDescriptor.get.bind(this)() : this[privatePropName];\n },\n set(value: T): void {\n if (originalDescriptor && originalDescriptor.set) {\n originalDescriptor.set.bind(this)(fallback(value, defaultValue));\n }\n this[privatePropName] = fallback(value, defaultValue);\n },\n };\n }\n\n return propDecorator;\n}\n\nexport function toBoolean(value: any, allowUndefined: boolean | null = false): boolean | undefined {\n return allowUndefined && typeof value === 'undefined' ? undefined : value != null && `${value}` !== 'false';\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toBoolean\n *\n * ```ts\n * @Input() InputBoolean() visible: boolean = false;\n * @Input() @InputBoolean(null) visible: boolean = false;\n * ```\n */\nexport function InputBoolean(defaultValue: boolean | null = false): any {\n return propDecoratorFactory('InputNumber', toBoolean, defaultValue);\n}\n\nexport function toNumber(value: any): number;\nexport function toNumber<D>(value: any, fallback: D): number | D;\nexport function toNumber(value: any, fallbackValue: number = 0): number {\n return !isNaN(parseFloat(value as any)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toNumber\n *\n * ```ts\n * @Input() @InputNumber() visible: number = 1;\n * @Input() @InputNumber(null) visible: number = 2;\n * ```\n */\nexport function InputNumber(defaultValue: number | null = 0): any {\n return propDecoratorFactory('InputNumber', toNumber, defaultValue);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;IAAA,SAAS,oBAAoB,CAC3B,IAAY,EACZ,QAAsC,EACtC,YAAiB;QAEjB,SAAS,aAAa,CAAC,MAAW,EAAE,QAAgB,EAAE,kBAAiD;YACrG,IAAM,eAAe,GAAG,SAAO,QAAU,CAAC;YAE1C,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE;gBACjE,OAAO,CAAC,IAAI,CAAC,gBAAa,eAAe,qDAA+C,IAAI,gBAAa,CAAC,CAAC;aAC5G;YAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE;gBAC7C,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;YAEH,OAAO;gBACL,GAAG;oBACD,OAAO,kBAAkB,IAAI,kBAAkB,CAAC,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;iBACnH;gBACD,GAAG,YAAC,KAAQ;oBACV,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,GAAG,EAAE;wBAChD,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;qBAClE;oBACD,IAAI,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;iBACvD;aACF,CAAC;SACH;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;aAEe,SAAS,CAAC,KAAU,EAAE,cAAsC;QAAtC,+BAAA,EAAA,sBAAsC;QAC1E,OAAO,cAAc,IAAI,OAAO,KAAK,KAAK,WAAW,GAAG,SAAS,GAAG,KAAK,IAAI,IAAI,IAAI,KAAG,KAAO,KAAK,OAAO,CAAC;IAC9G,CAAC;IAED;;;;;;;;aAQgB,YAAY,CAAC,YAAoC;QAApC,6BAAA,EAAA,oBAAoC;QAC/D,OAAO,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IACtE,CAAC;aAIe,QAAQ,CAAC,KAAU,EAAE,aAAyB;QAAzB,8BAAA,EAAA,iBAAyB;QAC5D,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAY,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC;IACnG,CAAC;IAED;;;;;;;;aAQgB,WAAW,CAAC,YAA+B;QAA/B,6BAAA,EAAA,gBAA+B;QACzD,OAAO,oBAAoB,CAAC,aAAa,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACrE;;ICjEA;;;;;;;;;;;;;;;"}
|
package/bundles/util.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license ng-util(cipchk@qq.com)
|
|
2
|
+
* @license ng-util(cipchk@qq.com) v12.1.2
|
|
3
3
|
* (c) 2020 cipchk https://github.com/ng-util
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -10,40 +10,16 @@
|
|
|
10
10
|
}(this, (function (exports, convert) { 'use strict';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* Generated from: public-api.ts
|
|
15
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
13
|
+
* Generated bundle index. Do not edit.
|
|
16
14
|
*/
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return convert.InputBoolean;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, 'InputNumber', {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return convert.InputNumber;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, 'toBoolean', {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return convert.toBoolean;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, 'toNumber', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return convert.toNumber;
|
|
46
|
-
}
|
|
16
|
+
Object.keys(convert).forEach(function (k) {
|
|
17
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return convert[k];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
47
23
|
});
|
|
48
24
|
|
|
49
25
|
Object.defineProperty(exports, '__esModule', { value: true });
|
package/bundles/util.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.umd.js","sources":["../../../../packages/util/util.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;CAAA;;;;;;;;;;;;;;;;;;;"}
|
package/convert/package.json
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview added by tsickle
|
|
3
|
-
* Generated from: convert.ts
|
|
4
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Generated bundle index. Do not edit.
|
|
8
3
|
*/
|
|
9
|
-
export
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
export * from './public-api';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udmVydC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvY29udmVydC9jb252ZXJ0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljLWFwaSc7XG4iXX0=
|
package/esm2015/convert/prop.js
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview added by tsickle
|
|
3
|
-
* Generated from: prop.ts
|
|
4
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @template T, D
|
|
8
|
-
* @param {?} name
|
|
9
|
-
* @param {?} fallback
|
|
10
|
-
* @param {?} defaultValue
|
|
11
|
-
* @return {?}
|
|
12
|
-
*/
|
|
13
1
|
function propDecoratorFactory(name, fallback, defaultValue) {
|
|
14
|
-
/**
|
|
15
|
-
* @param {?} target
|
|
16
|
-
* @param {?} propName
|
|
17
|
-
* @param {?=} originalDescriptor
|
|
18
|
-
* @return {?}
|
|
19
|
-
*/
|
|
20
2
|
function propDecorator(target, propName, originalDescriptor) {
|
|
21
|
-
/** @type {?} */
|
|
22
3
|
const privatePropName = `$$__${propName}`;
|
|
23
4
|
if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
|
|
24
5
|
console.warn(`The prop "${privatePropName}" is already exist, it will be overrided by ${name} decorator.`);
|
|
@@ -28,16 +9,9 @@ function propDecoratorFactory(name, fallback, defaultValue) {
|
|
|
28
9
|
writable: true,
|
|
29
10
|
});
|
|
30
11
|
return {
|
|
31
|
-
/**
|
|
32
|
-
* @return {?}
|
|
33
|
-
*/
|
|
34
12
|
get() {
|
|
35
13
|
return originalDescriptor && originalDescriptor.get ? originalDescriptor.get.bind(this)() : this[privatePropName];
|
|
36
14
|
},
|
|
37
|
-
/**
|
|
38
|
-
* @param {?} value
|
|
39
|
-
* @return {?}
|
|
40
|
-
*/
|
|
41
15
|
set(value) {
|
|
42
16
|
if (originalDescriptor && originalDescriptor.set) {
|
|
43
17
|
originalDescriptor.set.bind(this)(fallback(value, defaultValue));
|
|
@@ -48,11 +22,6 @@ function propDecoratorFactory(name, fallback, defaultValue) {
|
|
|
48
22
|
}
|
|
49
23
|
return propDecorator;
|
|
50
24
|
}
|
|
51
|
-
/**
|
|
52
|
-
* @param {?} value
|
|
53
|
-
* @param {?=} allowUndefined
|
|
54
|
-
* @return {?}
|
|
55
|
-
*/
|
|
56
25
|
export function toBoolean(value, allowUndefined = false) {
|
|
57
26
|
return allowUndefined && typeof value === 'undefined' ? undefined : value != null && `${value}` !== 'false';
|
|
58
27
|
}
|
|
@@ -60,32 +29,25 @@ export function toBoolean(value, allowUndefined = false) {
|
|
|
60
29
|
* Input decorator that handle a prop to do get/set automatically with toBoolean
|
|
61
30
|
*
|
|
62
31
|
* ```ts
|
|
63
|
-
*
|
|
32
|
+
* @Input() InputBoolean() visible: boolean = false;
|
|
33
|
+
* @Input() @InputBoolean(null) visible: boolean = false;
|
|
64
34
|
* ```
|
|
65
|
-
* @param {?=} defaultValue
|
|
66
|
-
* @return {?}
|
|
67
35
|
*/
|
|
68
36
|
export function InputBoolean(defaultValue = false) {
|
|
69
37
|
return propDecoratorFactory('InputNumber', toBoolean, defaultValue);
|
|
70
38
|
}
|
|
71
|
-
/**
|
|
72
|
-
* @param {?} value
|
|
73
|
-
* @param {?=} fallbackValue
|
|
74
|
-
* @return {?}
|
|
75
|
-
*/
|
|
76
39
|
export function toNumber(value, fallbackValue = 0) {
|
|
77
|
-
return !isNaN(parseFloat(
|
|
40
|
+
return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
|
|
78
41
|
}
|
|
79
42
|
/**
|
|
80
43
|
* Input decorator that handle a prop to do get/set automatically with toNumber
|
|
81
44
|
*
|
|
82
45
|
* ```ts
|
|
83
|
-
*
|
|
46
|
+
* @Input() @InputNumber() visible: number = 1;
|
|
47
|
+
* @Input() @InputNumber(null) visible: number = 2;
|
|
84
48
|
* ```
|
|
85
|
-
* @param {?=} defaultValue
|
|
86
|
-
* @return {?}
|
|
87
49
|
*/
|
|
88
50
|
export function InputNumber(defaultValue = 0) {
|
|
89
51
|
return propDecoratorFactory('InputNumber', toNumber, defaultValue);
|
|
90
52
|
}
|
|
91
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvY29udmVydC9wcm9wLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLFNBQVMsb0JBQW9CLENBQzNCLElBQVksRUFDWixRQUFzQyxFQUN0QyxZQUFpQjtJQUVq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nVtYmVyO1xuZXhwb3J0IGZ1bmN0aW9uIHRvTnVtYmVyPEQ+KHZhbHVlOiBhbnksIGZhbGxiYWNrOiBEKTogbnVtYmVyIHwgRDtcbmV4cG9ydCBmdW5jdGlvbiB0b051bWJlcih2YWx1ZTogYW55LCBmYWxsYmFja1ZhbHVlOiBudW1iZXIgPSAwKTogbnVtYmVyIHtcbiAgcmV0dXJuICFpc05hTihwYXJzZUZsb2F0KHZhbHVlIGFzIGFueSkpICYmICFpc05hTihOdW1iZXIodmFsdWUpKSA/IE51bWJlcih2YWx1ZSkgOiBmYWxsYmFja1ZhbHVlO1xufVxuXG4vKipcbiAqIElucHV0IGRlY29yYXRvciB0aGF0IGhhbmRsZSBhIHByb3AgdG8gZG8gZ2V0L3NldCBhdXRvbWF0aWNhbGx5IHdpdGggdG9OdW1iZXJcbiAqXG4gKiBgYGB0c1xuICogQElucHV0KCkgQElucHV0TnVtYmVyKCkgdmlzaWJsZTogbnVtYmVyID0gMTtcbiAqIEBJbnB1dCgpIEBJbnB1dE51bWJlcihudWxsKSB2aXNpYmxlOiBudW1iZXIgPSAyO1xuICogYGBgXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBJbnB1dE51bWJlcihkZWZhdWx0VmFsdWU6IG51bWJlciB8IG51bGwgPSAwKTogYW55IHtcbiAgcmV0dXJuIHByb3BEZWNvcmF0b3JGYWN0b3J5KCdJbnB1dE51bWJlcicsIHRvTnVtYmVyLCBkZWZhdWx0VmFsdWUpO1xufVxuIl19
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Generated from: public-api.ts
|
|
4
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5
|
-
*/
|
|
6
|
-
export { toBoolean, InputBoolean, toNumber, InputNumber } from './prop';
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL2NvbnZlcnQvIiwic291cmNlcyI6WyJwdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsK0RBQWMsUUFBUSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9wcm9wJztcbiJdfQ==
|
|
1
|
+
export * from './prop';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvY29udmVydC9wdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsUUFBUSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9wcm9wJztcbiJdfQ==
|
package/esm2015/public-api.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Generated from: public-api.ts
|
|
4
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5
|
-
*/
|
|
6
|
-
export { toBoolean, InputBoolean, toNumber, InputNumber } from '@ng-util/util/convert';
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsLyIsInNvdXJjZXMiOlsicHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLCtEQUFjLHVCQUF1QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnQG5nLXV0aWwvdXRpbC9jb252ZXJ0JztcbiJdfQ==
|
|
1
|
+
export * from '@ng-util/util/convert';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHVCQUF1QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnQG5nLXV0aWwvdXRpbC9jb252ZXJ0JztcbiJdfQ==
|
package/esm2015/util.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview added by tsickle
|
|
3
|
-
* Generated from: util.ts
|
|
4
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Generated bundle index. Do not edit.
|
|
8
3
|
*/
|
|
9
|
-
export
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
export * from './public-api';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvdXRpbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpYy1hcGknO1xuIl19
|
package/fesm2015/convert.js
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview added by tsickle
|
|
3
|
-
* Generated from: prop.ts
|
|
4
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @template T, D
|
|
8
|
-
* @param {?} name
|
|
9
|
-
* @param {?} fallback
|
|
10
|
-
* @param {?} defaultValue
|
|
11
|
-
* @return {?}
|
|
12
|
-
*/
|
|
13
1
|
function propDecoratorFactory(name, fallback, defaultValue) {
|
|
14
|
-
/**
|
|
15
|
-
* @param {?} target
|
|
16
|
-
* @param {?} propName
|
|
17
|
-
* @param {?=} originalDescriptor
|
|
18
|
-
* @return {?}
|
|
19
|
-
*/
|
|
20
2
|
function propDecorator(target, propName, originalDescriptor) {
|
|
21
|
-
/** @type {?} */
|
|
22
3
|
const privatePropName = `$$__${propName}`;
|
|
23
4
|
if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
|
|
24
5
|
console.warn(`The prop "${privatePropName}" is already exist, it will be overrided by ${name} decorator.`);
|
|
@@ -28,16 +9,9 @@ function propDecoratorFactory(name, fallback, defaultValue) {
|
|
|
28
9
|
writable: true,
|
|
29
10
|
});
|
|
30
11
|
return {
|
|
31
|
-
/**
|
|
32
|
-
* @return {?}
|
|
33
|
-
*/
|
|
34
12
|
get() {
|
|
35
13
|
return originalDescriptor && originalDescriptor.get ? originalDescriptor.get.bind(this)() : this[privatePropName];
|
|
36
14
|
},
|
|
37
|
-
/**
|
|
38
|
-
* @param {?} value
|
|
39
|
-
* @return {?}
|
|
40
|
-
*/
|
|
41
15
|
set(value) {
|
|
42
16
|
if (originalDescriptor && originalDescriptor.set) {
|
|
43
17
|
originalDescriptor.set.bind(this)(fallback(value, defaultValue));
|
|
@@ -48,11 +22,6 @@ function propDecoratorFactory(name, fallback, defaultValue) {
|
|
|
48
22
|
}
|
|
49
23
|
return propDecorator;
|
|
50
24
|
}
|
|
51
|
-
/**
|
|
52
|
-
* @param {?} value
|
|
53
|
-
* @param {?=} allowUndefined
|
|
54
|
-
* @return {?}
|
|
55
|
-
*/
|
|
56
25
|
function toBoolean(value, allowUndefined = false) {
|
|
57
26
|
return allowUndefined && typeof value === 'undefined' ? undefined : value != null && `${value}` !== 'false';
|
|
58
27
|
}
|
|
@@ -60,45 +29,30 @@ function toBoolean(value, allowUndefined = false) {
|
|
|
60
29
|
* Input decorator that handle a prop to do get/set automatically with toBoolean
|
|
61
30
|
*
|
|
62
31
|
* ```ts
|
|
63
|
-
*
|
|
32
|
+
* @Input() InputBoolean() visible: boolean = false;
|
|
33
|
+
* @Input() @InputBoolean(null) visible: boolean = false;
|
|
64
34
|
* ```
|
|
65
|
-
* @param {?=} defaultValue
|
|
66
|
-
* @return {?}
|
|
67
35
|
*/
|
|
68
36
|
function InputBoolean(defaultValue = false) {
|
|
69
37
|
return propDecoratorFactory('InputNumber', toBoolean, defaultValue);
|
|
70
38
|
}
|
|
71
|
-
/**
|
|
72
|
-
* @param {?} value
|
|
73
|
-
* @param {?=} fallbackValue
|
|
74
|
-
* @return {?}
|
|
75
|
-
*/
|
|
76
39
|
function toNumber(value, fallbackValue = 0) {
|
|
77
|
-
return !isNaN(parseFloat(
|
|
40
|
+
return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
|
|
78
41
|
}
|
|
79
42
|
/**
|
|
80
43
|
* Input decorator that handle a prop to do get/set automatically with toNumber
|
|
81
44
|
*
|
|
82
45
|
* ```ts
|
|
83
|
-
*
|
|
46
|
+
* @Input() @InputNumber() visible: number = 1;
|
|
47
|
+
* @Input() @InputNumber(null) visible: number = 2;
|
|
84
48
|
* ```
|
|
85
|
-
* @param {?=} defaultValue
|
|
86
|
-
* @return {?}
|
|
87
49
|
*/
|
|
88
50
|
function InputNumber(defaultValue = 0) {
|
|
89
51
|
return propDecoratorFactory('InputNumber', toNumber, defaultValue);
|
|
90
52
|
}
|
|
91
53
|
|
|
92
54
|
/**
|
|
93
|
-
*
|
|
94
|
-
* Generated from: public-api.ts
|
|
95
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @fileoverview added by tsickle
|
|
100
|
-
* Generated from: convert.ts
|
|
101
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
55
|
+
* Generated bundle index. Do not edit.
|
|
102
56
|
*/
|
|
103
57
|
|
|
104
58
|
export { InputBoolean, InputNumber, toBoolean, toNumber };
|
package/fesm2015/convert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sources":["
|
|
1
|
+
{"version":3,"file":"convert.js","sources":["../../../../packages/util/convert/prop.ts","../../../../packages/util/convert/convert.ts"],"sourcesContent":["function propDecoratorFactory<T, D>(\n name: string,\n fallback: (v: T, defaultValue: D) => D,\n defaultValue: any,\n): (target: any, propName: string) => void {\n function propDecorator(target: any, propName: string, originalDescriptor?: TypedPropertyDescriptor<any>): any {\n const privatePropName = `$$__${propName}`;\n\n if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {\n console.warn(`The prop \"${privatePropName}\" is already exist, it will be overrided by ${name} decorator.`);\n }\n\n Object.defineProperty(target, privatePropName, {\n configurable: true,\n writable: true,\n });\n\n return {\n get(): string {\n return originalDescriptor && originalDescriptor.get ? originalDescriptor.get.bind(this)() : this[privatePropName];\n },\n set(value: T): void {\n if (originalDescriptor && originalDescriptor.set) {\n originalDescriptor.set.bind(this)(fallback(value, defaultValue));\n }\n this[privatePropName] = fallback(value, defaultValue);\n },\n };\n }\n\n return propDecorator;\n}\n\nexport function toBoolean(value: any, allowUndefined: boolean | null = false): boolean | undefined {\n return allowUndefined && typeof value === 'undefined' ? undefined : value != null && `${value}` !== 'false';\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toBoolean\n *\n * ```ts\n * @Input() InputBoolean() visible: boolean = false;\n * @Input() @InputBoolean(null) visible: boolean = false;\n * ```\n */\nexport function InputBoolean(defaultValue: boolean | null = false): any {\n return propDecoratorFactory('InputNumber', toBoolean, defaultValue);\n}\n\nexport function toNumber(value: any): number;\nexport function toNumber<D>(value: any, fallback: D): number | D;\nexport function toNumber(value: any, fallbackValue: number = 0): number {\n return !isNaN(parseFloat(value as any)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toNumber\n *\n * ```ts\n * @Input() @InputNumber() visible: number = 1;\n * @Input() @InputNumber(null) visible: number = 2;\n * ```\n */\nexport function InputNumber(defaultValue: number | null = 0): any {\n return propDecoratorFactory('InputNumber', toNumber, defaultValue);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA,SAAS,oBAAoB,CAC3B,IAAY,EACZ,QAAsC,EACtC,YAAiB;IAEjB,SAAS,aAAa,CAAC,MAAW,EAAE,QAAgB,EAAE,kBAAiD;QACrG,MAAM,eAAe,GAAG,OAAO,QAAQ,EAAE,CAAC;QAE1C,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE;YACjE,OAAO,CAAC,IAAI,CAAC,aAAa,eAAe,+CAA+C,IAAI,aAAa,CAAC,CAAC;SAC5G;QAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE;YAC7C,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QAEH,OAAO;YACL,GAAG;gBACD,OAAO,kBAAkB,IAAI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2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* Generated from: public-api.ts
|
|
6
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @fileoverview added by tsickle
|
|
11
|
-
* Generated from: util.ts
|
|
12
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4
|
+
* Generated bundle index. Do not edit.
|
|
13
5
|
*/
|
|
14
6
|
//# sourceMappingURL=util.js.map
|
package/fesm2015/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../packages/util/util.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-util/util",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.1.2",
|
|
4
4
|
"author": "cipchk<cipchk@qq.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"typings": "util.d.ts",
|
|
26
26
|
"metadata": "util.metadata.json",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"tslib": "^2.
|
|
28
|
+
"tslib": "^2.2.0"
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license ng-util(cipchk@qq.com) v11.2.0
|
|
3
|
-
* (c) 2020 cipchk https://github.com/ng-util
|
|
4
|
-
* License: MIT
|
|
5
|
-
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("@ng-util/util/convert",["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self)["ng-util"]=e["ng-util"]||{},e["ng-util"].util=e["ng-util"].util||{},e["ng-util"].util.convert={}))}(this,(function(e){"use strict";function t(e,t,n){return function(i,o,u){var r="$$__"+o;return Object.prototype.hasOwnProperty.call(i,r)&&console.warn('The prop "'+r+'" is already exist, it will be overrided by '+e+" decorator."),Object.defineProperty(i,r,{configurable:!0,writable:!0}),{get:function(){return u&&u.get?u.get.bind(this)():this[r]},set:function(e){u&&u.set&&u.set.bind(this)(t(e,n)),this[r]=t(e,n)}}}}function n(e,t){return void 0===t&&(t=!1),t&&void 0===e?void 0:null!=e&&""+e!="false"}function i(e,t){return void 0===t&&(t=0),isNaN(parseFloat(e))||isNaN(Number(e))?t:Number(e)}e.InputBoolean=function(e){return void 0===e&&(e=!1),t("InputNumber",n,e)},e.InputNumber=function(e){return void 0===e&&(e=0),t("InputNumber",i,e)},e.toBoolean=n,e.toNumber=i,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
7
|
-
//# sourceMappingURL=convert.umd.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/util/convert/prop.ts"],"names":["propDecoratorFactory","name","fallback","defaultValue","target","propName","originalDescriptor","privatePropName","Object","prototype","hasOwnProperty","call","console","warn","defineProperty","configurable","writable","get","bind","this","set","value","toBoolean","allowUndefined","undefined","toNumber","fallbackValue","isNaN","parseFloat","Number"],"mappings":"+VAAA,SAASA,EACPC,EACAC,EACAC,GA2BA,OAzBA,SAAuBC,EAAaC,EAAkBC,OAC9CC,EAAkB,OAAOF,EAW/B,OATIG,OAAOC,UAAUC,eAAeC,KAAKP,EAAQG,IAC/CK,QAAQC,KAAK,aAAaN,EAAe,+CAA+CN,EAAI,eAG9FO,OAAOM,eAAeV,EAAQG,EAAiB,CAC7CQ,cAAc,EACdC,UAAU,IAGL,CACLC,IAAG,WACD,OAAOX,GAAsBA,EAAmBW,IAAMX,EAAmBW,IAAIC,KAAKC,KAA5Bb,GAAsCa,KAAKZ,IAEnGa,IAAG,SAACC,GACEf,GAAsBA,EAAmBc,KAC3Cd,EAAmBc,IAAIF,KAAKC,KAA5Bb,CAAkCJ,EAASmB,EAAOlB,IAEpDgB,KAAKZ,GAAmBL,EAASmB,EAAOlB,eAQhCmB,EAAUD,EAAYE,GACpC,YADoC,IAAAA,IAAAA,GAAA,GAC7BA,QAAmC,IAAVF,OAAwBG,EAAqB,MAATH,GAAiB,GAAGA,GAAY,iBAiBtFI,EAASJ,EAAYK,GACnC,YADmC,IAAAA,IAAAA,EAAA,GAC3BC,MAAMC,WAAU,KAAoBD,MAAME,OAAOR,IAA0BK,EAAhBG,OAAOR,2BAP/ClB,GAC3B,YAD2B,IAAAA,IAAAA,GAAA,GACpBH,EAAqB,cAAesB,EAAWnB,2BAiB5BA,GAC1B,YAD0B,IAAAA,IAAAA,EAAA,GACnBH,EAAqB,cAAeyB,EAAUtB","sourcesContent":["function propDecoratorFactory<T, D>(\n name: string,\n fallback: (v: T, defaultValue: D) => D,\n defaultValue: any,\n): (target: any, propName: string) => void {\n function propDecorator(target: any, propName: string, originalDescriptor?: TypedPropertyDescriptor<any>): any {\n const privatePropName = `$$__${propName}`;\n\n if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {\n console.warn(`The prop \"${privatePropName}\" is already exist, it will be overrided by ${name} decorator.`);\n }\n\n Object.defineProperty(target, privatePropName, {\n configurable: true,\n writable: true,\n });\n\n return {\n get(): string {\n return originalDescriptor && originalDescriptor.get ? originalDescriptor.get.bind(this)() : this[privatePropName];\n },\n set(value: T): void {\n if (originalDescriptor && originalDescriptor.set) {\n originalDescriptor.set.bind(this)(fallback(value, defaultValue));\n }\n this[privatePropName] = fallback(value, defaultValue);\n },\n };\n }\n\n return propDecorator;\n}\n\nexport function toBoolean(value: any, allowUndefined: boolean | null = false): boolean | undefined {\n return allowUndefined && typeof value === 'undefined' ? undefined : value != null && `${value}` !== 'false';\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toBoolean\n *\n * ```ts\n * @Input() InputBoolean() visible: boolean = false;\n * @Input() @InputBoolean(null) visible: boolean = false;\n * ```\n */\nexport function InputBoolean(defaultValue: boolean | null = false): any {\n return propDecoratorFactory('InputNumber', toBoolean, defaultValue);\n}\n\nexport function toNumber(value: any): number;\nexport function toNumber<D>(value: any, fallback: D): number | D;\nexport function toNumber(value: any, fallbackValue: number = 0): number {\n return !isNaN(parseFloat(value as any)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toNumber\n *\n * ```ts\n * @Input() @InputNumber() visible: number = 1;\n * @Input() @InputNumber(null) visible: number = 2;\n * ```\n */\nexport function InputNumber(defaultValue: number | null = 0): any {\n return propDecoratorFactory('InputNumber', toNumber, defaultValue);\n}\n"]}
|
package/bundles/util.umd.min.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license ng-util(cipchk@qq.com) v11.2.0
|
|
3
|
-
* (c) 2020 cipchk https://github.com/ng-util
|
|
4
|
-
* License: MIT
|
|
5
|
-
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@ng-util/util/convert")):"function"==typeof define&&define.amd?define("@ng-util/util",["exports","@ng-util/util/convert"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self)["ng-util"]=e["ng-util"]||{},e["ng-util"].util={}),e["ng-util"].util.convert)}(this,(function(e,t){"use strict";Object.defineProperty(e,"InputBoolean",{enumerable:!0,get:function(){return t.InputBoolean}}),Object.defineProperty(e,"InputNumber",{enumerable:!0,get:function(){return t.InputNumber}}),Object.defineProperty(e,"toBoolean",{enumerable:!0,get:function(){return t.toBoolean}}),Object.defineProperty(e,"toNumber",{enumerable:!0,get:function(){return t.toNumber}}),Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
7
|
-
//# sourceMappingURL=util.umd.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|