@@ -420,3 +420,77 @@ const assert = require('assert');
420
420
assert . strictEqual ( buf , 'HELLOWORLD' ) ;
421
421
} ) ) ;
422
422
}
423
+
424
+ {
425
+ // In the new stream than should use the writeable of the first stream and readable of the last stream
426
+ // #46829
427
+ ( async ( ) => {
428
+ const newStream = compose (
429
+ new PassThrough ( {
430
+ // reading FROM you in object mode or not
431
+ readableObjectMode : false ,
432
+
433
+ // writing TO you in object mode or not
434
+ writableObjectMode : false ,
435
+ } ) ,
436
+ new Transform ( {
437
+ // reading FROM you in object mode or not
438
+ readableObjectMode : true ,
439
+
440
+ // writing TO you in object mode or not
441
+ writableObjectMode : false ,
442
+ transform : ( chunk , encoding , callback ) => {
443
+ callback ( null , {
444
+ value : chunk . toString ( )
445
+ } ) ;
446
+ }
447
+ } )
448
+ ) ;
449
+
450
+ assert . strictEqual ( newStream . writableObjectMode , false ) ;
451
+ assert . strictEqual ( newStream . readableObjectMode , true ) ;
452
+
453
+ newStream . write ( 'Steve Rogers' ) ;
454
+ newStream . write ( 'On your left' ) ;
455
+
456
+ newStream . end ( ) ;
457
+
458
+ assert . deepStrictEqual ( await newStream . toArray ( ) , [ { value : 'Steve Rogers' } , { value : 'On your left' } ] ) ;
459
+ } ) ( ) . then ( common . mustCall ( ) ) ;
460
+ }
461
+
462
+ {
463
+ // In the new stream than should use the writeable of the first stream and readable of the last stream
464
+ // #46829
465
+ ( async ( ) => {
466
+ const newStream = compose (
467
+ new PassThrough ( {
468
+ // reading FROM you in object mode or not
469
+ readableObjectMode : true ,
470
+
471
+ // writing TO you in object mode or not
472
+ writableObjectMode : true ,
473
+ } ) ,
474
+ new Transform ( {
475
+ // reading FROM you in object mode or not
476
+ readableObjectMode : false ,
477
+
478
+ // writing TO you in object mode or not
479
+ writableObjectMode : true ,
480
+ transform : ( chunk , encoding , callback ) => {
481
+ callback ( null , chunk . value ) ;
482
+ }
483
+ } )
484
+ ) ;
485
+
486
+ assert . strictEqual ( newStream . writableObjectMode , true ) ;
487
+ assert . strictEqual ( newStream . readableObjectMode , false ) ;
488
+
489
+ newStream . write ( { value : 'Steve Rogers' } ) ;
490
+ newStream . write ( { value : 'On your left' } ) ;
491
+
492
+ newStream . end ( ) ;
493
+
494
+ assert . deepStrictEqual ( await newStream . toArray ( ) , [ Buffer . from ( 'Steve RogersOn your left' ) ] ) ;
495
+ } ) ( ) . then ( common . mustCall ( ) ) ;
496
+ }
0 commit comments