Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.8 to 0.1.0-beta.9

2

package.json
{
"name": "class-transformer",
"version": "0.1.0-beta.8",
"version": "0.1.0-beta.9",
"description": "Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -13,4 +13,7 @@ # class-transformer

Also it allows to serialize / deserialize object based on criteria.
This tool is useful on both frontend and backend.
This tool is super useful on both frontend and backend.
Example how to use with angular 2 in [plunker](http://plnkr.co/edit/Mja1ZYAjVySWASMHVB9R).
Source code is [here](https://github.com/pleerock/class-transformer-demo).
## Installation

@@ -566,3 +569,3 @@

.map(res => res.json())
.map(res => plainToClass(User, res))
.map(res => plainToClass(User, res as Object[]))
.subscribe(users => {

@@ -576,2 +579,5 @@ // now "users" is type of User[] and each user have getName() and isAdult() methods available

Example how to use with angular 2 in [plunker](http://plnkr.co/edit/Mja1ZYAjVySWASMHVB9R).
Source code is [here](https://github.com/pleerock/class-transformer-demo).
## Samples

@@ -585,2 +591,2 @@

See information about breaking changes and release notes [here](https://github.com/pleerock/class-transformer/tree/master/doc/release-notes.md).
See information about breaking changes and release notes [here](https://github.com/pleerock/class-transformer/tree/master/doc/release-notes.md).

@@ -8,3 +8,3 @@ import { ClassTransformOptions } from "./ClassTransformOptions";

constructor(transformationType: TransformationType, options: ClassTransformOptions);
transform(source: Object | Object[] | any, value: Object | Object[] | any, targetType: Function, arrayType: Function, isMap: boolean, fromProperty: string, level?: number): any;
transform(source: Object | Object[] | any, value: Object | Object[] | any, targetType: Function, arrayType: Function, isMap: boolean, level?: number): any;
private applyCustomTransformations(value, target, key);

@@ -11,0 +11,0 @@ private isCircular(object, level);

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

// -------------------------------------------------------------------------
TransformOperationExecutor.prototype.transform = function (source, value, targetType, arrayType, isMap, fromProperty, level) {
TransformOperationExecutor.prototype.transform = function (source, value, targetType, arrayType, isMap, level) {
var _this = this;

@@ -27,3 +27,3 @@ if (level === void 0) { level = 0; }

if (!_this.isCircular(subValue, level)) {
var value_1 = _this.transform(subSource, subValue, targetType, undefined, subValue instanceof Map, fromProperty + "[" + String(index) + "]", level + 1);
var value_1 = _this.transform(subSource, subValue, targetType, undefined, subValue instanceof Map, level + 1);
if (newValue_1 instanceof Set) {

@@ -73,12 +73,11 @@ newValue_1.add(value_1);

if (!source && (this.transformationType === "plainToClass" || this.transformationType === "classToClass")) {
if (!targetType) {
console.log(value);
throw new Error("Cannot determine type for " + fromProperty + ", did you forget to specify a @Type?");
}
if (isMap) {
newValue = new Map();
}
else {
else if (targetType) {
newValue = new targetType();
}
else {
newValue = {};
}
}

@@ -144,3 +143,3 @@ // traverse over keys

if (!this.isCircular(subValue, level)) {
var finalValue = this.transform(subSource, subValue, type, arrayType_1, isSubValueMap, targetType.name + "." + propertyName, level + 1);
var finalValue = this.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1);
finalValue = this.applyCustomTransformations(finalValue, targetType, key);

@@ -147,0 +146,0 @@ if (newValue instanceof Map) {

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