Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/indiesoftby/defold-zstd
Zstandard compression API for the Defold engine.
https://github.com/indiesoftby/defold-zstd
defold defold-extension defold-library defold-native-extension zstd
Last synced: about 2 months ago
JSON representation
Zstandard compression API for the Defold engine.
- Host: GitHub
- URL: https://github.com/indiesoftby/defold-zstd
- Owner: indiesoftby
- License: other
- Created: 2024-09-17T22:45:54.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-17T22:51:24.000Z (3 months ago)
- Last Synced: 2024-10-04T22:08:03.163Z (3 months ago)
- Topics: defold, defold-extension, defold-library, defold-native-extension, zstd
- Language: C
- Homepage:
- Size: 494 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-defold - Zstandard Compression
README
# Zstandard Compression for Defold
This is a native extension for [the Defold game engine](https://defold.com/) that allows you to use Zstandard to compress and decompress strings in your Lua code. The included version of Zstd is 1.5.6.
Currently, the extension has simple API with two functions: `compress` and `decompress`. It doesn't support streaming, dictionaries and other features of the Zstd library. If you need more features, you can fill an issue on GitHub or even better - submit a PR.
## Usage
First add this extension as a dependency to your `game.project`:
https://github.com/indiesoftby/defold-zstd/archive/main.zip
Then you can use the extension in your Lua code:
```lua
local zstd = require "zstd"local compression_level = 3 -- maximum and the slowest compression level is 22
local compressed = zstd.compress("Hello, world!", compression_level)
local decompressed = zstd.decompress(compressed)print(decompressed)
```## API
### `zstd.version()`
Returns the version of the Zstandard library.**Returns:**
- `string`: The version.### `zstd.compress(data, level)`
Compresses a string.**Parameters:**
- `data` (string): The data to compress.
- `level` (number, optional): Optional compression level (default is 3, maximum is 22)**Returns:**
- `string`: The compressed data### `zstd.decompress(data)`
Decompresses a string.**Parameters:**
- `data` (string): The data to decompress.**Returns:**
- `string`: The decompressed data.## License
This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.