@@ -686,57 +686,78 @@ Zlib.prototype.params = function params(level, strategy, callback) {
686
686
// generic zlib
687
687
// minimal 2-byte header
688
688
function Deflate ( opts ) {
689
- if ( ! ( this instanceof Deflate ) )
689
+ if ( ! ( this instanceof Deflate ) ) {
690
+ process . emitWarning ( `Instantiating Deflate class without 'new' is deprecated.` ,
691
+ 'DeprecationWarning' , 'DEP0184' ) ;
690
692
return new Deflate ( opts ) ;
693
+ }
691
694
ReflectApply ( Zlib , this , [ opts , DEFLATE ] ) ;
692
695
}
693
696
ObjectSetPrototypeOf ( Deflate . prototype , Zlib . prototype ) ;
694
697
ObjectSetPrototypeOf ( Deflate , Zlib ) ;
695
698
696
699
function Inflate ( opts ) {
697
- if ( ! ( this instanceof Inflate ) )
700
+ if ( ! ( this instanceof Inflate ) ) {
701
+ process . emitWarning ( `Instantiating Inflate class without 'new' is deprecated.` ,
702
+ 'DeprecationWarning' , 'DEP0184' ) ;
698
703
return new Inflate ( opts ) ;
704
+ }
699
705
ReflectApply ( Zlib , this , [ opts , INFLATE ] ) ;
700
706
}
701
707
ObjectSetPrototypeOf ( Inflate . prototype , Zlib . prototype ) ;
702
708
ObjectSetPrototypeOf ( Inflate , Zlib ) ;
703
709
704
710
function Gzip ( opts ) {
705
- if ( ! ( this instanceof Gzip ) )
711
+ if ( ! ( this instanceof Gzip ) ) {
712
+ process . emitWarning ( `Instantiating Gzip class without 'new' is deprecated.` ,
713
+ 'DeprecationWarning' , 'DEP0184' ) ;
706
714
return new Gzip ( opts ) ;
715
+ }
707
716
ReflectApply ( Zlib , this , [ opts , GZIP ] ) ;
708
717
}
709
718
ObjectSetPrototypeOf ( Gzip . prototype , Zlib . prototype ) ;
710
719
ObjectSetPrototypeOf ( Gzip , Zlib ) ;
711
720
712
721
function Gunzip ( opts ) {
713
- if ( ! ( this instanceof Gunzip ) )
722
+ if ( ! ( this instanceof Gunzip ) ) {
723
+ process . emitWarning ( `Instantiating Gunzip class without 'new' is deprecated.` ,
724
+ 'DeprecationWarning' , 'DEP0184' ) ;
714
725
return new Gunzip ( opts ) ;
726
+ }
715
727
ReflectApply ( Zlib , this , [ opts , GUNZIP ] ) ;
716
728
}
717
729
ObjectSetPrototypeOf ( Gunzip . prototype , Zlib . prototype ) ;
718
730
ObjectSetPrototypeOf ( Gunzip , Zlib ) ;
719
731
720
732
function DeflateRaw ( opts ) {
721
733
if ( opts && opts . windowBits === 8 ) opts . windowBits = 9 ;
722
- if ( ! ( this instanceof DeflateRaw ) )
734
+ if ( ! ( this instanceof DeflateRaw ) ) {
735
+ process . emitWarning ( `Instantiating DeflateRaw class without 'new' is deprecated.` ,
736
+ 'DeprecationWarning' , 'DEP0184' ) ;
723
737
return new DeflateRaw ( opts ) ;
738
+ }
724
739
ReflectApply ( Zlib , this , [ opts , DEFLATERAW ] ) ;
725
740
}
726
741
ObjectSetPrototypeOf ( DeflateRaw . prototype , Zlib . prototype ) ;
727
742
ObjectSetPrototypeOf ( DeflateRaw , Zlib ) ;
728
743
729
744
function InflateRaw ( opts ) {
730
- if ( ! ( this instanceof InflateRaw ) )
745
+ if ( ! ( this instanceof InflateRaw ) ) {
746
+ process . emitWarning ( `Instantiating InflateRaw class without 'new' is deprecated.` ,
747
+ 'DeprecationWarning' , 'DEP0184' ) ;
731
748
return new InflateRaw ( opts ) ;
749
+ }
732
750
ReflectApply ( Zlib , this , [ opts , INFLATERAW ] ) ;
733
751
}
734
752
ObjectSetPrototypeOf ( InflateRaw . prototype , Zlib . prototype ) ;
735
753
ObjectSetPrototypeOf ( InflateRaw , Zlib ) ;
736
754
737
755
function Unzip ( opts ) {
738
- if ( ! ( this instanceof Unzip ) )
756
+ if ( ! ( this instanceof Unzip ) ) {
757
+ process . emitWarning ( `Instantiating Unzip class without 'new' is deprecated.` ,
758
+ 'DeprecationWarning' , 'DEP0184' ) ;
739
759
return new Unzip ( opts ) ;
760
+ }
740
761
ReflectApply ( Zlib , this , [ opts , UNZIP ] ) ;
741
762
}
742
763
ObjectSetPrototypeOf ( Unzip . prototype , Zlib . prototype ) ;
@@ -801,16 +822,22 @@ ObjectSetPrototypeOf(Brotli.prototype, Zlib.prototype);
801
822
ObjectSetPrototypeOf ( Brotli , Zlib ) ;
802
823
803
824
function BrotliCompress ( opts ) {
804
- if ( ! ( this instanceof BrotliCompress ) )
825
+ if ( ! ( this instanceof BrotliCompress ) ) {
826
+ process . emitWarning ( `Instantiating BrotliCompress class without 'new' is deprecated.` ,
827
+ 'DeprecationWarning' , 'DEP0184' ) ;
805
828
return new BrotliCompress ( opts ) ;
829
+ }
806
830
ReflectApply ( Brotli , this , [ opts , BROTLI_ENCODE ] ) ;
807
831
}
808
832
ObjectSetPrototypeOf ( BrotliCompress . prototype , Brotli . prototype ) ;
809
833
ObjectSetPrototypeOf ( BrotliCompress , Brotli ) ;
810
834
811
835
function BrotliDecompress ( opts ) {
812
- if ( ! ( this instanceof BrotliDecompress ) )
836
+ if ( ! ( this instanceof BrotliDecompress ) ) {
837
+ process . emitWarning ( `Instantiating BrotliDecompress class without 'new' is deprecated.` ,
838
+ 'DeprecationWarning' , 'DEP0184' ) ;
813
839
return new BrotliDecompress ( opts ) ;
840
+ }
814
841
ReflectApply ( Brotli , this , [ opts , BROTLI_DECODE ] ) ;
815
842
}
816
843
ObjectSetPrototypeOf ( BrotliDecompress . prototype , Brotli . prototype ) ;
0 commit comments