Skip to content

Commit 7a19a7a

Browse files
committed
fixup: NodeStream
1 parent fb49c78 commit 7a19a7a

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

lib/internal/streams/add-abort-signal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ const validateAbortSignal = (signal, name) => {
1818
}
1919
};
2020

21-
function isStream(obj) {
21+
function isNodeStream(obj) {
2222
return !!(obj && typeof obj.pipe === 'function');
2323
}
2424

2525
module.exports.addAbortSignal = function addAbortSignal(signal, stream) {
2626
validateAbortSignal(signal, 'signal');
27-
if (!isStream(stream)) {
27+
if (!isNodeStream(stream)) {
2828
throw new ERR_INVALID_ARG_TYPE('stream', 'stream.Stream', stream);
2929
}
3030
return module.exports.addAbortSignalNoValidate(signal, stream);

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const {
2020
const {
2121
isClosed,
2222
isReadable,
23-
isReadableStream,
23+
isReadableNodeStream,
2424
isReadableFinished,
2525
isWritable,
26-
isWritableStream,
26+
isWritableNodeStream,
2727
isWritableFinished,
2828
willEmitClose: _willEmitClose,
2929
} = require('internal/streams/utils');
@@ -49,9 +49,9 @@ function eos(stream, options, callback) {
4949
callback = once(callback);
5050

5151
const readable = options.readable ||
52-
(options.readable !== false && isReadableStream(stream));
52+
(options.readable !== false && isReadableNodeStream(stream));
5353
const writable = options.writable ||
54-
(options.writable !== false && isWritableStream(stream));
54+
(options.writable !== false && isWritableNodeStream(stream));
5555

5656
const wState = stream._writableState;
5757
const rState = stream._readableState;
@@ -65,8 +65,8 @@ function eos(stream, options, callback) {
6565
// this generic check.
6666
let willEmitClose = (
6767
_willEmitClose(stream) &&
68-
isReadableStream(stream) === readable &&
69-
isWritableStream(stream) === writable
68+
isReadableNodeStream(stream) === readable &&
69+
isWritableNodeStream(stream) === writable
7070
);
7171

7272
let writableFinished = isWritableFinished(stream, false);

lib/internal/streams/pipeline.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const { validateCallback } = require('internal/validators');
2727

2828
const {
2929
isIterable,
30-
isReadableStream,
31-
isStream,
30+
isReadableNodeStream,
31+
isNodeStream,
3232
} = require('internal/streams/utils');
3333

3434
let PassThrough;
@@ -87,7 +87,7 @@ function popCallback(streams) {
8787
function makeAsyncIterable(val) {
8888
if (isIterable(val)) {
8989
return val;
90-
} else if (isReadableStream(val)) {
90+
} else if (isReadableNodeStream(val)) {
9191
// Legacy streams are not Iterable.
9292
return fromReadable(val);
9393
}
@@ -204,7 +204,7 @@ function pipeline(...streams) {
204204
const reading = i < streams.length - 1;
205205
const writing = i > 0;
206206

207-
if (isStream(stream)) {
207+
if (isNodeStream(stream)) {
208208
finishCount++;
209209
destroys.push(destroyer(stream, reading, writing, finish));
210210
}
@@ -216,7 +216,7 @@ function pipeline(...streams) {
216216
throw new ERR_INVALID_RETURN_VALUE(
217217
'Iterable, AsyncIterable or Stream', 'source', ret);
218218
}
219-
} else if (isIterable(stream) || isReadableStream(stream)) {
219+
} else if (isIterable(stream) || isReadableNodeStream(stream)) {
220220
ret = stream;
221221
} else {
222222
throw new ERR_INVALID_ARG_TYPE(
@@ -271,8 +271,8 @@ function pipeline(...streams) {
271271
finishCount++;
272272
destroys.push(destroyer(ret, false, true, finish));
273273
}
274-
} else if (isStream(stream)) {
275-
if (isReadableStream(ret)) {
274+
} else if (isNodeStream(stream)) {
275+
if (isReadableNodeStream(ret)) {
276276
ret.pipe(stream);
277277

278278
// Compat. Before node v10.12.0 stdio used to throw an error so

lib/internal/streams/utils.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const {
88

99
const kDestroyed = Symbol('kDestroyed');
1010

11-
function isReadableStream(obj) {
11+
function isReadableNodeStream(obj) {
1212
return !!(
1313
obj &&
1414
typeof obj.pipe === 'function' &&
@@ -18,7 +18,7 @@ function isReadableStream(obj) {
1818
);
1919
}
2020

21-
function isWritableStream(obj) {
21+
function isWritableNodeStream(obj) {
2222
return !!(
2323
obj &&
2424
typeof obj.write === 'function' &&
@@ -27,8 +27,8 @@ function isWritableStream(obj) {
2727
);
2828
}
2929

30-
function isStream(obj) {
31-
return isReadableStream(obj) || isWritableStream(obj);
30+
function isNodeStream(obj) {
31+
return isReadableNodeStream(obj) || isWritableNodeStream(obj);
3232
}
3333

3434
function isIterable(obj, isAsync) {
@@ -40,7 +40,7 @@ function isIterable(obj, isAsync) {
4040
}
4141

4242
function isDestroyed(stream) {
43-
if (!isStream(stream)) return null;
43+
if (!isNodeStream(stream)) return null;
4444
const wState = stream._writableState;
4545
const rState = stream._readableState;
4646
const state = wState || rState;
@@ -49,7 +49,7 @@ function isDestroyed(stream) {
4949

5050
// Have been end():d.
5151
function isWritableEnded(stream) {
52-
if (!isWritableStream(stream)) return null;
52+
if (!isWritableNodeStream(stream)) return null;
5353
if (stream.writableEnded === true) return true;
5454
const wState = stream._writableState;
5555
if (wState?.errored) return false;
@@ -59,7 +59,7 @@ function isWritableEnded(stream) {
5959

6060
// Have emitted 'finish'.
6161
function isWritableFinished(stream, strict) {
62-
if (!isWritableStream(stream)) return null;
62+
if (!isWritableNodeStream(stream)) return null;
6363
if (stream.writableFinished === true) return true;
6464
const wState = stream._writableState;
6565
if (wState?.errored) return false;
@@ -72,7 +72,7 @@ function isWritableFinished(stream, strict) {
7272

7373
// Have been push(null):d.
7474
function isReadableEnded(stream) {
75-
if (!isReadableStream(stream)) return null;
75+
if (!isReadableNodeStream(stream)) return null;
7676
if (stream.readableEnded === true) return true;
7777
const rState = stream._readableState;
7878
if (!rState || rState.errored) return false;
@@ -82,7 +82,7 @@ function isReadableEnded(stream) {
8282

8383
// Have emitted 'end'.
8484
function isReadableFinished(stream, strict) {
85-
if (!isReadableStream(stream)) return null;
85+
if (!isReadableNodeStream(stream)) return null;
8686
const rState = stream._readableState;
8787
if (rState?.errored) return false;
8888
if (typeof rState?.endEmitted !== 'boolean') return null;
@@ -93,21 +93,21 @@ function isReadableFinished(stream, strict) {
9393
}
9494

9595
function isReadable(stream) {
96-
const r = isReadableStream(stream);
96+
const r = isReadableNodeStream(stream);
9797
if (r === null || typeof stream.readable !== 'boolean') return null;
9898
if (isDestroyed(stream)) return false;
9999
return r && stream.readable && !isReadableFinished(stream);
100100
}
101101

102102
function isWritable(stream) {
103-
const r = isWritableStream(stream);
103+
const r = isWritableNodeStream(stream);
104104
if (r === null || typeof stream.writable !== 'boolean') return null;
105105
if (isDestroyed(stream)) return false;
106106
return r && stream.writable && !isWritableEnded(stream);
107107
}
108108

109109
function isFinished(stream, opts) {
110-
if (!isStream(stream)) {
110+
if (!isNodeStream(stream)) {
111111
return null;
112112
}
113113

@@ -127,7 +127,7 @@ function isFinished(stream, opts) {
127127
}
128128

129129
function isClosed(stream) {
130-
if (!isStream(stream)) {
130+
if (!isNodeStream(stream)) {
131131
return null;
132132
}
133133

@@ -173,7 +173,7 @@ function isServerRequest(stream) {
173173
}
174174

175175
function willEmitClose(stream) {
176-
if (!isStream(stream)) return null;
176+
if (!isNodeStream(stream)) return null;
177177

178178
const wState = stream._writableState;
179179
const rState = stream._readableState;
@@ -194,12 +194,12 @@ module.exports = {
194194
isFinished,
195195
isIterable,
196196
isReadable,
197-
isReadableStream,
197+
isReadableNodeStream,
198198
isReadableEnded,
199199
isReadableFinished,
200-
isStream,
200+
isNodeStream,
201201
isWritable,
202-
isWritableStream,
202+
isWritableNodeStream,
203203
isWritableEnded,
204204
isWritableFinished,
205205
isServerRequest,

lib/stream/promises.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const {
1515

1616
const {
1717
isIterable,
18-
isStream,
18+
isNodeStream,
1919
} = require('internal/streams/utils');
2020

2121
const pl = require('internal/streams/pipeline');
@@ -26,7 +26,7 @@ function pipeline(...streams) {
2626
let signal;
2727
const lastArg = streams[streams.length - 1];
2828
if (lastArg && typeof lastArg === 'object' &&
29-
!isStream(lastArg) && !isIterable(lastArg)) {
29+
!isNodeStream(lastArg) && !isIterable(lastArg)) {
3030
const options = ArrayPrototypePop(streams);
3131
signal = options.signal;
3232
validateAbortSignal(signal, 'options.signal');

0 commit comments

Comments
 (0)