Skip to content

Commit

Permalink
Revert "fixup: remove eos webstream changes"
Browse files Browse the repository at this point in the history
This reverts commit ca32e5a.
  • Loading branch information
ronag committed Jul 30, 2021
1 parent ca32e5a commit 6d06b1c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ const {
validateObject,
} = require('internal/validators');

const {
isBrandCheck,
} = require('internal/webstreams/util');

const isReadableStream =
isBrandCheck('ReadableStream');
const isWritableStream =
isBrandCheck('WritableStream');

const {
isClosed,
isReadable,
Expand All @@ -25,9 +34,12 @@ const {
isWritable,
isWritableNodeStream,
isWritableFinished,
isNodeStream,
willEmitClose: _willEmitClose,
} = require('internal/streams/utils');

let Duplex;

function isRequest(stream) {
return stream.setHeader && typeof stream.abort === 'function';
}
Expand All @@ -53,6 +65,17 @@ function eos(stream, options, callback) {
const writable = options.writable ||
(options.writable !== false && isWritableNodeStream(stream));

if (isNodeStream(stream)) {
// Do nothing...
} if (isReadableStream(stream) || isWritableStream(stream)) {
if (!Duplex) {
Duplex = require('./duplex');
}
stream = Duplex.from(stream);
} else {
// TODO: Throw INVALID_ARG_TYPE.
}

const wState = stream._writableState;
const rState = stream._readableState;

Expand Down

0 comments on commit 6d06b1c

Please sign in to comment.