Skip to content

temtum/zstd-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zstd-lib version ZSTD/v1.4.3

Zstd wrapper for Nodejs

Installation

$ npm install zstd-lib --save

Usage

Async

compress(buffer[, zstdCompressParams], callback)

const compress = require('zstd-lib').compress;

compress(input, function(err, output)) {
  // ...
};

decompress(buffer[, zstdDecompressParams], callback)

const decompress = require('zstd-lib').decompress;

decompress(input, function(err, output) {
  // ...
});

Sync

compressSync(buffer[, zstdCompressParams])

const compressSync = require('zstd-lib').compressSync;

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

decompressSync(buffer[, zstdCompressParams])

const decompressSync = require('zstd-lib').decompressSync;

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

Stream

compressStream([zstdCompressParams])

const compressStream = require('zstd-lib').compressStream;
const fs = require('fs');

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

decompressStream([zstdCompressParams])

const decompressStream = require('zstd-lib').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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published