lz4decompress Synchronous

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

Expand an LZ4 block previously produced by lz4compress. Supply a capacity when the source is untrusted or your script has a known maximum document size.

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

Parameters

Function parameters
ParameterTypeDescription
datastringCompressed LZ4 block.
maxOutputSizenumber?Optional nonnegative output capacity in bytes. Omit it for the default limit; explicit nil is rejected.

Returns

string

The original byte string. Invalid blocks and output that exceeds the selected capacity raise an error.

Usage notes

The optional second argument is a limit, not a promised output length. A valid result can be shorter.

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 packed = lz4compress("saved preferences")
local ok, text = pcall(lz4decompress, packed, 1024)
if ok then print(text) end
Kawaii documentation