Skip to content

Commit 9c9012f

Browse files
merge: release 0.5.1 (#1003)
2 parents 12fb2c6 + 11077f4 commit 9c9012f

File tree

4 files changed

+72
-23
lines changed

4 files changed

+72
-23
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
_This changelog follows the [keep a changelog][keep-a-changelog]_ format to maintain a human readable changelog.
44

5+
### [0.5.1][v0.5.1] [BREAKING CHANGE] - 2021-11-22
6+
7+
#### Changed
8+
9+
- re-added accidentally removed deprecated function names `classToPlain` and `plainToClass`
10+
511
### [0.5.0][v0.5.0] [BREAKING CHANGE] - 2021-11-20
612

713
> **NOTE:** This version fixes a security vulnerability allowing denial of service attacks with a specially crafted request payload. Please update as soon as possible.
@@ -229,6 +235,7 @@ This version has introduced a breaking-change when this library is used with cla
229235
- Library has changed its name from `serializer.ts` to `constructor-utils`.
230236
- Added `constructor-utils` namespace.
231237

238+
[v0.5.1]: https://github.com/typestack/class-transformer/compare/v0.5.0...v0.5.1
232239
[v0.5.0]: https://github.com/typestack/class-transformer/compare/v0.4.1...v0.5.0
233240
[v0.4.1]: https://github.com/typestack/class-transformer/compare/v0.4.0...v0.4.1
234241
[v0.4.0]: https://github.com/typestack/class-transformer/compare/v0.3.2...v0.4.0

package-lock.json

Lines changed: 37 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "class-transformer",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors",
55
"author": "TypeStack contributors",
66
"license": "MIT",
@@ -63,11 +63,11 @@
6363
"eslint-plugin-jest": "^25.2.4",
6464
"husky": "^4.3.8",
6565
"jest": "^26.6.3",
66-
"lint-staged": "^12.0.3",
66+
"lint-staged": "^12.1.2",
6767
"prettier": "^2.4.1",
6868
"reflect-metadata": "0.1.13",
6969
"rimraf": "3.0.2",
70-
"rollup": "^2.60.0",
70+
"rollup": "^2.60.1",
7171
"rollup-plugin-terser": "^7.0.2",
7272
"ts-jest": "^26.5.6",
7373
"ts-node": "^10.4.0",

src/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ export * from './enums';
99

1010
const classTransformer = new ClassTransformer();
1111

12+
/**
13+
* Converts class (constructor) object to plain (literal) object. Also works with arrays.
14+
*
15+
* @deprecated Function name changed, use the `instanceToPlain` method instead.
16+
*/
17+
export function classToPlain<T>(object: T, options?: ClassTransformOptions): Record<string, any>;
18+
export function classToPlain<T>(object: T[], options?: ClassTransformOptions): Record<string, any>[];
19+
export function classToPlain<T>(
20+
object: T | T[],
21+
options?: ClassTransformOptions
22+
): Record<string, any> | Record<string, any>[] {
23+
return classTransformer.instanceToPlain(object, options);
24+
}
25+
1226
/**
1327
* Converts class (constructor) object to plain (literal) object. Also works with arrays.
1428
*/
@@ -46,6 +60,17 @@ export function classToPlainFromExist<T>(
4660
return classTransformer.classToPlainFromExist(object, plainObject, options);
4761
}
4862

63+
/**
64+
* Converts plain (literal) object to class (constructor) object. Also works with arrays.
65+
*
66+
* @deprecated Function name changed, use the `plainToInstance` method instead.
67+
*/
68+
export function plainToClass<T, V>(cls: ClassConstructor<T>, plain: V[], options?: ClassTransformOptions): T[];
69+
export function plainToClass<T, V>(cls: ClassConstructor<T>, plain: V, options?: ClassTransformOptions): T;
70+
export function plainToClass<T, V>(cls: ClassConstructor<T>, plain: V | V[], options?: ClassTransformOptions): T | T[] {
71+
return classTransformer.plainToInstance(cls, plain as any, options);
72+
}
73+
4974
/**
5075
* Converts plain (literal) object to class (constructor) object. Also works with arrays.
5176
*/

0 commit comments

Comments
 (0)