@@ -706,57 +706,64 @@ Zlib.prototype.params = function params(level, strategy, callback) {
706
706
// generic zlib
707
707
// minimal 2-byte header
708
708
function Deflate ( opts ) {
709
- if ( ! ( this instanceof Deflate ) )
709
+ if ( ! new . target ) {
710
710
return new Deflate ( opts ) ;
711
+ }
711
712
ReflectApply ( Zlib , this , [ opts , DEFLATE ] ) ;
712
713
}
713
714
ObjectSetPrototypeOf ( Deflate . prototype , Zlib . prototype ) ;
714
715
ObjectSetPrototypeOf ( Deflate , Zlib ) ;
715
716
716
717
function Inflate ( opts ) {
717
- if ( ! ( this instanceof Inflate ) )
718
+ if ( ! new . target ) {
718
719
return new Inflate ( opts ) ;
720
+ }
719
721
ReflectApply ( Zlib , this , [ opts , INFLATE ] ) ;
720
722
}
721
723
ObjectSetPrototypeOf ( Inflate . prototype , Zlib . prototype ) ;
722
724
ObjectSetPrototypeOf ( Inflate , Zlib ) ;
723
725
724
726
function Gzip ( opts ) {
725
- if ( ! ( this instanceof Gzip ) )
727
+ if ( ! new . target ) {
726
728
return new Gzip ( opts ) ;
729
+ }
727
730
ReflectApply ( Zlib , this , [ opts , GZIP ] ) ;
728
731
}
729
732
ObjectSetPrototypeOf ( Gzip . prototype , Zlib . prototype ) ;
730
733
ObjectSetPrototypeOf ( Gzip , Zlib ) ;
731
734
732
735
function Gunzip ( opts ) {
733
- if ( ! ( this instanceof Gunzip ) )
736
+ if ( ! new . target ) {
734
737
return new Gunzip ( opts ) ;
738
+ }
735
739
ReflectApply ( Zlib , this , [ opts , GUNZIP ] ) ;
736
740
}
737
741
ObjectSetPrototypeOf ( Gunzip . prototype , Zlib . prototype ) ;
738
742
ObjectSetPrototypeOf ( Gunzip , Zlib ) ;
739
743
740
744
function DeflateRaw ( opts ) {
741
- if ( opts && opts . windowBits === 8 ) opts . windowBits = 9 ;
742
- if ( ! ( this instanceof DeflateRaw ) )
745
+ if ( opts ? .windowBits === 8 ) opts . windowBits = 9 ;
746
+ if ( ! new . target ) {
743
747
return new DeflateRaw ( opts ) ;
748
+ }
744
749
ReflectApply ( Zlib , this , [ opts , DEFLATERAW ] ) ;
745
750
}
746
751
ObjectSetPrototypeOf ( DeflateRaw . prototype , Zlib . prototype ) ;
747
752
ObjectSetPrototypeOf ( DeflateRaw , Zlib ) ;
748
753
749
754
function InflateRaw ( opts ) {
750
- if ( ! ( this instanceof InflateRaw ) )
755
+ if ( ! new . target ) {
751
756
return new InflateRaw ( opts ) ;
757
+ }
752
758
ReflectApply ( Zlib , this , [ opts , INFLATERAW ] ) ;
753
759
}
754
760
ObjectSetPrototypeOf ( InflateRaw . prototype , Zlib . prototype ) ;
755
761
ObjectSetPrototypeOf ( InflateRaw , Zlib ) ;
756
762
757
763
function Unzip ( opts ) {
758
- if ( ! ( this instanceof Unzip ) )
764
+ if ( ! new . target ) {
759
765
return new Unzip ( opts ) ;
766
+ }
760
767
ReflectApply ( Zlib , this , [ opts , UNZIP ] ) ;
761
768
}
762
769
ObjectSetPrototypeOf ( Unzip . prototype , Zlib . prototype ) ;
@@ -831,16 +838,18 @@ ObjectSetPrototypeOf(Brotli.prototype, Zlib.prototype);
831
838
ObjectSetPrototypeOf ( Brotli , Zlib ) ;
832
839
833
840
function BrotliCompress ( opts ) {
834
- if ( ! ( this instanceof BrotliCompress ) )
841
+ if ( ! new . target ) {
835
842
return new BrotliCompress ( opts ) ;
843
+ }
836
844
ReflectApply ( Brotli , this , [ opts , BROTLI_ENCODE ] ) ;
837
845
}
838
846
ObjectSetPrototypeOf ( BrotliCompress . prototype , Brotli . prototype ) ;
839
847
ObjectSetPrototypeOf ( BrotliCompress , Brotli ) ;
840
848
841
849
function BrotliDecompress ( opts ) {
842
- if ( ! ( this instanceof BrotliDecompress ) )
850
+ if ( ! new . target ) {
843
851
return new BrotliDecompress ( opts ) ;
852
+ }
844
853
ReflectApply ( Brotli , this , [ opts , BROTLI_DECODE ] ) ;
845
854
}
846
855
ObjectSetPrototypeOf ( BrotliDecompress . prototype , Brotli . prototype ) ;
0 commit comments