@airpower/transformer 0.1.2 → 0.1.4

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.
Files changed (2) hide show
  1. package/dist/main.js +14 -0
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -19,6 +19,9 @@ class DecoratorUtil {
19
19
  * @param isObject `可选` 是否是对象配置
20
20
  */
21
21
  static getClassConfig(target, classConfigKey, defaultValue = void 0, isObject = false) {
22
+ if (typeof target !== "object") {
23
+ target = target.prototype;
24
+ }
22
25
  let classConfig = Reflect.get(target, classConfigKey);
23
26
  if (!isObject) {
24
27
  if (classConfig) {
@@ -93,6 +96,9 @@ class DecoratorUtil {
93
96
  * @param list `递归参数` 无需传入
94
97
  */
95
98
  static getFieldList(target, fieldConfigKey, list = []) {
99
+ if (typeof target !== "object") {
100
+ target = target.prototype;
101
+ }
96
102
  const fieldList = Reflect.get(target, fieldConfigKey) || [];
97
103
  fieldList.forEach((item) => list.includes(item) || list.push(item));
98
104
  const superClass = Reflect.getPrototypeOf(target);
@@ -108,6 +114,9 @@ class DecoratorUtil {
108
114
  * @param value 配置值
109
115
  */
110
116
  static setProperty(target, key, value) {
117
+ if (typeof target !== "object") {
118
+ target = target.prototype;
119
+ }
111
120
  Reflect.defineProperty(target, key, {
112
121
  enumerable: false,
113
122
  value,
@@ -122,8 +131,13 @@ class DecoratorUtil {
122
131
  * @param fieldListKey 类配置项列表索引值
123
132
  */
124
133
  static addFieldDecoratorKey(target, key, fieldListKey) {
134
+ if (typeof target !== "object") {
135
+ target = target.prototype;
136
+ }
137
+ console.warn(target, fieldListKey, key);
125
138
  const list = Reflect.get(target, fieldListKey) || [];
126
139
  list.push(key);
140
+ console.warn(target, fieldListKey, list);
127
141
  this.setProperty(target, fieldListKey, list);
128
142
  }
129
143
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/transformer",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "AirPower-Transformer 是一个基于 TypeScript 的数据转换器,提供了从 JSON 对象到 类实例 对象之间互相转换的系列装饰器和方法。",
6
6
  "author": {
7
7
  "name": "Hamm",