Zstd (Zstandard) binding for Nodejs, with TypeScript, AMD64 & ARM64 support.
$ npm install @skhaz/zstd --save
import { compress } from '@skhaz/zstd'
try {
const output = await compress(input)
} catch (err) {
// ...
}
import { decompress } from '@skhaz/zstd'
try {
const output = await decompress(input)
} catch (err) {
// ...
}
import { compressSync } from '@skhaz/zstd'
try {
const output = compressSync(input)
} catch (err) {
// ...
}
import { decompressSync } from '@skhaz/zstd'
try {
const output = decompressSync(input)
} catch (err) {
// ...
}
import { compressStream } from '@skhaz/zstd'
import { createReadStream, createWriteStream } from 'fs'
createReadStream('path/to/input').pipe(compressStream()).pipe(createWriteStream('path/to/output'))
import { decompressStream } from '@skhaz/zstd'
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 test
MIT