@airpower/transformer 0.1.6 → 0.1.8

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 CHANGED
@@ -43,12 +43,8 @@ class DecoratorUtil {
43
43
  * @param field 属性
44
44
  * @param fieldConfigKey 配置项索引键值
45
45
  * @param fieldConfig 配置的参数
46
- * @param fieldListKey `可选` 类配置项列表索引值
47
46
  */
48
- static setFieldConfig(instance, field, fieldConfigKey, fieldConfig, fieldListKey) {
49
- if (fieldListKey) {
50
- this.addFieldDecoratorKey(instance, field, fieldListKey);
51
- }
47
+ static setFieldConfig(instance, field, fieldConfigKey, fieldConfig) {
52
48
  this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
53
49
  }
54
50
  /**
@@ -59,7 +55,7 @@ class DecoratorUtil {
59
55
  * @param isObject `可选` 是否对象配置
60
56
  */
61
57
  static getFieldConfig(Class, field, fieldConfigKey, isObject = false) {
62
- let fieldConfig = Reflect.get(Class.prototype, `${fieldConfigKey}[${field.toString()}]`);
58
+ let fieldConfig = Reflect.get(new Class(), `${fieldConfigKey}[${field.toString()}]`);
63
59
  const SuperClass = Reflect.getPrototypeOf(Class);
64
60
  if (!isObject) {
65
61
  if (fieldConfig !== void 0) {
@@ -86,7 +82,7 @@ class DecoratorUtil {
86
82
  * @param list `递归参数` 无需传入
87
83
  */
88
84
  static getFieldList(Class, fieldConfigKey, list = []) {
89
- const fieldList = Reflect.get(Class.prototype, fieldConfigKey) || [];
85
+ const fieldList = Reflect.get(new Class(), fieldConfigKey) || [];
90
86
  fieldList.forEach((item) => list.includes(item) || list.push(item));
91
87
  const SuperClass = Reflect.getPrototypeOf(Class);
92
88
  if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
@@ -108,17 +104,6 @@ class DecoratorUtil {
108
104
  configurable: true
109
105
  });
110
106
  }
111
- /**
112
- * ### 设置一个属性的包含装饰器索引
113
- * @param instance 目标类
114
- * @param field 属性
115
- * @param propertyKey 类配置项列表索引值
116
- */
117
- static addFieldDecoratorKey(instance, field, propertyKey) {
118
- const list = Reflect.get(instance, propertyKey) || [];
119
- list.push(field);
120
- this.setProperty(instance, propertyKey, list);
121
- }
122
107
  }
123
108
  class Transformer {
124
109
  /**
@@ -27,9 +27,8 @@ export declare class DecoratorUtil {
27
27
  * @param field 属性
28
28
  * @param fieldConfigKey 配置项索引键值
29
29
  * @param fieldConfig 配置的参数
30
- * @param fieldListKey `可选` 类配置项列表索引值
31
30
  */
32
- static setFieldConfig<T extends Transformer>(instance: T, field: keyof T, fieldConfigKey: string, fieldConfig: unknown, fieldListKey?: string): void;
31
+ static setFieldConfig<T extends Transformer>(instance: T, field: keyof T, fieldConfigKey: string, fieldConfig: unknown): void;
33
32
  /**
34
33
  * ### 获取类指定属性的指定类型的配置
35
34
  * @param Class 目标类
@@ -52,11 +51,4 @@ export declare class DecoratorUtil {
52
51
  * @param value 配置值
53
52
  */
54
53
  private static setProperty;
55
- /**
56
- * ### 设置一个属性的包含装饰器索引
57
- * @param instance 目标类
58
- * @param field 属性
59
- * @param propertyKey 类配置项列表索引值
60
- */
61
- private static addFieldDecoratorKey;
62
54
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/transformer",
3
3
  "type": "module",
4
- "version": "0.1.6",
4
+ "version": "0.1.8",
5
5
  "description": "AirPower-Transformer 是一个基于 TypeScript 的数据转换器,提供了从 JSON 对象到 类实例 对象之间互相转换的系列装饰器和方法。",
6
6
  "author": {
7
7
  "name": "Hamm",