Skip to content

Commit

Permalink
stream: rollback duplex from new api
Browse files Browse the repository at this point in the history
  • Loading branch information
ErickWendel committed Jan 13, 2023
1 parent 0e07fc8 commit 47ca37d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Readable.ReadableState = ReadableState;
const EE = require('events');
const { Stream, prependListener } = require('internal/streams/legacy');
const { Buffer } = require('buffer');
const Duplex = require('internal/streams/duplex');

const {
addAbortSignal,
Expand Down Expand Up @@ -88,7 +87,7 @@ function ReadableState(options, stream, isDuplex) {
// 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;
isDuplex = stream instanceof Stream.Duplex;

// Object stream flag. Used to make read(n) ignore n and to
// make all the buffer merging and length checks go away.
Expand Down Expand Up @@ -190,7 +189,7 @@ function Readable(options) {

// Checking for a Stream.Duplex instance is faster here instead of inside
// the ReadableState constructor, at least with V8 6.5.
const isDuplex = this instanceof Duplex;
const isDuplex = this instanceof Stream.Duplex;

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

Expand Down
5 changes: 2 additions & 3 deletions lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Writable.WritableState = WritableState;

const EE = require('events');
const Stream = require('internal/streams/legacy').Stream;
const Duplex = require('internal/streams/duplex');
const { Buffer } = require('buffer');
const destroyImpl = require('internal/streams/destroy');

Expand Down Expand Up @@ -82,7 +81,7 @@ function WritableState(options, stream, isDuplex) {
// values for the readable and the writable sides of the duplex stream,
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
if (typeof isDuplex !== 'boolean')
isDuplex = stream instanceof Duplex;
isDuplex = stream instanceof Stream.Duplex;

// Object stream flag to indicate whether or not this stream
// contains buffers or objects.
Expand Down Expand Up @@ -229,7 +228,7 @@ function Writable(options) {

// Checking for a Stream.Duplex instance is faster here instead of inside
// the WritableState constructor, at least with V8 6.5.
const isDuplex = (this instanceof Duplex);
const isDuplex = (this instanceof Stream.Duplex);

if (!isDuplex && !FunctionPrototypeSymbolHasInstance(Writable, this))
return new Writable(options);
Expand Down

0 comments on commit 47ca37d

Please sign in to comment.