File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,6 +70,24 @@ util.Buffer = (function() {
7070 if ( ! Buffer . prototype . utf8Write ) // refuse to use non-node buffers (performance)
7171 return null ;
7272
73+ // Node 4.2.0 to 4.4.7 Support. Unfortunatly not 4.0.0 - 4.1.2 compatible
74+ // See - https://github.com/nodejs/node/pull/3080 for reference
75+ if ( Buffer . from && Buffer . from . toString ( ) === Uint8Array . from . toString ( ) ) {
76+ function PolyBuffer ( arg , encoding ) {
77+ var b = new Buffer ( arg , encoding ) ;
78+ Object . setPrototypeOf ( b , PolyBuffer . prototype ) ;
79+ return b ;
80+ }
81+
82+ PolyBuffer . from = function ( value , encoding ) { return new PolyBuffer ( value , encoding ) ; } ;
83+ PolyBuffer . allocUnsafe = function allocUnsafe ( size ) { return new PolyBuffer ( size ) ; } ;
84+
85+ Object . setPrototypeOf ( PolyBuffer . prototype , Buffer . prototype ) ;
86+ Object . setPrototypeOf ( PolyBuffer , Buffer ) ;
87+
88+ return PolyBuffer ;
89+ }
90+
7391 /* istanbul ignore next */
7492 if ( ! Buffer . from )
7593 Buffer . from = function from ( value , encoding ) { return new Buffer ( value , encoding ) ; } ;
You can’t perform that action at this time.
0 commit comments