@@ -47,12 +47,6 @@ function CorkedRequest(state) {
47
47
}
48
48
/* </replacement> */
49
49
50
- /*<replacement>*/
51
-
52
-
53
- var Duplex ;
54
- /*</replacement>*/
55
-
56
50
Writable . WritableState = WritableState ;
57
51
/*<replacement>*/
58
52
@@ -80,6 +74,7 @@ function _isUint8Array(obj) {
80
74
}
81
75
82
76
var destroyImpl = require ( './internal/streams/destroy' ) ;
77
+ const { exception } = require ( 'console' ) ;
83
78
84
79
var _require = require ( './internal/streams/state' ) ,
85
80
getHighWaterMark = _require . getHighWaterMark ;
@@ -101,16 +96,12 @@ require('inherits')(Writable, Stream);
101
96
function nop ( ) { }
102
97
103
98
function WritableState ( options , stream , isDuplex ) {
104
- Duplex = Duplex || require ( './_stream_duplex' ) ;
105
99
options = options || { } ; // Duplex streams are both readable and writable, but share
106
100
// the same options object.
107
101
// However, some cases require setting options to different
108
102
// values for the readable and the writable sides of the duplex stream,
109
103
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
110
104
111
- if ( typeof isDuplex !== 'boolean' ) isDuplex = stream instanceof Duplex ; // object stream flag to indicate whether or not this stream
112
- // contains buffers or objects.
113
-
114
105
this . objectMode = ! ! options . objectMode ;
115
106
if ( isDuplex ) this . objectMode = this . objectMode || ! ! options . writableObjectMode ; // the point at which write() starts returning false
116
107
// Note: 0 is a valid value, means that we always return false if
@@ -226,8 +217,8 @@ if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.protot
226
217
} ;
227
218
}
228
219
229
- function Writable ( options ) {
230
- Duplex = Duplex || require ( './_stream_duplex' ) ; // Writable ctor is applied to Duplexes, too.
220
+ function Writable ( options , isDuplex ) {
221
+ // Writable ctor is applied to Duplexes, too.
231
222
// `realHasInstance` is necessary because using plain `instanceof`
232
223
// would return false, as no `_writableState` property is attached.
233
224
// Trying to use the custom `instanceof` for Writable here will also break the
@@ -236,7 +227,9 @@ function Writable(options) {
236
227
// Checking for a Stream.Duplex instance is faster here instead of inside
237
228
// the WritableState constructor, at least with V8 6.5
238
229
239
- var isDuplex = this instanceof Duplex ;
230
+ if ( typeof isDuplex !== 'boolean' ) isDuplex = false ; // object stream flag to indicate whether or not this stream
231
+ // contains buffers or objects.
232
+
240
233
if ( ! isDuplex && ! realHasInstance . call ( Writable , this ) ) return new Writable ( options ) ;
241
234
this . _writableState = new WritableState ( options , this , isDuplex ) ; // legacy.
242
235
0 commit comments