File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " class-transformer" ,
3
- "version" : " 0.2.0 " ,
3
+ "version" : " 0.2.1 " ,
4
4
"description" : " Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors" ,
5
5
"license" : " MIT" ,
6
6
"readmeFilename" : " README.md" ,
Original file line number Diff line number Diff line change @@ -97,8 +97,8 @@ export class TransformOperationExecutor {
97
97
if ( value === null || value === undefined )
98
98
return value ;
99
99
return new Date ( value ) ;
100
-
101
- } else if ( ( targetType === Buffer || value instanceof Buffer ) && ! isMap ) {
100
+
101
+ } else if ( testForBuffer ( ) && ( targetType === Buffer || value instanceof Buffer ) && ! isMap ) {
102
102
if ( value === null || value === undefined )
103
103
return value ;
104
104
return Buffer . from ( value ) ;
@@ -411,10 +411,19 @@ export class TransformOperationExecutor {
411
411
412
412
}
413
413
414
- function instantiateArrayType ( arrayType : Function ) : Array < any > | Set < any > {
414
+ function instantiateArrayType ( arrayType : Function ) : Array < any > | Set < any > {
415
415
const array = new ( arrayType as any ) ( ) ;
416
416
if ( ! ( array instanceof Set ) && ! ( "push" in array ) ) {
417
417
return [ ] ;
418
418
}
419
419
return array ;
420
420
}
421
+
422
+
423
+ function testForBuffer ( ) : boolean {
424
+ try {
425
+ Buffer
426
+ return true ;
427
+ } catch { }
428
+ return false ;
429
+ }
You can’t perform that action at this time.
0 commit comments