@ng-util/util 20.1.0 → 21.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/README.md +2 -2
- package/fesm2022/util.mjs +2 -1
- package/fesm2022/util.mjs.map +1 -1
- package/package.json +3 -7
- package/types/util.d.ts +2 -0
- package/convert/index.d.ts +0 -31
- package/fesm2022/utilConvert.mjs +0 -66
- package/fesm2022/utilConvert.mjs.map +0 -1
- package/index.d.ts +0 -1
package/README.md
CHANGED
package/fesm2022/util.mjs
CHANGED
package/fesm2022/util.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
1
|
+
{"version":3,"file":"util.mjs","sources":["../../../../packages/util/public-api.ts","../../../../packages/util/util.ts"],"sourcesContent":["// https://github.com/ng-packagr/ng-packagr/issues/1655\nexport default void 0;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;AACA,gBAAe,KAAK,CAAC;;ACDrB;;AAEG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-util/util",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.1",
|
|
4
4
|
"author": "cipchk<cipchk@qq.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -19,18 +19,14 @@
|
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"module": "fesm2022/util.mjs",
|
|
22
|
-
"typings": "
|
|
22
|
+
"typings": "types/util.d.ts",
|
|
23
23
|
"exports": {
|
|
24
24
|
"./package.json": {
|
|
25
25
|
"default": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
".": {
|
|
28
|
-
"types": "./
|
|
28
|
+
"types": "./types/util.d.ts",
|
|
29
29
|
"default": "./fesm2022/util.mjs"
|
|
30
|
-
},
|
|
31
|
-
"./convert": {
|
|
32
|
-
"types": "./convert/index.d.ts",
|
|
33
|
-
"default": "./fesm2022/utilConvert.mjs"
|
|
34
30
|
}
|
|
35
31
|
},
|
|
36
32
|
"dependencies": {
|
package/types/util.d.ts
ADDED
package/convert/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated use `booleanAttribute` instead
|
|
3
|
-
*/
|
|
4
|
-
declare function toBoolean(value: any, allowUndefined?: boolean | null): boolean | undefined;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated use `booleanAttribute` instead
|
|
7
|
-
* Input decorator that handle a prop to do get/set automatically with toBoolean
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* @Input() InputBoolean() visible: boolean = false;
|
|
11
|
-
* @Input() @InputBoolean(null) visible: boolean = false;
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
declare function InputBoolean(defaultValue?: boolean | null): any;
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated use `numberAttribute` instead
|
|
17
|
-
*/
|
|
18
|
-
declare function toNumber(value: any): number;
|
|
19
|
-
declare function toNumber<D>(value: any, fallback: D): number | D;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated use `numberAttribute` instead
|
|
22
|
-
* Input decorator that handle a prop to do get/set automatically with toNumber
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* @Input() @InputNumber() visible: number = 1;
|
|
26
|
-
* @Input() @InputNumber(null) visible: number = 2;
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare function InputNumber(defaultValue?: number | null): any;
|
|
30
|
-
|
|
31
|
-
export { InputBoolean, InputNumber, toBoolean, toNumber };
|
package/fesm2022/utilConvert.mjs
DELETED
|
@@ -1,66 +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
|
|
14
|
-
? originalDescriptor.get.bind(this)()
|
|
15
|
-
: this[privatePropName];
|
|
16
|
-
},
|
|
17
|
-
set(value) {
|
|
18
|
-
if (originalDescriptor && originalDescriptor.set) {
|
|
19
|
-
originalDescriptor.set.bind(this)(fallback(value, defaultValue));
|
|
20
|
-
}
|
|
21
|
-
this[privatePropName] = fallback(value, defaultValue);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return propDecorator;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated use `booleanAttribute` instead
|
|
29
|
-
*/
|
|
30
|
-
function toBoolean(value, allowUndefined = false) {
|
|
31
|
-
return allowUndefined && typeof value === 'undefined' ? undefined : value != null && `${value}` !== 'false';
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated use `booleanAttribute` instead
|
|
35
|
-
* Input decorator that handle a prop to do get/set automatically with toBoolean
|
|
36
|
-
*
|
|
37
|
-
* ```ts
|
|
38
|
-
* @Input() InputBoolean() visible: boolean = false;
|
|
39
|
-
* @Input() @InputBoolean(null) visible: boolean = false;
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
function InputBoolean(defaultValue = false) {
|
|
43
|
-
return propDecoratorFactory('InputNumber', toBoolean, defaultValue);
|
|
44
|
-
}
|
|
45
|
-
function toNumber(value, fallbackValue = 0) {
|
|
46
|
-
return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated use `numberAttribute` instead
|
|
50
|
-
* Input decorator that handle a prop to do get/set automatically with toNumber
|
|
51
|
-
*
|
|
52
|
-
* ```ts
|
|
53
|
-
* @Input() @InputNumber() visible: number = 1;
|
|
54
|
-
* @Input() @InputNumber(null) visible: number = 2;
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
function InputNumber(defaultValue = 0) {
|
|
58
|
-
return propDecoratorFactory('InputNumber', toNumber, defaultValue);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Generated bundle index. Do not edit.
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
export { InputBoolean, InputNumber, toBoolean, toNumber };
|
|
66
|
-
//# 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\n ? originalDescriptor.get.bind(this)()\n : 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\n/**\n * @deprecated use `booleanAttribute` instead\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 * @deprecated use `booleanAttribute` instead\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\n/**\n * @deprecated use `numberAttribute` instead\n */\nexport function toNumber(value: any): number;\nexport function toNumber<D>(value: any, fallback: D): number | D;\nexport function toNumber(value: any, fallbackValue = 0): number {\n return !isNaN(parseFloat(value as any)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;\n}\n\n/**\n * @deprecated use `numberAttribute` instead\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;AAEzC,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;;AAG5G,QAAA,MAAM,CAAC,c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