@@ -35,17 +35,15 @@ module.exports = compression
3535 */
3636
3737function compression ( options ) {
38- options = options || { } ;
38+ var opts = options || { }
3939
40- var filter = options . filter || shouldCompress
41- var threshold ;
40+ var filter = opts . filter || shouldCompress
41+ var threshold = typeof opts . threshold === 'string'
42+ ? bytes ( opts . threshold )
43+ : opts . threshold
4244
43- if ( false === options . threshold || 0 === options . threshold ) {
44- threshold = 0
45- } else if ( 'string' === typeof options . threshold ) {
46- threshold = bytes ( options . threshold )
47- } else {
48- threshold = options . threshold || 1024
45+ if ( threshold == null ) {
46+ threshold = 1024
4947 }
5048
5149 return function compression ( req , res , next ) {
@@ -169,8 +167,8 @@ function compression(options) {
169167 // compression stream
170168 debug ( '%s compression' , method )
171169 stream = method === 'gzip'
172- ? zlib . createGzip ( options )
173- : zlib . createDeflate ( options )
170+ ? zlib . createGzip ( opts )
171+ : zlib . createDeflate ( opts )
174172
175173 // add bufferred listeners to stream
176174 addListeners ( stream , stream . on , listeners )
0 commit comments