c2843276f6978a7add934ba3733af9806214a7ae34f3e657f10733f8c087694843a1d45a559cd96ff4e0ed5eb9f5f2d0f1b0f16f71660f1a790666dba1f4e4 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # minizlib
  2. A fast zlib stream built on [minipass](http://npm.im/minipass) and
  3. Node.js's zlib binding.
  4. This module was created to serve the needs of
  5. [node-tar](http://npm.im/tar) and
  6. [minipass-fetch](http://npm.im/minipass-fetch).
  7. Brotli is supported in versions of node with a Brotli binding.
  8. ## How does this differ from the streams in `require('zlib')`?
  9. First, there are no convenience methods to compress or decompress a
  10. buffer. If you want those, use the built-in `zlib` module. This is
  11. only streams. That being said, Minipass streams to make it fairly easy to
  12. use as one-liners: `new zlib.Deflate().end(data).read()` will return the
  13. deflate compressed result.
  14. This module compresses and decompresses the data as fast as you feed
  15. it in. It is synchronous, and runs on the main process thread. Zlib
  16. and Brotli operations can be high CPU, but they're very fast, and doing it
  17. this way means much less bookkeeping and artificial deferral.
  18. Node's built in zlib streams are built on top of `stream.Transform`.
  19. They do the maximally safe thing with respect to consistent
  20. asynchrony, buffering, and backpressure.
  21. See [Minipass](http://npm.im/minipass) for more on the differences between
  22. Node.js core streams and Minipass streams, and the convenience methods
  23. provided by that class.
  24. ## Classes
  25. - Deflate
  26. - Inflate
  27. - Gzip
  28. - Gunzip
  29. - DeflateRaw
  30. - InflateRaw
  31. - Unzip
  32. - BrotliCompress (Node v10 and higher)
  33. - BrotliDecompress (Node v10 and higher)
  34. ## USAGE
  35. ```js
  36. const zlib = require('minizlib')
  37. const input = sourceOfCompressedData()
  38. const decode = new zlib.BrotliDecompress()
  39. const output = whereToWriteTheDecodedData()
  40. input.pipe(decode).pipe(output)
  41. ```
  42. ## REPRODUCIBLE BUILDS
  43. To create reproducible gzip compressed files across different operating
  44. systems, set `portable: true` in the options. This causes minizlib to set
  45. the `OS` indicator in byte 9 of the extended gzip header to `0xFF` for
  46. 'unknown'.