Node: Implement 7zip module

Created on 11 Apr 2020  路  3Comments  路  Source: nodejs/node

Is your feature request related to a problem? Please describe.
I need to compress lots of log files, which are taking up lots of storage and the zlib module doesn't compress the log files enough.

Describe the solution you'd like.
7zip is very popular, has been tested rigorously and has a vast range of compression options. The 7z file format is much more efficient than the gz file format and can compress files much more. It would be very useful to have a 7zip module in Node.js.

Describe alternatives you've considered.
There are lots of 7zip modules on npm:

  • node-7z-forall

    • similar to Node.js design.

    • vast range of features.

    • 7zip doesn't need to be installed.

  • 7zip-min

    • cross-platform support.

    • easy to use.

    • 7zip doesn't need to be installed.

  • node-7z

    • similar to Node.js design.

    • vast range of features.

    • 7zip does need to be installed OR the 7zip binary can be imported using the 7zip-bin npm module.

Most helpful comment

This is interesting in that the requested feature is superficially simple ("support 7zip") but not when you look at it in detail.

7zip itself is a program, not a file format or a compression method.

7z _is_ a file format but it's a container format: it supports the deflate, bzip2, lzma (1 and 2) and ppm compression methods. Different sections of a file can use different methods.

Node.js supports deflate but not the others. Adding support for them isn't trivial and probably boils down to vendoring existing, license-compatible libraries, and taking on the maintenance responsibility that comes with that. Not very attractive.

I could maybe get behind lzma support, that's what xz(1) produces and consumes. On the other hand, the OSS ecosystem seems to be moving towards zstd.


That said, if all you want to do is compress some log files, just shell out to your favorite compression tool. Nothing wrong with that. :-)

All 3 comments

-1 This is best left to userland.

This is interesting in that the requested feature is superficially simple ("support 7zip") but not when you look at it in detail.

7zip itself is a program, not a file format or a compression method.

7z _is_ a file format but it's a container format: it supports the deflate, bzip2, lzma (1 and 2) and ppm compression methods. Different sections of a file can use different methods.

Node.js supports deflate but not the others. Adding support for them isn't trivial and probably boils down to vendoring existing, license-compatible libraries, and taking on the maintenance responsibility that comes with that. Not very attractive.

I could maybe get behind lzma support, that's what xz(1) produces and consumes. On the other hand, the OSS ecosystem seems to be moving towards zstd.


That said, if all you want to do is compress some log files, just shell out to your favorite compression tool. Nothing wrong with that. :-)

I could maybe get behind lzma support, that's what xz(1) produces and consumes.

Just for context, I鈥檝e been maintaining https://www.npmjs.com/package/lzma-native for a while now, and adding support for lzma/xz to Node.js core wouldn鈥檛 be too complicated. On the other hand, I think we mostly want deflate/gzip/brotli because those are the web鈥檚 most common compression methods, and the demand for lzma/xz suppport doesn鈥檛 seem to compare to the demand for those imo.

Was this page helpful?
0 / 5 - 0 ratings