@ng-util/util 15.0.0 → 16.0.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/{fesm2015 → fesm2022}/util.mjs +0 -1
- package/{fesm2015 → fesm2022}/utilConvert.mjs +0 -1
- package/package.json +8 -16
- package/fesm2020/util.mjs +0 -7
- package/fesm2020/util.mjs.map +0 -1
- package/fesm2020/utilConvert.mjs +0 -60
- package/fesm2020/utilConvert.mjs.map +0 -1
- /package/{esm2020 → esm2022}/convert/prop.mjs +0 -0
- /package/{esm2020 → esm2022}/convert/public-api.mjs +0 -0
- /package/{esm2020 → esm2022}/convert/utilConvert.mjs +0 -0
- /package/{esm2020 → esm2022}/public-api.mjs +0 -0
- /package/{esm2020 → esm2022}/util.mjs +0 -0
- /package/{fesm2015 → fesm2022}/util.mjs.map +0 -0
- /package/{fesm2015 → fesm2022}/utilConvert.mjs.map +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-util/util",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.1",
|
|
4
4
|
"author": "cipchk<cipchk@qq.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,11 +18,7 @@
|
|
|
18
18
|
"angular standalone library"
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
|
-
"module": "
|
|
22
|
-
"es2020": "fesm2020/util.mjs",
|
|
23
|
-
"esm2020": "esm2020/util.mjs",
|
|
24
|
-
"fesm2020": "fesm2020/util.mjs",
|
|
25
|
-
"fesm2015": "fesm2015/util.mjs",
|
|
21
|
+
"module": "fesm2022/util.mjs",
|
|
26
22
|
"typings": "index.d.ts",
|
|
27
23
|
"exports": {
|
|
28
24
|
"./package.json": {
|
|
@@ -30,19 +26,15 @@
|
|
|
30
26
|
},
|
|
31
27
|
".": {
|
|
32
28
|
"types": "./index.d.ts",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"node": "./fesm2015/util.mjs",
|
|
37
|
-
"default": "./fesm2020/util.mjs"
|
|
29
|
+
"esm2022": "./esm2022/util.mjs",
|
|
30
|
+
"esm": "./esm2022/util.mjs",
|
|
31
|
+
"default": "./fesm2022/util.mjs"
|
|
38
32
|
},
|
|
39
33
|
"./convert": {
|
|
40
34
|
"types": "./convert/index.d.ts",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"node": "./fesm2015/utilConvert.mjs",
|
|
45
|
-
"default": "./fesm2020/utilConvert.mjs"
|
|
35
|
+
"esm2022": "./esm2022/convert/utilConvert.mjs",
|
|
36
|
+
"esm": "./esm2022/convert/utilConvert.mjs",
|
|
37
|
+
"default": "./fesm2022/utilConvert.mjs"
|
|
46
38
|
}
|
|
47
39
|
},
|
|
48
40
|
"dependencies": {
|
package/fesm2020/util.mjs
DELETED
package/fesm2020/util.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.mjs","sources":["../../../../packages/util/util.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;AAEG"}
|
package/fesm2020/utilConvert.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
function propDecoratorFactory(name, fallback, defaultValue) {
|
|
2
|
-
function propDecorator(target, propName, originalDescriptor) {
|
|
3
|
-
const privatePropName = `$$__${propName}`;
|
|
4
|
-
if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
|
|
5
|
-
console.warn(`The prop "${privatePropName}" is already exist, it will be overrided by ${name} decorator.`);
|
|
6
|
-
}
|
|
7
|
-
Object.defineProperty(target, privatePropName, {
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true,
|
|
10
|
-
});
|
|
11
|
-
return {
|
|
12
|
-
get() {
|
|
13
|
-
return originalDescriptor && originalDescriptor.get ? originalDescriptor.get.bind(this)() : this[privatePropName];
|
|
14
|
-
},
|
|
15
|
-
set(value) {
|
|
16
|
-
if (originalDescriptor && originalDescriptor.set) {
|
|
17
|
-
originalDescriptor.set.bind(this)(fallback(value, defaultValue));
|
|
18
|
-
}
|
|
19
|
-
this[privatePropName] = fallback(value, defaultValue);
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return propDecorator;
|
|
24
|
-
}
|
|
25
|
-
function toBoolean(value, allowUndefined = false) {
|
|
26
|
-
return allowUndefined && typeof value === 'undefined' ? undefined : value != null && `${value}` !== 'false';
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Input decorator that handle a prop to do get/set automatically with toBoolean
|
|
30
|
-
*
|
|
31
|
-
* ```ts
|
|
32
|
-
* @Input() InputBoolean() visible: boolean = false;
|
|
33
|
-
* @Input() @InputBoolean(null) visible: boolean = false;
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
function InputBoolean(defaultValue = false) {
|
|
37
|
-
return propDecoratorFactory('InputNumber', toBoolean, defaultValue);
|
|
38
|
-
}
|
|
39
|
-
function toNumber(value, fallbackValue = 0) {
|
|
40
|
-
return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Input decorator that handle a prop to do get/set automatically with toNumber
|
|
44
|
-
*
|
|
45
|
-
* ```ts
|
|
46
|
-
* @Input() @InputNumber() visible: number = 1;
|
|
47
|
-
* @Input() @InputNumber(null) visible: number = 2;
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
function InputNumber(defaultValue = 0) {
|
|
51
|
-
return propDecoratorFactory('InputNumber', toNumber, defaultValue);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Generated bundle index. Do not edit.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export { InputBoolean, InputNumber, toBoolean, toNumber };
|
|
59
|
-
//# sourceMappingURL=utilConvert.mjs.map
|
|
60
|
-
//# sourceMappingURL=utilConvert.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utilConvert.mjs","sources":["../../../../packages/util/convert/prop.ts","../../../../packages/util/convert/utilConvert.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,EAAA;AAEjB,IAAA,SAAS,aAAa,CAAC,MAAW,EAAE,QAAgB,EAAE,kBAAiD,EAAA;AACrG,QAAA,MAAM,eAAe,GAAG,CAAO,IAAA,EAAA,QAAQ,EAAE,CAAC;AAE1C,QAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE;YACjE,OAAO,CAAC,IAAI,CAAC,CAAA,UAAA,EAAa,eAAe,CAA+C,4CAAA,EAAA,IAAI,CAAa,WAAA,CAAA,CAAC,CAAC;AAC5G,SAAA;AAED,QAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE;AAC7C,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,GAAA;gBACD,OAAO,kBAAkB,IAAI,kBAAkB,CAAC,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;aACnH;AACD,YAAA,GAAG,CAAC,KAAQ,EAAA;AACV,gBAAA,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,GAAG,EAAE;AAChD,oBAAA,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;AAClE,iBAAA;gBACD,IAAI,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;aACvD;SACF,CAAC;KACH;AAED,IAAA,OAAO,aAAa,CAAC;AACvB,CAAC;SAEe,SAAS,CAAC,KAAU,EAAE,iBAAiC,KAAK,EAAA;IAC1E,OAAO,cAAc,IAAI,OAAO,KAAK,KAAK,WAAW,GAAG,SAAS,GAAG,KAAK,IAAI,IAAI,IAAI,GAAG,KAAK,CAAA,CAAE,KAAK,OAAO,CAAC;AAC9G,CAAC;AAED;;;;;;;AAOG;AACa,SAAA,YAAY,CAAC,YAAA,GAA+B,KAAK,EAAA;IAC/D,OAAO,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AACtE,CAAC;SAIe,QAAQ,CAAC,KAAU,EAAE,gBAAwB,CAAC,EAAA;AAC5D,IAAA,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;AACnG,CAAC;AAED;;;;;;;AAOG;AACa,SAAA,WAAW,CAAC,YAAA,GAA8B,CAAC,EAAA;IACzD,OAAO,oBAAoB,CAAC,aAAa,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AACrE;;ACjEA;;AAEG;;;;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|