File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -23,11 +23,15 @@ function pipeline(...streams) {
23
23
signal = options . signal ;
24
24
}
25
25
26
- pl ( streams , ( err , value ) => {
26
+ const stream = pl ( streams , ( err , value ) => {
27
27
if ( err ) {
28
28
reject ( err ) ;
29
- } else {
29
+ } else if ( value !== undefined ) {
30
30
resolve ( value ) ;
31
+ } else if ( stream . readable ) {
32
+ resolve ( stream ) ;
33
+ } else {
34
+ resolve ( ) ;
31
35
}
32
36
} , { signal } ) ;
33
37
} ) ;
Original file line number Diff line number Diff line change @@ -1447,3 +1447,29 @@ const tsp = require('timers/promises');
1447
1447
assert . strictEqual ( text , 'Hello World!' ) ;
1448
1448
} ) ) ;
1449
1449
}
1450
+
1451
+ {
1452
+ const pipelinePromise = promisify ( pipeline ) ;
1453
+
1454
+ async function run ( ) {
1455
+ const read = new Readable ( {
1456
+ read ( ) { }
1457
+ } ) ;
1458
+
1459
+ const duplex = new PassThrough ( ) ;
1460
+
1461
+ read . push ( 'data' ) ;
1462
+ read . push ( null ) ;
1463
+
1464
+ const stream = await pipelinePromise ( read , duplex ) ;
1465
+
1466
+ let ret = ''
1467
+ for await ( const x of stream ) {
1468
+ ret += x ;
1469
+ }
1470
+
1471
+ assert . strictEqual ( ret , 'data' ) ;
1472
+ }
1473
+
1474
+ run ( ) ;
1475
+ }
You can’t perform that action at this time.
0 commit comments