@@ -29,15 +29,12 @@ const {
2929 ArrayPrototypePush,
3030 ArrayPrototypeSlice,
3131 ArrayPrototypeSplice,
32- FunctionPrototype,
3332 Error,
34- FunctionPrototypeBind,
3533 FunctionPrototypeCall,
3634 FunctionPrototypeSymbolHasInstance,
3735 ObjectDefineProperty,
3836 ObjectDefineProperties,
3937 ObjectSetPrototypeOf,
40- ReflectApply,
4138 StringPrototypeToLowerCase,
4239 Symbol,
4340 SymbolHasInstance,
@@ -77,7 +74,7 @@ const { errorOrDestroy } = destroyImpl;
7774ObjectSetPrototypeOf ( Writable . prototype , Stream . prototype ) ;
7875ObjectSetPrototypeOf ( Writable , Stream ) ;
7976
80- const nop = FunctionPrototype ;
77+ function nop ( ) { }
8178
8279const kOnFinished = Symbol ( 'kOnFinished' ) ;
8380
@@ -154,7 +151,7 @@ function WritableState(options, stream, isDuplex) {
154151 this . bufferProcessing = false ;
155152
156153 // The callback that's passed to _write(chunk, cb).
157- this . onwrite = FunctionPrototypeBind ( onwrite , undefined , stream ) ;
154+ this . onwrite = onwrite . bind ( undefined , stream ) ;
158155
159156 // The callback that the user supplies to write(chunk, encoding, cb).
160157 this . writecb = null ;
@@ -273,6 +270,16 @@ function Writable(options) {
273270 } ) ;
274271}
275272
273+ ObjectDefineProperty ( Writable , SymbolHasInstance , {
274+ value : function ( object ) {
275+ if ( FunctionPrototypeSymbolHasInstance ( this , object ) ) return true ;
276+ if ( this !== Writable ) return false ;
277+
278+ return object && object . _writableState instanceof WritableState ;
279+ } ,
280+ } ) ;
281+
282+
276283// Otherwise people can pipe Writable streams, which is just wrong.
277284Writable . prototype . pipe = function ( ) {
278285 errorOrDestroy ( this , new ERR_STREAM_CANNOT_PIPE ( ) ) ;
@@ -372,7 +379,7 @@ function writeOrBuffer(stream, state, chunk, encoding, callback) {
372379 state . needDrain = true ;
373380
374381 if ( state . writing || state . corked || state . errored || ! state . constructed ) {
375- ArrayPrototypePush ( state . buffered , { chunk, encoding, callback } ) ;
382+ state . buffered . push ( { chunk, encoding, callback } ) ;
376383 if ( state . allBuffers && encoding !== 'buffer' ) {
377384 state . allBuffers = false ;
378385 }
@@ -855,7 +862,7 @@ Writable.prototype.destroy = function(err, cb) {
855862 process . nextTick ( errorBuffer , state ) ;
856863 }
857864
858- ReflectApply ( destroy , this , [ err , cb ] ) ;
865+ FunctionPrototypeCall ( destroy , this , err , cb ) ;
859866 return this ;
860867} ;
861868
0 commit comments