zlib: allow zero values for level and strategy
authorBrian White <mscdex@mscdex.net>
Mon, 1 Jul 2013 09:42:19 +0000 (05:42 -0400)
committerBen Noordhuis <info@bnoordhuis.nl>
Mon, 1 Jul 2013 17:37:29 +0000 (19:37 +0200)
This is a back-port of commit c9644fb from the master branch.

lib/zlib.js

index c926314..a1896ba 100644 (file)
@@ -298,10 +298,16 @@ function Zlib(opts, mode) {
     self.emit('error', error);
   };
 
+  var level = exports.Z_DEFAULT_COMPRESSION;
+  if (typeof opts.level === 'number') level = opts.level;
+
+  var strategy = exports.Z_DEFAULT_STRATEGY;
+  if (typeof opts.strategy === 'number') strategy = opts.strategy;
+
   this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS,
-                     opts.level || exports.Z_DEFAULT_COMPRESSION,
+                     level,
                      opts.memLevel || exports.Z_DEFAULT_MEMLEVEL,
-                     opts.strategy || exports.Z_DEFAULT_STRATEGY,
+                     strategy,
                      opts.dictionary);
 
   this._buffer = new Buffer(this._chunkSize);