Adding a needed feature to Node.js’s zlib module

Necessity is the mother of pull requests

As you may know, Node.js is the JavaScript web server. As such, one of the necessary features for it to have is a zlib compression and decompression module. That module is actually pretty neat. It features both a syncronous and an asyncronous API backed by native-code which makes it much more efficient than JavaScript-based alternative.

It the best option for handling zlib compression in Node.js… That is of course, unless it’s missing a feature.

I had need of a way to decompress multiple zlib streams that were concatenated together without any meta data to tell how long each stream was. This is trivial to do with the native C library, python, or pure-JS zlib ports. Unfortunately, the Node.js zlib API simply did not expose this information.

One option would be to just use a pure-JS zlib port like pako, but Node.js is open source. It would be better if we just fix the problem!

Searching through the bug tracker, I found an existing open issue, and after a brief discussion of what the API should look like, I created the pull requests.

Now with the release of Node.js 8.1, this information is available, and the bug is no more!

This is what makes open source great!

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? * Time limit is exhausted. Please reload the CAPTCHA.