Reputation: 2702
I have a few questions on zlib
module, to be used with files under 40MB:
zlib.gzipSync()
for fastest zipping (compression level does not matter)?Buffer
?Asked because reference is not expressive.
Upvotes: 3
Views: 5724
Reputation: 144912
The docs describe the options
object used for every zlib call. They also point you to the zlib manual which describes those options in great detail.
The fastest level
is 0
, which means no compression. However, this would be silly, since you may as well skip gzipping altogether. 1
means "some compression with best speed."
That said, don't use gzipSync
. We don't do things synchronously in node. If you're looking to write the compressed data to a file, do:
var compressor = zlib.createGzip({level: 1});
compressor.pipe(fs.createWriteStream('output.gz'));
compressor.end(inputData);
Upvotes: 0
Reputation: 112394
Yeah, not much to go on in that documentation.
I recommend that you look at the zlib manual (the zlib.h source file) for information on the noted parameters and operations.
The fastest compression would be level 1.
The default compression level is 6. Other defaults can be found in zlib.h.
There does not appear to be an interface to deflateSetHeader()
, which would be required to insert a file name in a gzip header.
Upvotes: 1