Zstd binding for Nodejs, with TypeScript support.
$ npm install @xingrz/cppzst --saveimport { compress } from '@xingrz/cppzst';
try {
const output = await compress(input);
} catch(err) {
// ...
}import { decompress } from '@xingrz/cppzst';
try {
const output = await decompress(input);
} catch(err) {
// ...
}import { compressSync } from '@xingrz/cppzst';
try {
const output = compressSync(input);
} catch(err) {
// ...
}import { decompressSync } from '@xingrz/cppzst';
try {
const output = decompressSync(input);
} catch(err) {
// ...
}import { compressStream } from '@xingrz/cppzst';
import { createReadStream, createWriteStream } from 'fs';
createReadStream('path/to/input')
.pipe(compressStream())
.pipe(createWriteStream('path/to/output'));import { decompressStream } from '@xingrz/cppzst';
import { createReadStream, createWriteStream } from 'fs';
createReadStream('path/to/input')
.pipe(decompressStream())
.pipe(createWriteStream('path/to/output'));The compress, compressSync and compressStream methods may accept an optional zstdCompressParams object to define compress level and/or dict.
const zstdCompressParams = {
level: 5, // default 1
dict: new Buffer('hello zstd'), // if dict null, left level only.
dictSize: dict.length, // if dict null, left level only.
};The decompress, decompressSync and decompressStream methods may accept an optional zstdDecompressParams object to define dict.
const zdtdDecompressParams = {
dict: new Buffer('hello zstd'),
dictSize: dict.length,
};$ npm testMIT

