@ng-util/util 19.0.1 → 20.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 CHANGED
@@ -16,7 +16,7 @@ Universal toolset of Angular.
16
16
 
17
17
  ## API
18
18
 
19
- ### convert
19
+ ### convert (deprecated)
20
20
 
21
21
  - `toBoolean`、`@InputBoolean()`
22
22
  - `toNumber`、`@InputNumber()`
@@ -1,5 +1,31 @@
1
1
  /**
2
- * Generated bundle index. Do not edit.
2
+ * @deprecated use `booleanAttribute` instead
3
3
  */
4
- /// <amd-module name="@ng-util/util/convert" />
5
- export * from './public-api';
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 };
@@ -1 +1 @@
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: number = 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,oBAA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;AAQG;AACa,SAAA,YAAY,CAAC,YAAA,GAA+B,KAAK,EAAA;IAC/D,OAAO,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC;AACrE;SAOgB,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;AAClG;AAEA;;;;;;;;AAQG;AACa,SAAA,WAAW,CAAC,YAAA,GAA8B,CAAC,EAAA;IACzD,OAAO,oBAAoB,CAAC,aAAa,EAAE,QAAQ,EAAE,YAAY,CAAC;AACpE;;AC3EA;;AAEG;;;;"}
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,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE;AAC7C,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,QAAQ,EAAE;AACX,SAAA,CAAC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ts CHANGED
@@ -1,5 +1 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- /// <amd-module name="@ng-util/util" />
5
- export * from './public-api';
1
+ export * from '@ng-util/util/convert';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-util/util",
3
- "version": "19.0.1",
3
+ "version": "20.0.1",
4
4
  "author": "cipchk<cipchk@qq.com>",
5
5
  "license": "MIT",
6
6
  "repository": {
package/convert/prop.d.ts DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * @deprecated use `booleanAttribute` instead
3
- */
4
- export 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
- export declare function InputBoolean(defaultValue?: boolean | null): any;
15
- /**
16
- * @deprecated use `numberAttribute` instead
17
- */
18
- export declare function toNumber(value: any): number;
19
- export 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
- export declare function InputNumber(defaultValue?: number | null): any;
@@ -1 +0,0 @@
1
- export * from './prop';
package/public-api.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '@ng-util/util/convert';