zlib: add zstd support
Adds ZstdCompress
and ZsdDecompress
to the zlib
module which can be used to compress/decompress with the Zstandard ("zstd") algorithm.
Notable omissions:
- Providing dictionaries isn't implemented.
- The docs in
zlib.md
don't call out any params beyond the basic compression level.
The code follows similar patterns to the PR that added Brotli support. Just that instead of brotli, it adds the equivalent zstd APIs. Just like Brotli, this required separate compression/decompression context objects.
Zstd itself has been around and stable for multiple years but this PR is early in terms of web support: It only just starts shipping by default in Chrome 123. On the other hand, by shipping in Chrome it will soon be supported quite widely on the web. Firefox also signaled support (https://bugzilla.mozilla.org/show_bug.cgi?id=1301878#c65). Zstd is now enabled on the web and supported by both Chrome and Firefox: https://caniuse.com/zstd
Official support in node.js would allow passing additional WPTs around fetch
(https://github.com/nodejs/undici/issues/2847).