Skip to content

Commit e432835

Browse files
committed
fixup
1 parent fbec373 commit e432835

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

lib/_stream_readable.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ function prependListener(emitter, event, fn) {
7272
emitter._events[event] = [fn, emitter._events[event]];
7373
}
7474

75-
function ReadableState(options, isDuplex) {
75+
function ReadableState(options, stream, isDuplex) {
76+
// Duplex streams are both readable and writable, but share
77+
// the same options object.
78+
// However, some cases require setting options to different
79+
// values for the readable and the writable sides of the duplex stream.
80+
// These options can be provided separately as readableXXX and writableXXX.
7681
if (typeof isDuplex !== 'boolean')
7782
isDuplex = stream instanceof Stream.Duplex;
7883

@@ -161,16 +166,11 @@ function Readable(options) {
161166
if (!(this instanceof Readable))
162167
return new Readable(options);
163168

164-
// Duplex streams are both readable and writable, but share
165-
// the same options object.
166-
// However, some cases require setting options to different
167-
// values for the readable and the writable sides of the duplex stream.
168-
// These options can be provided separately as readableXXX and writableXXX.
169169
// Checking for a Stream.Duplex instance is faster here instead of inside
170170
// the ReadableState constructor, at least with V8 6.5
171171
const isDuplex = this instanceof Stream.Duplex;
172172

173-
this._readableState = new ReadableState(options, isDuplex);
173+
this._readableState = new ReadableState(options, this, isDuplex);
174174

175175
// legacy
176176
this.readable = true;

lib/_stream_writable.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ Object.setPrototypeOf(Writable, Stream);
5858
function nop() {}
5959

6060
function WritableState(options, stream, isDuplex) {
61+
// Duplex streams are both readable and writable, but share
62+
// the same options object.
63+
// However, some cases require setting options to different
64+
// values for the readable and the writable sides of the duplex stream,
65+
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
6166
if (typeof isDuplex !== 'boolean')
6267
isDuplex = stream instanceof Stream.Duplex;
6368

@@ -210,12 +215,6 @@ function Writable(options) {
210215
// Node.js LazyTransform implementation, which has a non-trivial getter for
211216
// `_writableState` that would lead to infinite recursion.
212217

213-
214-
// Duplex streams are both readable and writable, but share
215-
// the same options object.
216-
// However, some cases require setting options to different
217-
// values for the readable and the writable sides of the duplex stream,
218-
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
219218
// Checking for a Stream.Duplex instance is faster here instead of inside
220219
// the WritableState constructor, at least with V8 6.5
221220
const isDuplex = (this instanceof Stream.Duplex);

0 commit comments

Comments
 (0)