File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,11 +23,15 @@ function pipeline(...streams) {
2323 signal = options . signal ;
2424 }
2525
26- pl ( streams , ( err , value ) => {
26+ const stream = pl ( streams , ( err , value ) => {
2727 if ( err ) {
2828 reject ( err ) ;
29- } else {
29+ } else if ( value !== undefined ) {
3030 resolve ( value ) ;
31+ } else if ( stream . readable ) {
32+ resolve ( stream ) ;
33+ } else {
34+ resolve ( ) ;
3135 }
3236 } , { signal } ) ;
3337 } ) ;
Original file line number Diff line number Diff line change @@ -1406,3 +1406,29 @@ const tsp = require('timers/promises');
14061406 } ) ) ;
14071407 ac . abort ( ) ;
14081408}
1409+
1410+ {
1411+ const pipelinePromise = promisify ( pipeline ) ;
1412+
1413+ async function run ( ) {
1414+ const read = new Readable ( {
1415+ read ( ) { }
1416+ } ) ;
1417+
1418+ const duplex = new PassThrough ( ) ;
1419+
1420+ read . push ( 'data' ) ;
1421+ read . push ( null ) ;
1422+
1423+ const stream = await pipelinePromise ( read , duplex ) ;
1424+
1425+ let ret = ''
1426+ for await ( const x of stream ) {
1427+ ret += x ;
1428+ }
1429+
1430+ assert . strictEqual ( ret , 'data' ) ;
1431+ }
1432+
1433+ run ( ) ;
1434+ }
You can’t perform that action at this time.
0 commit comments