(Translated by https://www.hiragana.jp/)
GitHub - sjnam/luajit-zstd: Facebook zstandard ffi binding
Skip to content
This repository has been archived by the owner on Nov 21, 2021. It is now read-only.

sjnam/luajit-zstd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

Name

luajit-zstd - facebook zstandard ffi binding

Installation

To install luajit-zstd you need to install Zstandard with shared libraries firtst. Then you can install luajit-zstd by placing lib/zstd.lua to your lua library path.

Example

local zstandard = require "zstd"
local zstd = zstandard:new()
local txt = string.rep("ABCD", 1000)
print("Uncompressed size:", #txt)
local c, err = zstd:compress(txt)
print("Compressed size:", #c)
local txt2, err = zstd:decompress(c)
assert(txt == txt2)
zstd:free()

Methods

new

syntax: zstd = zstandard:new()

Create cstream and dstream.

free

syntax: zstd:free()

Free cstream and dstream.

compress

syntax: encoded_buffer, err = zstd:compress(input_buffer, clvl)

Compresses the data in input_buffer into encoded_buffer.

decompress

syntax: decoded_buffer, err = zstd:decompress(encoded_buffer)

Decompresses the data in encoded_buffer into decoded_buffer.

compressFile

syntax: ok, err = zstd:compressFile(path, clvl?)

Compresses the input file with clvl compression level.

decompressFile

syntax: ok, err = zstd:decompressFile(fname, outname?)

Decompress the input file fname.

compressFileUsingDictionary

syntax: ok, err = zstd:compressFileUsingDictionary(path, dict, clvl?)

Compresses the input file with clvl compression level using a digested Dictionary.

decompressFileUsingDictionary

syntax: ok, err = zstd:decompressFileUsingDictionary(fname, dict, outname?)

Decompress the input file fname using a digested Dictionary.

Author

Soojin Nam jsunam@gamil.com

License

Public Domain