Skip to content

Commit c5da09b

Browse files
committed
stream: inline name arg creation
1 parent ab68aad commit c5da09b

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

lib/internal/streams/pipeline.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ async function pumpToWeb(readable, writable, finish, { end }) {
181181
}
182182
}
183183

184-
function getPipelineArgName(i, len) {
185-
if (i === 0) return 'source';
186-
if (i === len - 1) return 'destination';
187-
return `transform[${i - 1}]`;
188-
}
189-
190184
function isValidPipelineSource(stream) {
191185
return (
192186
isIterable(stream) ||
@@ -218,12 +212,10 @@ function validatePipelineStream(stream, i, len) {
218212
return;
219213
}
220214

221-
const name = getPipelineArgName(i, len);
222-
223215
if (i === 0) {
224216
if (!isValidPipelineSource(stream)) {
225217
throw new ERR_INVALID_ARG_TYPE(
226-
name,
218+
'source',
227219
['Readable', 'Iterable', 'AsyncIterable', 'ReadableStream', 'TransformStream'],
228220
stream,
229221
);
@@ -234,7 +226,7 @@ function validatePipelineStream(stream, i, len) {
234226
if (i === len - 1) {
235227
if (!isValidPipelineDestination(stream)) {
236228
throw new ERR_INVALID_ARG_TYPE(
237-
name,
229+
'destination',
238230
['Writable', 'WritableStream', 'TransformStream'],
239231
stream,
240232
);
@@ -244,7 +236,7 @@ function validatePipelineStream(stream, i, len) {
244236

245237
if (!isValidPipelineTransform(stream)) {
246238
throw new ERR_INVALID_ARG_TYPE(
247-
name,
239+
`transform[${i - 1}]`,
248240
['Duplex', 'Transform', 'TransformStream'],
249241
stream,
250242
);

0 commit comments

Comments
 (0)