Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Circular dep that was not needed #441

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ require('inherits')(Duplex, Readable);

function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);
this.isDuplex = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can just add public properties like that... would at least need to be behind a symbol

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain any reason for that? I do not see a case where i can not simply place that i will refactor that but i do not see why we should not be able to place it after we made sure we are called with new we are sure that this is a instance and i am 100% sure that no novice developer will mess with that propertie

and if he does it is up to him it still has no down side for this

Readable.call(this, options);
Writable.call(this, options);
this.allowHalfOpen = true;
Expand Down
17 changes: 5 additions & 12 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
'use strict';

module.exports = Readable;
/*<replacement>*/

var Duplex;
/*</replacement>*/

Readable.ReadableState = ReadableState;
/*<replacement>*/
Expand Down Expand Up @@ -103,16 +99,14 @@ function prependListener(emitter, event, fn) {
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
}

function ReadableState(options, stream, isDuplex) {
Duplex = Duplex || require('./_stream_duplex');
function ReadableState(options,isDuplex) {
options = options || {}; // Duplex streams are both readable and writable, but share
// the same options object.
// However, some cases require setting options to different
// values for the readable and the writable sides of the duplex stream.
// These options can be provided separately as readableXXX and writableXXX.

if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
// make all the buffer merging and length checks go away
// make all the buffer merging and length checks go away

this.objectMode = !!options.objectMode;
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
Expand Down Expand Up @@ -167,12 +161,11 @@ function ReadableState(options, stream, isDuplex) {
}

function Readable(options) {
Duplex = Duplex || require('./_stream_duplex');

if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside
// the ReadableState constructor, at least with V8 6.5

var isDuplex = this instanceof Duplex;
this._readableState = new ReadableState(options, this, isDuplex); // legacy

this._readableState = new ReadableState(options, this.isDuplex); // legacy

this.readable = true;

Expand Down