lzw
Lempel–Ziv–Welch (LZW) is a universal lossless compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch.
Classes & types
type
lzw.Format
type
lzw.Options
Options of lzw.compress and lzw.decompress, every field is optional and both sides must use the same ones.
Functions
lzw.compress | Compresses a string using variable-width LZW, the format is set by the options. |
lzw.decompress | Decompresses a variable-width LZW string, the options must match the compression ones. |
#lzw.compress
function lzw.compress(raw_data: string, options?: lzw.Options): string
Compresses a string using variable-width LZW, the format is set by the options.
Parameters
| Name | Type | Description |
|---|---|---|
raw_data | string | The string to compress. |
optionsoptional | lzw.Options | The format options. |
Returns
| Type | Name | Description |
|---|---|---|
string | compressed_data | The compressed string. |
#lzw.decompress
function lzw.decompress(compressed_data: string, options?: lzw.Options): string
Decompresses a variable-width LZW string, the options must match the compression ones.
Without an end code the bits that do not form a whole code are ignored, so formats with codes narrower than a character should use one.
Parameters
| Name | Type | Description |
|---|---|---|
compressed_data | string | The string to decompress. |
optionsoptional | lzw.Options | The format options. |
Returns
| Type | Name | Description |
|---|---|---|
string | decompressed_data | The decompressed string. |