Skip to content

Commit 6d06b1c

Browse files
committed
Revert "fixup: remove eos webstream changes"
This reverts commit ca32e5a.
1 parent ca32e5a commit 6d06b1c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/internal/streams/end-of-stream.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ const {
1717
validateObject,
1818
} = require('internal/validators');
1919

20+
const {
21+
isBrandCheck,
22+
} = require('internal/webstreams/util');
23+
24+
const isReadableStream =
25+
isBrandCheck('ReadableStream');
26+
const isWritableStream =
27+
isBrandCheck('WritableStream');
28+
2029
const {
2130
isClosed,
2231
isReadable,
@@ -25,9 +34,12 @@ const {
2534
isWritable,
2635
isWritableNodeStream,
2736
isWritableFinished,
37+
isNodeStream,
2838
willEmitClose: _willEmitClose,
2939
} = require('internal/streams/utils');
3040

41+
let Duplex;
42+
3143
function isRequest(stream) {
3244
return stream.setHeader && typeof stream.abort === 'function';
3345
}
@@ -53,6 +65,17 @@ function eos(stream, options, callback) {
5365
const writable = options.writable ||
5466
(options.writable !== false && isWritableNodeStream(stream));
5567

68+
if (isNodeStream(stream)) {
69+
// Do nothing...
70+
} if (isReadableStream(stream) || isWritableStream(stream)) {
71+
if (!Duplex) {
72+
Duplex = require('./duplex');
73+
}
74+
stream = Duplex.from(stream);
75+
} else {
76+
// TODO: Throw INVALID_ARG_TYPE.
77+
}
78+
5679
const wState = stream._writableState;
5780
const rState = stream._readableState;
5881

0 commit comments

Comments
 (0)