Skip to content

Commit

Permalink
stream: allow empty string as source of pipeline
Browse files Browse the repository at this point in the history
Fixes: #38721

PR-URL: #38723
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
Ayase-252 authored and danielleadams committed May 31, 2021
1 parent 496f7ea commit 4131f94
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/streams/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function isStream(obj) {
}

function isIterable(obj, isAsync) {
if (!obj) return false;
if (obj == null) return false;
if (isAsync === true) return typeof obj[SymbolAsyncIterator] === 'function';
if (isAsync === false) return typeof obj[SymbolIterator] === 'function';
return typeof obj[SymbolAsyncIterator] === 'function' ||
Expand Down
18 changes: 18 additions & 0 deletions test/parallel/test-stream-pipeline-with-empty-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const common = require('../common');
const {
pipeline,
PassThrough
} = require('stream');


async function runTest() {
await pipeline(
'',
new PassThrough({ objectMode: true }),
common.mustCall(() => { })
);
}

runTest().then(common.mustCall(() => {}));

0 comments on commit 4131f94

Please sign in to comment.