Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js: zlib.gzipSync()

Tags:

node.js

zlib

I have a few questions on zlib module, to be used with files under 40MB:

  1. What kind of options should be used in zlib.gzipSync() for fastest zipping (compression level does not matter)?
  2. Which default values is used, if options is not passed to the method?
  3. Is this method returns Buffer?
  4. What kind of extension and mime type should be used for final result?
  5. Update: How to pass a file name? (So after unzipping file has name and extension)

Asked because reference is not expressive.

like image 381
dr.dimitru Avatar asked Jun 29 '26 09:06

dr.dimitru


1 Answers

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.

like image 173
Mark Adler Avatar answered Jul 01 '26 23:07

Mark Adler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!