This is a pure esm package contains the zstd n-api addon for node.js & wasm for browsers.
npm install @cloudpss/zstd
import { compress, decompress } from '@cloudpss/zstd';
const compressed = compress(Buffer.from('Hello World!'));
const decompressed = decompress(compressed);
console.log(decompressed.toString()); // Hello World!
To explicitly use the wasm or the n-api version, import @cloudpss/zstd/wasm
and @cloudpss/zstd/napi
respectively.
Notice: If you are using this library in a browser, the Buffer
classes is replaced with Uint8Array
classes.
Compresses the input buffer with the given compression level (default: 4).
Decompresses the input buffer.
The type of the current module.
The version of the zstd library.
The maximum size of the input/output buffer.
The default compression level.
Minimum compression level.
Maximum compression level.
MIT