Zstd wrapper for Nodejs
Go to file
2023-04-27 10:45:30 -03:00
.github/workflows Add exports and Gh Actions, removed packages 2023-04-27 10:45:30 -03:00
deps update zstd 2023-04-14 12:44:38 +08:00
src fix node14 2020-08-25 17:01:38 +08:00
test bump zstd version to 1.3.4 2018-09-21 02:47:22 -04:00
.gitignore Add exports and Gh Actions, removed packages 2023-04-27 10:45:30 -03:00
.gitmodules master 2020-08-27 17:00:56 +08:00
binding.gyp 2023-04-14 14:37:43 +08:00
dist.sh 2.0.8 2023-04-14 12:45:01 +08:00
index.cjs Add exports and Gh Actions, removed packages 2023-04-27 10:45:30 -03:00
index.d.ts Add exports and Gh Actions, removed packages 2023-04-27 10:45:30 -03:00
index.mjs Add exports and Gh Actions, removed packages 2023-04-27 10:45:30 -03:00
LICENSE Initial commit 2016-08-18 10:41:01 +08:00
package.json Add exports and Gh Actions, removed packages 2023-04-27 10:45:30 -03:00
README.md 2.0.6 2020-10-28 11:09:48 +08:00

cppzst version ZSTD/v1.3.4

Build Status

Zstd wrapper for Nodejs

Installation

$ npm install cppzst --save

Usage

Async

compress(buffer[, zstdCompressParams], callback)

import {compress} from 'cppzst';

await compress(input);

decompress(buffer[, zstdDecompressParams], callback)

import {decompress} from 'cppzst';

await decompress(input)

Sync

compressSync(buffer[, zstdCompressParams])

const compressSync = require('cppzst').compressSync;

try {
  var output = compressSync(input);
} catch(err) {
  // ...
}

decompressSync(buffer[, zstdCompressParams])

const decompressSync = require('cppzst').decompressSync;

try {
  var output = decompressSync(input);
} catch(err) {
  // ...
}

Stream

compressStream([zstdCompressParams])

const compressStream = require('cppzst').compressStream;
const fs = require('fs');

fs.createReadStream('path/to/input')
  .pipe(compressStream())
  .pipe(fs.createWriteStream('path/to/output'));

decompressStream([zstdCompressParams])

const decompressStream = require('cppzst').decompressStream;
const fs = require('fs');

fs.createReadStream('path/to/input')
  .pipe(decompressStream())
  .pipe(fs.createWriteStream('path/to/output'));

ZSTD Params

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
};

Tests

$ npm test

License

MIT