I am a big fan of sugar. Here's how a gzip compression statement works in Node.JS
:
var q = require('qtree');
var zlib = require('zlib');
q(someData)
.then(q.nbind(zlib.gzip, zlib))
.then(function(gzippedData) {
// play with gzipped data
})
.done();
Now zlib.gzip
is a convenience method, and according to Node Documentation:
The convenience methods use the default settings for all options.
Now, how do I set (default) options for these convenience methods? Because I cannot use the same sugar writing style when I first do:
var gzip = zlib.createGzip({
level : zlib.Z_BEST_COMPRESSION
});
this new gzip
is not a function in the form of gzip(input, callback)
so I cannot use it that way.