@@ -706,57 +706,64 @@ Zlib.prototype.params = function params(level, strategy, callback) {
706706// generic zlib
707707// minimal 2-byte header
708708function Deflate ( opts ) {
709- if ( ! ( this instanceof Deflate ) )
709+ if ( ! new . target ) {
710710 return new Deflate ( opts ) ;
711+ }
711712 ReflectApply ( Zlib , this , [ opts , DEFLATE ] ) ;
712713}
713714ObjectSetPrototypeOf ( Deflate . prototype , Zlib . prototype ) ;
714715ObjectSetPrototypeOf ( Deflate , Zlib ) ;
715716
716717function Inflate ( opts ) {
717- if ( ! ( this instanceof Inflate ) )
718+ if ( ! new . target ) {
718719 return new Inflate ( opts ) ;
720+ }
719721 ReflectApply ( Zlib , this , [ opts , INFLATE ] ) ;
720722}
721723ObjectSetPrototypeOf ( Inflate . prototype , Zlib . prototype ) ;
722724ObjectSetPrototypeOf ( Inflate , Zlib ) ;
723725
724726function Gzip ( opts ) {
725- if ( ! ( this instanceof Gzip ) )
727+ if ( ! new . target ) {
726728 return new Gzip ( opts ) ;
729+ }
727730 ReflectApply ( Zlib , this , [ opts , GZIP ] ) ;
728731}
729732ObjectSetPrototypeOf ( Gzip . prototype , Zlib . prototype ) ;
730733ObjectSetPrototypeOf ( Gzip , Zlib ) ;
731734
732735function Gunzip ( opts ) {
733- if ( ! ( this instanceof Gunzip ) )
736+ if ( ! new . target ) {
734737 return new Gunzip ( opts ) ;
738+ }
735739 ReflectApply ( Zlib , this , [ opts , GUNZIP ] ) ;
736740}
737741ObjectSetPrototypeOf ( Gunzip . prototype , Zlib . prototype ) ;
738742ObjectSetPrototypeOf ( Gunzip , Zlib ) ;
739743
740744function 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 ) {
743747 return new DeflateRaw ( opts ) ;
748+ }
744749 ReflectApply ( Zlib , this , [ opts , DEFLATERAW ] ) ;
745750}
746751ObjectSetPrototypeOf ( DeflateRaw . prototype , Zlib . prototype ) ;
747752ObjectSetPrototypeOf ( DeflateRaw , Zlib ) ;
748753
749754function InflateRaw ( opts ) {
750- if ( ! ( this instanceof InflateRaw ) )
755+ if ( ! new . target ) {
751756 return new InflateRaw ( opts ) ;
757+ }
752758 ReflectApply ( Zlib , this , [ opts , INFLATERAW ] ) ;
753759}
754760ObjectSetPrototypeOf ( InflateRaw . prototype , Zlib . prototype ) ;
755761ObjectSetPrototypeOf ( InflateRaw , Zlib ) ;
756762
757763function Unzip ( opts ) {
758- if ( ! ( this instanceof Unzip ) )
764+ if ( ! new . target ) {
759765 return new Unzip ( opts ) ;
766+ }
760767 ReflectApply ( Zlib , this , [ opts , UNZIP ] ) ;
761768}
762769ObjectSetPrototypeOf ( Unzip . prototype , Zlib . prototype ) ;
@@ -831,16 +838,18 @@ ObjectSetPrototypeOf(Brotli.prototype, Zlib.prototype);
831838ObjectSetPrototypeOf ( Brotli , Zlib ) ;
832839
833840function BrotliCompress ( opts ) {
834- if ( ! ( this instanceof BrotliCompress ) )
841+ if ( ! new . target ) {
835842 return new BrotliCompress ( opts ) ;
843+ }
836844 ReflectApply ( Brotli , this , [ opts , BROTLI_ENCODE ] ) ;
837845}
838846ObjectSetPrototypeOf ( BrotliCompress . prototype , Brotli . prototype ) ;
839847ObjectSetPrototypeOf ( BrotliCompress , Brotli ) ;
840848
841849function BrotliDecompress ( opts ) {
842- if ( ! ( this instanceof BrotliDecompress ) )
843- return new BrotliDecompress ( opts ) ;
850+ if ( ! new . target ) {
851+ return new BrotliCompress ( opts ) ;
852+ }
844853 ReflectApply ( Brotli , this , [ opts , BROTLI_DECODE ] ) ;
845854}
846855ObjectSetPrototypeOf ( BrotliDecompress . prototype , Brotli . prototype ) ;
0 commit comments