Syntax
lz4compress(data: string): stringAliases
crypt.lz4compresscrypt.lz4.compresslz4.compressArguments
| Name | Type | Description |
|---|---|---|
data | string | Lua string bytes passed to LZ4 block compression. |
Returns
| Name | Type | Description |
|---|---|---|
compressed | string | Raw compressed bytes returned as a Lua string. The original size is not stored in the output. |
Description
Compresses Lua string bytes with LZ4 block compression and returns the raw compressed bytes as a Lua string.
Call it with 1 parameter(s): data. The argument table explains which values are required and which ones only refine the behavior.
It returns compressed (string). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Compress Lua string bytes and restore them by passing the original size.
local source = string.rep("Real Docs ", 100)
local compressed = lz4compress(source)
local restored = lz4decompress(compressed, #source)
print(#source, #compressed, restored == source)