File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change 1- import { Duplex , finished } from 'readable-stream' ;
1+ import { Duplex , finished , type DuplexOptions } from 'readable-stream' ;
22import once from 'once' ;
33import { Substream } from './Substream' ;
44
@@ -12,15 +12,15 @@ interface Chunk {
1212export class ObjectMultiplex extends Duplex {
1313 private _substreams : Record < string , Substream | typeof IGNORE_SUBSTREAM > ;
1414
15- constructor ( opts : Record < string , unknown > = { } ) {
15+ constructor ( opts : DuplexOptions = { } ) {
1616 super ( {
17- ...opts ,
1817 objectMode : true ,
18+ ...opts ,
1919 } ) ;
2020 this . _substreams = { } ;
2121 }
2222
23- createStream ( name : string ) : Substream {
23+ createStream ( name : string , opts : DuplexOptions = { } ) : Substream {
2424 // guard stream against destroyed already
2525 if ( this . destroyed ) {
2626 throw new Error (
@@ -47,7 +47,11 @@ export class ObjectMultiplex extends Duplex {
4747 }
4848
4949 // create substream
50- const substream = new Substream ( { parent : this , name } ) ;
50+ const substream = new Substream ( {
51+ name,
52+ parent : this ,
53+ ...opts ,
54+ } ) ;
5155 this . _substreams [ name ] = substream ;
5256
5357 // listen for parent stream to end
Original file line number Diff line number Diff line change 1- import { Duplex } from 'readable-stream' ;
1+ import { Duplex , type DuplexOptions } from 'readable-stream' ;
22import { ObjectMultiplex } from './ObjectMultiplex' ;
33
4- export interface SubstreamOptions {
4+ export interface SubstreamOptions extends DuplexOptions {
55 parent : ObjectMultiplex ;
66 name : string ;
77}
@@ -11,8 +11,11 @@ export class Substream extends Duplex {
1111
1212 private readonly _name : string ;
1313
14- constructor ( { parent, name } : SubstreamOptions ) {
15- super ( { objectMode : true } ) ;
14+ constructor ( { parent, name, ...streamOptions } : SubstreamOptions ) {
15+ super ( {
16+ objectMode : true ,
17+ ...streamOptions ,
18+ } ) ;
1619 this . _parent = parent ;
1720 this . _name = name ;
1821 }
You can’t perform that action at this time.
0 commit comments