@airpower/transformer 0.1.2 → 0.1.3
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 +12 -0
- 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,6 +131,9 @@ 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
|
+
}
|
|
125
137
|
const list = Reflect.get(target, fieldListKey) || [];
|
|
126
138
|
list.push(key);
|
|
127
139
|
this.setProperty(target, fieldListKey, list);
|