A streaming Zstandard compressor.
@class Compressor
@eryx/compression/zstd ModuleZstandard compression helpers: compress/decompress and dictionary support.
A streaming Zstandard compressor.
@class Compressor
A streaming Zstandard decompressor.
@class Decompressor
Compress data with Zstandard.
input bytes to compress
compression level (CLEVEL_MIN..CLEVEL_MAX)
compressed zstd frame level: CLEVEL_MIN (negative, ultra-fast) - CLEVEL_MAX (22, best). Default CLEVEL_DEFAULT (3). Negative levels trade ratio for extreme speed.
Decompress a Zstandard frame.
zstd frame to decompress
decompressed bytes Uses the content size embedded in the frame header when available (fast path).
Upper bound on compressed output size for len input bytes.
input length in bytes
upper bound on compressed size
Returns the decompressed size stored in the frame header, or nil if it was not stored (compressed with contentSize=0) or the frame is invalid.
zstd frame
decompressed size or nil
Compress using a pre-trained dictionary. The same dictionary must be supplied to decompressWithDict.
input bytes
dictionary data
compression level
compressed frame
Decompress using a pre-trained dictionary.
compressed frame
dictionary data used for compression
decompressed bytes
Train a Zstandard dictionary from an array of sample buffers.
representative examples of data
desired dictionary size in bytes
trained dictionary samples: { buffer } - representative examples of data you plan to compress. capacity: desired dictionary size in bytes (e.g. 112640 = 110 KB). Returns a dictionary buffer ready to pass to compress/decompressWithDict.
Creates a streaming Zstandard compressor.
compression level (CLEVEL_MIN..CLEVEL_MAX)
the streaming compressor
Creates a streaming Zstandard decompressor.
the streaming decompressor
zstd.CLEVEL_MAX = 22zstd.CLEVEL_DEFAULT = 3