@@ -11,27 +11,24 @@ var GLOBAL = (function getGlobal () {
1111} ) ( ) ;
1212
1313var TYPED_ARRAY_CTORS = {
14- 'Int8Array' : Int8Array ,
15- 'Uint8Array' : Uint8Array ,
16- 'Uint8ClampedArray' : Uint8ClampedArray ,
17- 'Int16Array' : Int16Array ,
18- 'Uint16Array' : Uint16Array ,
19- 'Int32Array' : Int32Array ,
20- 'Uint32Array' : Uint32Array ,
21- 'Float32Array' : Float32Array ,
22- 'Float64Array' : Float64Array
14+ 'Int8Array' : typeof Int8Array === 'function' ? Int8Array : void 0 ,
15+ 'Uint8Array' : typeof Uint8Array === 'function' ? Uint8Array : void 0 ,
16+ 'Uint8ClampedArray' : typeof Uint8ClampedArray === 'function' ? Uint8ClampedArray : void 0 ,
17+ 'Int16Array' : typeof Int16Array === 'function' ? Int16Array : void 0 ,
18+ 'Uint16Array' : typeof Uint16Array === 'function' ? Uint16Array : void 0 ,
19+ 'Int32Array' : typeof Int32Array === 'function' ? Int32Array : void 0 ,
20+ 'Uint32Array' : typeof Uint32Array === 'function' ? Uint32Array : void 0 ,
21+ 'Float32Array' : typeof Float32Array === 'function' ? Float32Array : void 0 ,
22+ 'Float64Array' : typeof Float64Array === 'function' ? Float64Array : void 0
2323} ;
2424
25- function isFunction ( value ) {
26- return typeof value === 'function' ;
27- }
28-
29- var ARRAY_BUFFER_SUPPORTED = isFunction ( ArrayBuffer ) ;
30- var MAP_SUPPORTED = isFunction ( Map ) ;
31- var SET_SUPPORTED = isFunction ( Set ) ;
25+ var ARRAY_BUFFER_SUPPORTED = typeof ArrayBuffer === 'function' ;
26+ var MAP_SUPPORTED = typeof Map === 'function' ;
27+ var SET_SUPPORTED = typeof Set === 'function' ;
28+ var BUFFER_FROM_SUPPORTED = typeof Buffer === 'function' ;
3229
3330var TYPED_ARRAY_SUPPORTED = function ( typeName ) {
34- return isFunction ( TYPED_ARRAY_CTORS [ typeName ] ) ;
31+ return ! ! TYPED_ARRAY_CTORS [ typeName ] ;
3532} ;
3633
3734// Saved proto functions
@@ -413,6 +410,25 @@ var builtInTransforms = [
413410 }
414411 } ,
415412
413+ {
414+ type : '[[Buffer]]' ,
415+
416+ shouldTransform : function ( type , val ) {
417+ return BUFFER_FROM_SUPPORTED && val instanceof Buffer ;
418+ } ,
419+
420+ toSerializable : function ( buffer ) {
421+ return arrSlice . call ( buffer ) ;
422+ } ,
423+
424+ fromSerializable : function ( val ) {
425+ if ( BUFFER_FROM_SUPPORTED )
426+ return Buffer . from ( val ) ;
427+
428+ return val ;
429+ }
430+ } ,
431+
416432 {
417433 type : '[[TypedArray]]' ,
418434
0 commit comments