@airpower/transformer 1.6.0 → 2.0.0

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
@@ -2,6 +2,15 @@
2
2
  <img width="300" src="./assets/airpower-bg.svg"/>
3
3
  </p>
4
4
 
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/@airpower/transformer">
7
+ <img src="https://img.shields.io/npm/v/@airpower/transformer"/>
8
+ </a>
9
+ <a href="https://www.npmjs.com/@airpower/transformer">
10
+ <img src="https://img.shields.io/npm/dm/@airpower/transformer"/>
11
+ </a>
12
+ </p>
13
+
5
14
  <p align="center">
6
15
  <a href="https://github.com/AirPowerTeam/AirPower-Transformer">Github</a> /
7
16
  <a href="https://gitee.com/air-power/AirPower-Transformer">Gitee</a> /
package/dist/main.js CHANGED
@@ -31,7 +31,7 @@ class Transformer {
31
31
  static newInstance(Class, recoverBy) {
32
32
  const instance = new Class();
33
33
  if (recoverBy) {
34
- return instance.recoverBy(recoverBy);
34
+ instance.recoverBy(recoverBy);
35
35
  }
36
36
  return instance;
37
37
  }
@@ -140,7 +140,6 @@ class Transformer {
140
140
  copy[field] = void 0;
141
141
  }
142
142
  }
143
- return copy;
144
143
  }
145
144
  /**
146
145
  * ### 排除部分类的属性
@@ -154,7 +153,6 @@ class Transformer {
154
153
  copy[field] = void 0;
155
154
  }
156
155
  }
157
- return copy;
158
156
  }
159
157
  /**
160
158
  * ### 用指定的数据对当前实例进行覆盖
@@ -162,7 +160,7 @@ class Transformer {
162
160
  * @param obj 覆盖对象
163
161
  */
164
162
  recoverBy(obj) {
165
- return Object.assign(this, obj);
163
+ Object.assign(this, obj);
166
164
  }
167
165
  /**
168
166
  * ### 转换到 `JSON`
@@ -44,18 +44,18 @@ export declare class Transformer {
44
44
  * ### 暴露部分类的属性
45
45
  * @param fields 属性列表
46
46
  */
47
- expose(...fields: Array<(keyof this) | string>): this;
47
+ expose(...fields: Array<(keyof this) | string>): void;
48
48
  /**
49
49
  * ### 排除部分类的属性
50
50
  * @param fields 属性列表
51
51
  */
52
- exclude(...fields: Array<(keyof this) | string>): this;
52
+ exclude(...fields: Array<(keyof this) | string>): void;
53
53
  /**
54
54
  * ### 用指定的数据对当前实例进行覆盖
55
55
  * 相同属性才会覆盖上去
56
56
  * @param obj 覆盖对象
57
57
  */
58
- recoverBy(obj: IJson | Transformer): this;
58
+ recoverBy(obj: IJson | Transformer): void;
59
59
  /**
60
60
  * ### 转换到 `JSON`
61
61
  * 会自动进行数据别名转换
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/transformer",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "2.0.0",
5
5
  "description": "AirPower-Transformer 是一个基于 TypeScript 的数据转换器,提供了从 JSON 对象到 类实例 对象之间互相转换的系列装饰器和方法。",
6
6
  "author": {
7
7
  "name": "Hamm",