zlib: add dictionary support to zstdCompress and zstdDecompress

Adds optional dictionary support to zlib’s zstdCompress and
zstdDecompress APIs. This enables better compression ratios when the
dictionary matches expected input structure or content patterns.

The implementation allows passing a `dictionary` buffer through the
options object. Support was added to both streaming and convenience
methods. Tests and documentation were also updated to reflect this new
capability.

Fixes: https://github.com/nodejs/node/issues/59105
PR-URL: https://github.com/nodejs/node/pull/59240
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
lluisemper 2025-08-04 18:13:57 +02:00 committed by GitHub
parent f7c2a7ed4a
commit b8e643259e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 79 additions and 7 deletions

View file

@ -1069,6 +1069,9 @@ Each Zstd-based class takes an `options` object. All options are optional.
* `maxOutputLength` {integer} Limits output size when using
[convenience methods][]. **Default:** [`buffer.kMaxLength`][]
* `info` {boolean} If `true`, returns an object with `buffer` and `engine`. **Default:** `false`
* `dictionary` {Buffer} Optional dictionary used to
improve compression efficiency when compressing or decompressing data that
shares common patterns with the dictionary.
For example: