@@ -2,6 +2,7 @@ import { ClassTransformOptions } from './interfaces';
2
2
import { TransformOperationExecutor } from './TransformOperationExecutor' ;
3
3
import { TransformationType } from './enums' ;
4
4
import { ClassConstructor } from './interfaces' ;
5
+ import { defaultOptions } from './constants/default-options.constant' ;
5
6
6
7
export class ClassTransformer {
7
8
// -------------------------------------------------------------------------
@@ -17,7 +18,10 @@ export class ClassTransformer {
17
18
object : T | T [ ] ,
18
19
options ?: ClassTransformOptions
19
20
) : Record < string , any > | Record < string , any > [ ] {
20
- const executor = new TransformOperationExecutor ( TransformationType . CLASS_TO_PLAIN , options || { } ) ;
21
+ const executor = new TransformOperationExecutor ( TransformationType . CLASS_TO_PLAIN , {
22
+ ...defaultOptions ,
23
+ ...options ,
24
+ } ) ;
21
25
return executor . transform ( undefined , object , undefined , undefined , undefined , undefined ) ;
22
26
}
23
27
@@ -41,7 +45,10 @@ export class ClassTransformer {
41
45
plainObject : P | P [ ] ,
42
46
options ?: ClassTransformOptions
43
47
) : T | T [ ] {
44
- const executor = new TransformOperationExecutor ( TransformationType . CLASS_TO_PLAIN , options || { } ) ;
48
+ const executor = new TransformOperationExecutor ( TransformationType . CLASS_TO_PLAIN , {
49
+ ...defaultOptions ,
50
+ ...options ,
51
+ } ) ;
45
52
return executor . transform ( plainObject , object , undefined , undefined , undefined , undefined ) ;
46
53
}
47
54
@@ -63,7 +70,10 @@ export class ClassTransformer {
63
70
plain : V | V [ ] ,
64
71
options ?: ClassTransformOptions
65
72
) : T | T [ ] {
66
- const executor = new TransformOperationExecutor ( TransformationType . PLAIN_TO_CLASS , options || { } ) ;
73
+ const executor = new TransformOperationExecutor ( TransformationType . PLAIN_TO_CLASS , {
74
+ ...defaultOptions ,
75
+ ...options ,
76
+ } ) ;
67
77
return executor . transform ( undefined , plain , cls , undefined , undefined , undefined ) ;
68
78
}
69
79
@@ -83,7 +93,10 @@ export class ClassTransformer {
83
93
plain : V | V [ ] ,
84
94
options ?: ClassTransformOptions
85
95
) : T | T [ ] {
86
- const executor = new TransformOperationExecutor ( TransformationType . PLAIN_TO_CLASS , options || { } ) ;
96
+ const executor = new TransformOperationExecutor ( TransformationType . PLAIN_TO_CLASS , {
97
+ ...defaultOptions ,
98
+ ...options ,
99
+ } ) ;
87
100
return executor . transform ( clsObject , plain , undefined , undefined , undefined , undefined ) ;
88
101
}
89
102
@@ -93,7 +106,10 @@ export class ClassTransformer {
93
106
classToClass < T > ( object : T , options ?: ClassTransformOptions ) : T ;
94
107
classToClass < T > ( object : T [ ] , options ?: ClassTransformOptions ) : T [ ] ;
95
108
classToClass < T > ( object : T | T [ ] , options ?: ClassTransformOptions ) : T | T [ ] {
96
- const executor = new TransformOperationExecutor ( TransformationType . CLASS_TO_CLASS , options || { } ) ;
109
+ const executor = new TransformOperationExecutor ( TransformationType . CLASS_TO_CLASS , {
110
+ ...defaultOptions ,
111
+ ...options ,
112
+ } ) ;
97
113
return executor . transform ( undefined , object , undefined , undefined , undefined , undefined ) ;
98
114
}
99
115
@@ -105,7 +121,10 @@ export class ClassTransformer {
105
121
classToClassFromExist < T > ( object : T , fromObject : T , options ?: ClassTransformOptions ) : T ;
106
122
classToClassFromExist < T > ( object : T , fromObjects : T [ ] , options ?: ClassTransformOptions ) : T [ ] ;
107
123
classToClassFromExist < T > ( object : T , fromObject : T | T [ ] , options ?: ClassTransformOptions ) : T | T [ ] {
108
- const executor = new TransformOperationExecutor ( TransformationType . CLASS_TO_CLASS , options || { } ) ;
124
+ const executor = new TransformOperationExecutor ( TransformationType . CLASS_TO_CLASS , {
125
+ ...defaultOptions ,
126
+ ...options ,
127
+ } ) ;
109
128
return executor . transform ( fromObject , object , undefined , undefined , undefined , undefined ) ;
110
129
}
111
130
0 commit comments