This build is based on facebook/zstd and provides a thin WebAssembly wrapper around the zstd.h API. Please see index.html for a demo and usage example.
This is a size-optimized build (ZSTD_MINIFY_LIB and ZSTD_NO_INLINE build flags). The build output is four versions of the binding: full, compress-only, decompress-only, and compress+decompress-only. The brotli-compressed size of the wasm varies from 23 kB decompress-only to 76kB full binding.
This repo tracks the upstream as a submodule.
The previous forked repo is archived.
Thanks to Fredrick R. Brennan for their awesome work bringing the forked repo up-to-date with upstream Zstandard and fixing the CMake build files.
Skip the first line if you already have Emscripten set up.
git clone https://github.com/emscripten-core/emsdk.git && cd emsdk && ./emsdk install latest && ./emsdk activate latest && source ./emsdk_env.sh && cd .. &&
git clone https://github.com/kig/zstd-emscripten && cd zstd-emscripten && git submodule update --init &&
mkdir -p build && cd build && emcmake cmake ../cmake/ && emmake make -j4 && cd .. &&
serve -p 5000
# open http://localhost:5000/index.html
See the test page for examples on using the simple API and the streaming compression and decompression API.
Zstd-emscripten is a 1:1 binding to the ZSTD API in zstd.h, please refer to the ZSTD docs for further details.
The compress-only and decompress-only versions of the library bind just a few functions, see exported_functions_compress.txt and exported_functions_decompress.txt for the exported function lists. The full version function 70C6 list is in exported_functions.txt.
(c) 2016–2021 Ilmari Heikkinen, Fredrick R. Brennan. As with Zstd itself, this is dual-licensed under BSD and GPLv2.