@@ -59,9 +59,11 @@ function nop() {}
5959
6060const kFlush = Symbol ( 'kFlush' ) ;
6161class WritableState extends WritableStateBase {
62- constructor ( options , stream , isDuplex ) {
62+ constructor ( options , stream ) {
6363 super ( options ) ;
6464
65+ let isDuplex = options . isDuplex ;
66+
6567 // Duplex streams are both readable and writable, but share
6668 // the same options object.
6769 // However, some cases require setting options to different
@@ -207,6 +209,7 @@ function Writable(options) {
207209
208210 WritableBase . call ( this , {
209211 ...options ,
212+ isDuplex,
210213 start : function ( ) {
211214 const state = this . _writableState ;
212215 if ( ! state . writing ) {
@@ -215,7 +218,8 @@ function Writable(options) {
215218 finishMaybe ( this , state ) ;
216219 } ,
217220 write : writeOrBuffer ,
218- flush : function ( state , cb ) {
221+ flush : function ( cb ) {
222+ const state = this . _writableState ;
219223 // .end() fully uncorks.
220224 if ( state . corked ) {
221225 state . corked = 1 ;
@@ -226,7 +230,7 @@ function Writable(options) {
226230
227231 finishMaybe ( this , state ) ;
228232 }
229- } , isDuplex , WritableState ) ;
233+ } , WritableState ) ;
230234}
231235Writable . WritableState = WritableState ;
232236Writable . prototype = ObjectCreate ( WritableBase . prototype ) ;
@@ -249,7 +253,9 @@ Writable.prototype.uncork = function() {
249253// If we're already writing something, then just put this
250254// in the queue, and wait our turn. Otherwise, call _write
251255// If we return false, then we need a drain event, so set that flag.
252- function writeOrBuffer ( state , chunk , encoding , callback ) {
256+ function writeOrBuffer ( chunk , encoding , callback ) {
257+ const state = this . _writableState ;
258+
253259 if ( typeof callback !== 'function' )
254260 callback = nop ;
255261
0 commit comments