Socket
Socket
Sign inDemoInstall

class-transformer

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

class-transformer - npm Package Compare versions

Comparing version 0.1.0-beta.1 to 0.1.0-beta.2

1

index.d.ts

@@ -5,2 +5,3 @@ import { ClassType } from "./ClassTransformer";

export { ClassTransformer } from "./ClassTransformer";
export { ClassTransformOptions } from "./ClassTransformOptions";
export * from "./decorators";

@@ -7,0 +8,0 @@ /**

8

package.json
{
"name": "class-transformer",
"version": "0.1.0-beta.1",
"description": "Transforms or serializes / deserializes objects from one shape into another based on class decorators",
"version": "0.1.0-beta.2",
"description": "Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors",
"license": "MIT",

@@ -51,3 +51,7 @@ "readmeFilename": "README.md",

"typings": "^1.3.2"
},
"scripts": {
"postinstall": "typings install",
"test": "gulp tests"
}
}

@@ -13,2 +13,3 @@ # class-transformer

Also it allows to serialize / deserialize object based on criteria.
This tool is useful on both frontend and backend.

@@ -252,2 +253,55 @@ ## Installation

### Exposing getters and method return values
You can expose what you getter or method return by setting a `@Expose()` decorator to those getters or methods:
```javascript
import {Expose} from "class-transformer";
export class User {
id: number;
firstName: string;
lastName: string;
password: string;
@Expose()
get name() {
return this.firstName + " " + this.lastName;
}
@Expose()
getFullName() {
return this.firstName + " " + this.lastName;
}
}
```
### Exposing properties with different names
If you want to expose some of properties with different names,
you can do it by specifying a `name` option to `@Expose` decorator:
```javascript
import {Expose} from "class-transformer";
export class User {
@Expose("uid")
id: number;
firstName: string;
lastName: string;
@Expose("secretKey")
password: string;
@Expose("fullName")
getFullName() {
return this.firstName + " " + this.lastName;
}
}
```
### Skipping specific properties

@@ -254,0 +308,0 @@

@@ -88,3 +88,3 @@ "use strict";

if (this.transformationType === "plainToClass" && !type && subValue instanceof Object && !(subValue instanceof Date))
throw new Error("Cannot determine type for " + targetType.name + "." + propertyName + ", did you forgot to specify a @Type?");
throw new Error("Cannot determine type for " + targetType.name + "." + propertyName + ", did you forget to specify a @Type?");
// if newValue is a source object that has method that match newKeyName then skip it

@@ -91,0 +91,0 @@ var hasDescriptor = false;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc