lz4compress Synchronous

  • crypt.lz4.compress
  • crypt.lz4compress
  • lz4.compress

Compress a string’s bytes into an LZ4 block. Pass the returned string to lz4decompress when the original data is needed again. Use it to reduce repetitive data before storage or transfer. The output is binary; retain the format information so the reader knows which decompressor to use.

Syntax
Luau
lz4compress(data: string) -> string

Parameters

Function parameters
ParameterTypeDescription
datastringUncompressed text or binary bytes.

Returns

string

An LZ4 block as a byte string. The result is not printable text, and small inputs may become larger after compression.

Example

Example
Luau
local original = string.rep("saved data;", 20)
local compressed = lz4compress(original)
print(#original, #compressed)
assert(lz4decompress(compressed) == original)
Kawaii documentation