A streaming gzip compressor. Feed data incrementally with write,
then call finish to produce the final gzip output.
@eryx/compression/gzip Module
Gzip helpers: compress/decompress and header inspection utilities.
Summary
Classes
Functions
API Reference
Classes
Compressor
Properties
Compressor:write
Compressor:finish
Compressor:close
Decompressor
A streaming gzip decompressor. Feed compressed chunks with write;
the second return value indicates when the stream is complete.
Properties
Decompressor:write
Decompressor:close
Functions
gzip.compress
Standard gzip compress.
Parameters
input bytes to compress
compression level (NO_COMPRESSION..BEST_COMPRESSION)
Returns
gzip-wrapped compressed bytes
gzip.compressEx
Gzip compress with a custom header (filename, timestamp, OS, comment).
Parameters
input bytes to compress
header and compression options
Returns
gzip-wrapped compressed bytes
gzip.decompress
Gzip decompress.
Parameters
gzip stream to decompress
Returns
decompressed bytes
gzip.isGzip
Returns true if the buffer starts with the gzip magic bytes (0x1F 0x8B).
Parameters
data to inspect
Returns
true when buffer looks like gzip
gzip.readHeader
Parses the gzip header fields without decompressing the payload.
Parameters
gzip stream
Returns
parsed header fields
gzip.createCompressor
Creates a streaming gzip compressor.
Parameters
compression level
Returns
the streaming compressor
gzip.createDecompressor
Creates a streaming gzip decompressor.
Returns
the streaming decompressor
Types
GzipHeader
CompressExOptions
Constants
- OS identifier constants (from the gzip spec RFC 1952)
gzip.OS_FAT=0- MS-DOS / FATgzip.OS_AMIGA=1gzip.OS_VMS=2gzip.OS_UNIX=3gzip.OS_HPFS=6- OS/2 / NTgzip.OS_MAC=7gzip.OS_NTFS=11gzip.OS_UNKNOWN=255- Compression levels
gzip.NO_COMPRESSION=0gzip.BEST_SPEED=1gzip.BEST_COMPRESSION=9