File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,24 @@ util.Buffer = (function() {
70
70
if ( ! Buffer . prototype . utf8Write ) // refuse to use non-node buffers (performance)
71
71
return null ;
72
72
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
+
73
91
/* istanbul ignore next */
74
92
if ( ! Buffer . from )
75
93
Buffer . from = function from ( value , encoding ) { return new Buffer ( value , encoding ) ; } ;
You can’t perform that action at this time.
0 commit comments