@@ -29,14 +29,11 @@ const {
2929 ArrayPrototypePush,
3030 ArrayPrototypeSlice,
3131 ArrayPrototypeSplice,
32- FunctionPrototype,
33- FunctionPrototypeBind,
3432 FunctionPrototypeCall,
3533 FunctionPrototypeSymbolHasInstance,
3634 ObjectDefineProperty,
3735 ObjectDefineProperties,
3836 ObjectSetPrototypeOf,
39- ReflectApply,
4037 StringPrototypeToLowerCase,
4138 Symbol,
4239 SymbolHasInstance,
@@ -76,7 +73,7 @@ const { errorOrDestroy } = destroyImpl;
7673ObjectSetPrototypeOf ( Writable . prototype , Stream . prototype ) ;
7774ObjectSetPrototypeOf ( Writable , Stream ) ;
7875
79- const nop = FunctionPrototype ;
76+ function nop ( ) { }
8077
8178const kOnFinished = Symbol ( 'kOnFinished' ) ;
8279
@@ -153,7 +150,7 @@ function WritableState(options, stream, isDuplex) {
153150 this . bufferProcessing = false ;
154151
155152 // The callback that's passed to _write(chunk, cb).
156- this . onwrite = FunctionPrototypeBind ( onwrite , undefined , stream ) ;
153+ this . onwrite = onwrite . bind ( undefined , stream ) ;
157154
158155 // The callback that the user supplies to write(chunk, encoding, cb).
159156 this . writecb = null ;
@@ -272,6 +269,16 @@ function Writable(options) {
272269 } ) ;
273270}
274271
272+ ObjectDefineProperty ( Writable , SymbolHasInstance , {
273+ value : function ( object ) {
274+ if ( FunctionPrototypeSymbolHasInstance ( this , object ) ) return true ;
275+ if ( this !== Writable ) return false ;
276+
277+ return object && object . _writableState instanceof WritableState ;
278+ } ,
279+ } ) ;
280+
281+
275282// Otherwise people can pipe Writable streams, which is just wrong.
276283Writable . prototype . pipe = function ( ) {
277284 errorOrDestroy ( this , new ERR_STREAM_CANNOT_PIPE ( ) ) ;
@@ -367,7 +374,7 @@ function writeOrBuffer(stream, state, chunk, encoding, callback) {
367374 state . needDrain = true ;
368375
369376 if ( state . writing || state . corked || state . errored || ! state . constructed ) {
370- ArrayPrototypePush ( state . buffered , { chunk, encoding, callback } ) ;
377+ state . buffered . push ( { chunk, encoding, callback } ) ;
371378 if ( state . allBuffers && encoding !== 'buffer' ) {
372379 state . allBuffers = false ;
373380 }
@@ -841,7 +848,7 @@ Writable.prototype.destroy = function(err, cb) {
841848 process . nextTick ( errorBuffer , state ) ;
842849 }
843850
844- ReflectApply ( destroy , this , [ err , cb ] ) ;
851+ FunctionPrototypeCall ( destroy , this , err , cb ) ;
845852 return this ;
846853} ;
847854
0 commit comments