@@ -686,57 +686,78 @@ Zlib.prototype.params = function params(level, strategy, callback) {
686686// generic zlib
687687// minimal 2-byte header
688688function 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' ) ;
690692 return new Deflate ( opts ) ;
693+ }
691694 ReflectApply ( Zlib , this , [ opts , DEFLATE ] ) ;
692695}
693696ObjectSetPrototypeOf ( Deflate . prototype , Zlib . prototype ) ;
694697ObjectSetPrototypeOf ( Deflate , Zlib ) ;
695698
696699function 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' ) ;
698703 return new Inflate ( opts ) ;
704+ }
699705 ReflectApply ( Zlib , this , [ opts , INFLATE ] ) ;
700706}
701707ObjectSetPrototypeOf ( Inflate . prototype , Zlib . prototype ) ;
702708ObjectSetPrototypeOf ( Inflate , Zlib ) ;
703709
704710function 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' ) ;
706714 return new Gzip ( opts ) ;
715+ }
707716 ReflectApply ( Zlib , this , [ opts , GZIP ] ) ;
708717}
709718ObjectSetPrototypeOf ( Gzip . prototype , Zlib . prototype ) ;
710719ObjectSetPrototypeOf ( Gzip , Zlib ) ;
711720
712721function 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' ) ;
714725 return new Gunzip ( opts ) ;
726+ }
715727 ReflectApply ( Zlib , this , [ opts , GUNZIP ] ) ;
716728}
717729ObjectSetPrototypeOf ( Gunzip . prototype , Zlib . prototype ) ;
718730ObjectSetPrototypeOf ( Gunzip , Zlib ) ;
719731
720732function DeflateRaw ( opts ) {
721733 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' ) ;
723737 return new DeflateRaw ( opts ) ;
738+ }
724739 ReflectApply ( Zlib , this , [ opts , DEFLATERAW ] ) ;
725740}
726741ObjectSetPrototypeOf ( DeflateRaw . prototype , Zlib . prototype ) ;
727742ObjectSetPrototypeOf ( DeflateRaw , Zlib ) ;
728743
729744function 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' ) ;
731748 return new InflateRaw ( opts ) ;
749+ }
732750 ReflectApply ( Zlib , this , [ opts , INFLATERAW ] ) ;
733751}
734752ObjectSetPrototypeOf ( InflateRaw . prototype , Zlib . prototype ) ;
735753ObjectSetPrototypeOf ( InflateRaw , Zlib ) ;
736754
737755function 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' ) ;
739759 return new Unzip ( opts ) ;
760+ }
740761 ReflectApply ( Zlib , this , [ opts , UNZIP ] ) ;
741762}
742763ObjectSetPrototypeOf ( Unzip . prototype , Zlib . prototype ) ;
@@ -801,16 +822,22 @@ ObjectSetPrototypeOf(Brotli.prototype, Zlib.prototype);
801822ObjectSetPrototypeOf ( Brotli , Zlib ) ;
802823
803824function 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' ) ;
805828 return new BrotliCompress ( opts ) ;
829+ }
806830 ReflectApply ( Brotli , this , [ opts , BROTLI_ENCODE ] ) ;
807831}
808832ObjectSetPrototypeOf ( BrotliCompress . prototype , Brotli . prototype ) ;
809833ObjectSetPrototypeOf ( BrotliCompress , Brotli ) ;
810834
811835function 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' ) ;
813839 return new BrotliDecompress ( opts ) ;
840+ }
814841 ReflectApply ( Brotli , this , [ opts , BROTLI_DECODE ] ) ;
815842}
816843ObjectSetPrototypeOf ( BrotliDecompress . prototype , Brotli . prototype ) ;
0 commit comments