This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
minizlib with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
A fast zlib stream built on minipass and Node.js's zlib binding.
Brotli is supported in versions of node with a Brotli binding.
First, there are no convenience methods to compress or decompress a
buffer. If you want those, use the built-in
zlib module. This is
only streams. That being said, Minipass streams to make it fairly easy to
use as one-liners:
new zlib.Deflate().end(data).read() will return the
deflate compressed result.
This module compresses and decompresses the data as fast as you feed it in. It is synchronous, and runs on the main process thread. Zlib and Brotli operations can be high CPU, but they're very fast, and doing it this way means much less bookkeeping and artificial deferral.
Node's built in zlib streams are built on top of
They do the maximally safe thing with respect to consistent
asynchrony, buffering, and backpressure.
See Minipass for more on the differences between Node.js core streams and Minipass streams, and the convenience methods provided by that class.
const zlib = require('minizlib') const input = sourceOfCompressedData() const decode = new zlib.BrotliDecompress() const output = whereToWriteTheDecodedData() input.pipe(decode).pipe(output)
To create reproducible gzip compressed files across different operating
portable: true in the options. This causes minizlib to set
OS indicator in byte 9 of the extended gzip header to