lz4decompress Synchronous

  • crypt.lz4.decompress
  • crypt.lz4decompress
  • lz4.decompress

Restore a string from an LZ4-compressed block. This reverses lz4compress and returns the original bytes. Use it to load data saved with LZ4. A compressed payload must be decoded with the same format; Zstandard data belongs to zstddecompress.

Syntax
Luau
lz4decompress(data: string, maxOutputSize: number?) -> string

Parameters

Function parameters
ParameterTypeDescription
datastringLZ4 block to decompress.
maxOutputSizenumber?Optional non-negative output capacity in bytes. Omit the argument when no smaller limit is needed; explicit nil is rejected.

Returns

string

The decompressed string. Invalid compressed data or output exceeding the supplied limit raises an error.

Differences from sUNC

Kawaii accepts an optional second argument, maxOutputSize. The sUNC signature lists only data. This argument is a capacity limit: decompressed output may be shorter than it.

Example

Example
Luau
local compressed = lz4compress("hello hello hello")
print(lz4decompress(compressed, 1024)) -- hello hello hello
Kawaii documentation