@@ -258,10 +258,12 @@ module Writable = {
258258 "writableObjectMode" ;
259259 };
260260 include Impl ;
261+
261262 type nonrec t (' w ) = subtype(writable('w));
262263 type objStream (' w ) = subtype([ writable('w) | objectMode]);
263- type nonrec supertype (' w , ' ty ) = subtype([< writable('w)] as 'ty);
264+ type supertype (' w , ' ty ) = subtype([< writable('w)] as 'ty);
264265 type nonrec subtype (' w , ' ty ) = subtype([> writable('w)] as 'ty);
266+
265267 type makeOptions (' w );
266268 [@ bs . obj ]
267269 external makeOptions :
@@ -530,9 +532,10 @@ module Readable = {
530532 external unshift : (subtype ([ > readable (' r )] ), ' r ) => unit = "unshift" ;
531533 };
532534 include Impl ;
535+
533536 type nonrec t (' r ) = subtype(readable('r));
534537 type objStream (' r ) = subtype([ readable('r) | objectMode]);
535- type nonrec supertype (' r , ' ty ) = subtype([< readable('r)] as 'ty);
538+ type supertype (' r , ' ty ) = subtype([< readable('r)] as 'ty);
536539 type nonrec subtype (' r , ' ty ) = subtype([> readable('r)] as 'ty);
537540
538541 type makeOptions (' r );
@@ -595,9 +598,12 @@ module Duplex = {
595598 include Events ;
596599 };
597600 include Impl ;
598- type nonrec t (' w , ' r ) = subtype(duplex('w, 'r));
599- type nonrec supertype (' w , ' r , ' ty ) = subtype([< duplex('w, 'r)] as 'ty);
601+
602+ type t (' w , ' r ) = subtype(duplex('w, 'r));
603+ type supertype (' w , ' r , ' ty ) = subtype([< duplex('w, 'r)] as 'ty);
600604 type nonrec subtype (' w , ' r , ' ty ) = subtype([> duplex('w, 'r)] as 'ty);
605+ type objStream (' w , ' r ) = subtype('w, 'r, [ duplex('w, 'r) | objectMode]);
606+
601607 type makeOptions (' w , ' r );
602608 [@ bs . obj ]
603609 external makeOptions :
@@ -640,6 +646,49 @@ module Duplex = {
640646 [@ bs . module "stream" ] [@ bs . new ]
641647 external make : makeOptions (Buffer . t , Buffer . t ) => t (Buffer . t , Buffer . t ) =
642648 "Duplex" ;
649+
650+ type makeOptionsObjMode (' w , ' r );
651+ [@ bs . obj ]
652+ external makeOptionsObjMode :
653+ (
654+ ~objectMode : [@ bs . as { json | true| json } ] _ ,
655+ ~allowHalfOpen : bool =?,
656+ ~highWaterMark : int =?,
657+ ~emitClose : bool =?,
658+ ~autoDestroy : bool =?,
659+ ~destroy : [@ bs . this ] (
660+ (
661+ t (' w , ' r ),
662+ Js . nullable (Js . Exn . t ),
663+ (~err : option (Js . Exn . t )) => unit
664+ ) =>
665+ unit
666+ )
667+ =?,
668+ ~final : [@ bs . this ] (
669+ (t (' w , ' r ), ' w , (~err : option (Js . Exn . t )) => unit ) => unit
670+ )
671+ =?,
672+ ~writev : [@ bs . this ] (
673+ (
674+ t (' w , ' r ),
675+ array (chunk (' w )),
676+ (~err : option (Js . Exn . t )) => unit
677+ ) =>
678+ unit
679+ )
680+ =?,
681+ ~read : [@ bs . this ] ((t (' w , ' r ), Js . nullable (int )) => unit ),
682+ ~write : [@ bs . this ] (
683+ (t (' w , ' r ), ' w , (~err : option (Js . Exn . t )) => unit ) => unit
684+ ),
685+ unit
686+ ) =>
687+ makeOptions (' w , ' r );
688+
689+ [@ bs . module "stream" ] [@ bs . new ]
690+ external makeObjMode : makeOptionsObjMode (' w , ' r ) => t (' w , ' r ) =
691+ "Duplex" ;
643692};
644693
645694module Transform = {
@@ -652,9 +701,9 @@ module Transform = {
652701 include Events ;
653702 };
654703 include Impl ;
655- type nonrec t (' w , ' r ) = subtype(transform('w, 'r));
704+ type t (' w , ' r ) = subtype(transform('w, 'r));
656705 type objStream (' w , ' r ) = subtype([ transform('w, 'r) | objectMode]);
657- type nonrec supertype (' w , ' r , ' ty ) = subtype([< transform('w, 'r)] as 'ty);
706+ type supertype (' w , ' r , ' ty ) = subtype([< transform('w, 'r)] as 'ty);
658707 type nonrec subtype (' w , ' r , ' ty ) = subtype([> transform('w, 'r)] as 'ty);
659708 type makeOptions (' w , ' r );
660709 [@ bs . obj ]
@@ -732,8 +781,8 @@ module PassThrough = {
732781 include Events ;
733782 };
734783 include Impl ;
735- type nonrec t (' w , ' r ) = subtype(passThrough('w, 'r));
736- type nonrec supertype (' w , ' r , ' ty ) = subtype([< passThrough('w, 'r)] as 'ty);
784+ type t (' w , ' r ) = subtype(passThrough('w, 'r));
785+ type supertype (' w , ' r , ' ty ) = subtype([< passThrough('w, 'r)] as 'ty);
737786 type nonrec subtype (' w , ' r , ' ty ) = subtype([> passThrough('w, 'r)] as 'ty);
738787 [@ bs . module "stream" ] [@ bs . new ]
739788 external make : unit => t (Buffer . t , Buffer . t ) = "PassThrough" ;
0 commit comments