@airpower/transformer 0.1.5 → 0.1.7
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/dist/main.js +1 -23
- package/dist/transformer/DecoratorUtil.d.ts +1 -13
- package/dist/type/index.d.ts +0 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
1
|
class DecoratorUtil {
|
|
5
2
|
/**
|
|
6
3
|
* ### 设置一个类配置项
|
|
@@ -46,12 +43,8 @@ class DecoratorUtil {
|
|
|
46
43
|
* @param field 属性
|
|
47
44
|
* @param fieldConfigKey 配置项索引键值
|
|
48
45
|
* @param fieldConfig 配置的参数
|
|
49
|
-
* @param fieldListKey `可选` 类配置项列表索引值
|
|
50
46
|
*/
|
|
51
|
-
static setFieldConfig(instance, field, fieldConfigKey, fieldConfig
|
|
52
|
-
if (fieldListKey) {
|
|
53
|
-
this.addFieldDecoratorKey(instance, field, fieldListKey);
|
|
54
|
-
}
|
|
47
|
+
static setFieldConfig(instance, field, fieldConfigKey, fieldConfig) {
|
|
55
48
|
this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
|
|
56
49
|
}
|
|
57
50
|
/**
|
|
@@ -111,22 +104,7 @@ class DecoratorUtil {
|
|
|
111
104
|
configurable: true
|
|
112
105
|
});
|
|
113
106
|
}
|
|
114
|
-
/**
|
|
115
|
-
* ### 设置一个属性的包含装饰器索引
|
|
116
|
-
* @param instance 目标类
|
|
117
|
-
* @param field 属性
|
|
118
|
-
* @param propertyKey 类配置项列表索引值
|
|
119
|
-
*/
|
|
120
|
-
static addFieldDecoratorKey(instance, field, propertyKey) {
|
|
121
|
-
const list = Reflect.get(instance, propertyKey) || [];
|
|
122
|
-
list.push(field);
|
|
123
|
-
this.setProperty(instance, propertyKey, list);
|
|
124
|
-
}
|
|
125
107
|
}
|
|
126
|
-
/**
|
|
127
|
-
* ### 装饰器前缀
|
|
128
|
-
*/
|
|
129
|
-
__publicField(DecoratorUtil, "DecoratorKeyPrefix", "[AirPower]");
|
|
130
108
|
class Transformer {
|
|
131
109
|
/**
|
|
132
110
|
* ### 从 `JSON` 转换到当前类的对象
|
|
@@ -6,10 +6,6 @@ import { ITransformerConstructor, Transformer } from './index';
|
|
|
6
6
|
* @author Hamm.cn
|
|
7
7
|
*/
|
|
8
8
|
export declare class DecoratorUtil {
|
|
9
|
-
/**
|
|
10
|
-
* ### 装饰器前缀
|
|
11
|
-
*/
|
|
12
|
-
static readonly DecoratorKeyPrefix = "[AirPower]";
|
|
13
9
|
/**
|
|
14
10
|
* ### 设置一个类配置项
|
|
15
11
|
* @param Class 目标类
|
|
@@ -31,9 +27,8 @@ export declare class DecoratorUtil {
|
|
|
31
27
|
* @param field 属性
|
|
32
28
|
* @param fieldConfigKey 配置项索引键值
|
|
33
29
|
* @param fieldConfig 配置的参数
|
|
34
|
-
* @param fieldListKey `可选` 类配置项列表索引值
|
|
35
30
|
*/
|
|
36
|
-
static setFieldConfig<T extends Transformer>(instance: T, field: keyof T, fieldConfigKey: string, fieldConfig: unknown
|
|
31
|
+
static setFieldConfig<T extends Transformer>(instance: T, field: keyof T, fieldConfigKey: string, fieldConfig: unknown): void;
|
|
37
32
|
/**
|
|
38
33
|
* ### 获取类指定属性的指定类型的配置
|
|
39
34
|
* @param Class 目标类
|
|
@@ -56,11 +51,4 @@ export declare class DecoratorUtil {
|
|
|
56
51
|
* @param value 配置值
|
|
57
52
|
*/
|
|
58
53
|
private static setProperty;
|
|
59
|
-
/**
|
|
60
|
-
* ### 设置一个属性的包含装饰器索引
|
|
61
|
-
* @param instance 目标类
|
|
62
|
-
* @param field 属性
|
|
63
|
-
* @param propertyKey 类配置项列表索引值
|
|
64
|
-
*/
|
|
65
|
-
private static addFieldDecoratorKey;
|
|
66
54
|
}
|
package/dist/type/index.d.ts
CHANGED