Skip to content

Commit

Permalink
merge: release 0.5.1 (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoNameProvided authored Nov 22, 2021
2 parents 12fb2c6 + 11077f4 commit 9c9012f
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 23 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

### [0.5.1][v0.5.1] [BREAKING CHANGE] - 2021-11-22

#### Changed

- re-added accidentally removed deprecated function names `classToPlain` and `plainToClass`

### [0.5.0][v0.5.0] [BREAKING CHANGE] - 2021-11-20

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

[v0.5.1]: https://github.com/typestack/class-transformer/compare/v0.5.0...v0.5.1
[v0.5.0]: https://github.com/typestack/class-transformer/compare/v0.4.1...v0.5.0
[v0.4.1]: https://github.com/typestack/class-transformer/compare/v0.4.0...v0.4.1
[v0.4.0]: https://github.com/typestack/class-transformer/compare/v0.3.2...v0.4.0
Expand Down
57 changes: 37 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "class-transformer",
"version": "0.5.0",
"version": "0.5.1",
"description": "Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors",
"author": "TypeStack contributors",
"license": "MIT",
Expand Down Expand Up @@ -63,11 +63,11 @@
"eslint-plugin-jest": "^25.2.4",
"husky": "^4.3.8",
"jest": "^26.6.3",
"lint-staged": "^12.0.3",
"lint-staged": "^12.1.2",
"prettier": "^2.4.1",
"reflect-metadata": "0.1.13",
"rimraf": "3.0.2",
"rollup": "^2.60.0",
"rollup": "^2.60.1",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^26.5.6",
"ts-node": "^10.4.0",
Expand Down
25 changes: 25 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ export * from './enums';

const classTransformer = new ClassTransformer();

/**
* Converts class (constructor) object to plain (literal) object. Also works with arrays.
*
* @deprecated Function name changed, use the `instanceToPlain` method instead.
*/
export function classToPlain<T>(object: T, options?: ClassTransformOptions): Record<string, any>;
export function classToPlain<T>(object: T[], options?: ClassTransformOptions): Record<string, any>[];
export function classToPlain<T>(
object: T | T[],
options?: ClassTransformOptions
): Record<string, any> | Record<string, any>[] {
return classTransformer.instanceToPlain(object, options);
}

/**
* Converts class (constructor) object to plain (literal) object. Also works with arrays.
*/
Expand Down Expand Up @@ -46,6 +60,17 @@ export function classToPlainFromExist<T>(
return classTransformer.classToPlainFromExist(object, plainObject, options);
}

/**
* Converts plain (literal) object to class (constructor) object. Also works with arrays.
*
* @deprecated Function name changed, use the `plainToInstance` method instead.
*/
export function plainToClass<T, V>(cls: ClassConstructor<T>, plain: V[], options?: ClassTransformOptions): T[];
export function plainToClass<T, V>(cls: ClassConstructor<T>, plain: V, options?: ClassTransformOptions): T;
export function plainToClass<T, V>(cls: ClassConstructor<T>, plain: V | V[], options?: ClassTransformOptions): T | T[] {
return classTransformer.plainToInstance(cls, plain as any, options);
}

/**
* Converts plain (literal) object to class (constructor) object. Also works with arrays.
*/
Expand Down

0 comments on commit 9c9012f

Please sign in to comment.