@@ -503,14 +503,16 @@ function _write(stream, chunk, encoding, cb) {
503503 return writeOrBuffer ( stream , state , chunk , encoding , cb ) ;
504504}
505505
506- Writable . prototype . write = function ( chunk , encoding , cb ) {
506+ function write ( chunk , encoding , cb ) {
507507 if ( encoding != null && typeof encoding === 'function' ) {
508508 cb = encoding ;
509509 encoding = null ;
510510 }
511511
512512 return _write ( this , chunk , encoding , cb ) === true ;
513- } ;
513+ }
514+
515+ Writable . prototype . write = write ;
514516
515517Writable . prototype . cork = function ( ) {
516518 const state = this . _writableState ;
@@ -588,9 +590,9 @@ function writeOrBuffer(stream, state, chunk, encoding, callback) {
588590
589591// Steady state of a flowing pipe into a byte-mode Writable: one Buffer,
590592// nothing queued, no user write callback, and write() not replaced. pipe()
591- // calls dest.write(), so a write() set on the instance or a subclass has to
592- // run. Returns undefined when the caller must use write() instead. Otherwise
593- // the same boolean as write().
593+ // calls dest.write(), so a write() set on the instance, a subclass or the
594+ // prototype has to run. Returns undefined when the caller must use write()
595+ // instead. Otherwise the same boolean as write().
594596const kWriteFlowBlock = kObjectMode | kDestroyed | kErrored | kSync |
595597 kEnding | kFinished | kWriting | kCorked | kBuffered | kEnded |
596598 kNeedDrain | kWriteCb | kExpectWriteCb | kBufferProcessing |
@@ -599,7 +601,7 @@ const kWriteFlowBlock = kObjectMode | kDestroyed | kErrored | kSync |
599601function writeKnownBuffer ( stream , chunk ) {
600602 const state = stream . _writableState ;
601603 if ( state == null || state . length !== 0 || ! ( chunk instanceof Buffer ) ||
602- stream . write !== Writable . prototype . write )
604+ stream . write !== write )
603605 return undefined ;
604606
605607 const bits = state [ kState ] ;
0 commit comments