simplelzw

package
v0.0.0-...-0f339ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(uncompressed []byte) ([]byte, error)

Compress data using a simplified version of the Lempel-Ziv-Welch (LZW) algorithm.

This algorithm differs from the one used by GIF, PDF, TIFF, etc. in that it does not place an upper limit on the number of codes. There is also no support for issuing reset codes. As this makes the amount of state needed to compress and decompress proportional to the size of the resulting compressed data, this algorithm is not suitable for compressing streams of data.

This algorithm provides a compression ratio that is worse than Zstandard. It is also slower. It is only provided because its output is deterministic and reproducible. Because it is easy to implement, it is easy to achieve reproducibility across implementations.

func Decompress

func Decompress(compressed []byte, maximumSizeBytes uint32) ([]byte, error)

Decompress data that was compressed using Compress() or MaybeCompress().

func MaybeCompress

func MaybeCompress(uncompressed []byte) ([]byte, error)

MaybeCompress compresses data, but discards the results if the compressed copy is larger than the original. In that case the uncompressed version is returned, prefixed with a decompressed size of 0 bytes, indicating that data is not compressed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL