-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClassTransformer.js
52 lines (51 loc) · 3.12 KB
/
ClassTransformer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TransformOperationExecutor_1 = require("./TransformOperationExecutor");
var ClassTransformer = /** @class */ (function () {
function ClassTransformer() {
}
ClassTransformer.prototype.classToPlain = function (object, options) {
var executor = new TransformOperationExecutor_1.TransformOperationExecutor(TransformOperationExecutor_1.TransformationType.CLASS_TO_PLAIN, options || {});
return executor.transform(undefined, object, undefined, undefined, undefined, undefined);
};
ClassTransformer.prototype.classToPlainFromExist = function (object, plainObject, options) {
var executor = new TransformOperationExecutor_1.TransformOperationExecutor(TransformOperationExecutor_1.TransformationType.CLASS_TO_PLAIN, options || {});
return executor.transform(plainObject, object, undefined, undefined, undefined, undefined);
};
ClassTransformer.prototype.plainToClass = function (cls, plain, options) {
var executor = new TransformOperationExecutor_1.TransformOperationExecutor(TransformOperationExecutor_1.TransformationType.PLAIN_TO_CLASS, options || {});
return executor.transform(undefined, plain, cls, undefined, undefined, undefined);
};
ClassTransformer.prototype.plainToClassFromExist = function (clsObject, plain, options) {
var executor = new TransformOperationExecutor_1.TransformOperationExecutor(TransformOperationExecutor_1.TransformationType.PLAIN_TO_CLASS, options || {});
return executor.transform(clsObject, plain, undefined, undefined, undefined, undefined);
};
ClassTransformer.prototype.classToClass = function (object, options) {
var executor = new TransformOperationExecutor_1.TransformOperationExecutor(TransformOperationExecutor_1.TransformationType.CLASS_TO_CLASS, options || {});
return executor.transform(undefined, object, undefined, undefined, undefined, undefined);
};
ClassTransformer.prototype.classToClassFromExist = function (object, fromObject, options) {
var executor = new TransformOperationExecutor_1.TransformOperationExecutor(TransformOperationExecutor_1.TransformationType.CLASS_TO_CLASS, options || {});
return executor.transform(fromObject, object, undefined, undefined, undefined, undefined);
};
ClassTransformer.prototype.serialize = function (object, options) {
return JSON.stringify(this.classToPlain(object, options));
};
/**
* Deserializes given JSON string to a object of the given class.
*/
ClassTransformer.prototype.deserialize = function (cls, json, options) {
var jsonObject = JSON.parse(json);
return this.plainToClass(cls, jsonObject, options);
};
/**
* Deserializes given JSON string to an array of objects of the given class.
*/
ClassTransformer.prototype.deserializeArray = function (cls, json, options) {
var jsonObject = JSON.parse(json);
return this.plainToClass(cls, jsonObject, options);
};
return ClassTransformer;
}());
exports.ClassTransformer = ClassTransformer;
//# sourceMappingURL=ClassTransformer.js.map