1.0.21 • Published 1 month ago

@skhaz/zstd v1.0.21

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@skhaz/zstd

license issues stars commits

Zstd (Zstandard) binding for Nodejs, with TypeScript, AMD64 & ARM64 support.

Installation

$ npm install @skhaz/zstd --save

Usage

Async

compress(buffer, zstdCompressParams)

import { compress } from '@skhaz/zstd'

try {
  const output = await compress(input)
} catch (err) {
  // ...
}

decompress(buffer, zstdDecompressParams)

import { decompress } from '@skhaz/zstd'

try {
  const output = await decompress(input)
} catch (err) {
  // ...
}

Sync

compressSync(buffer, zstdCompressParams)

import { compressSync } from '@skhaz/zstd'

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

decompressSync(buffer, zstdCompressParams)

import { decompressSync } from '@skhaz/zstd'

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

Stream

compressStream(zstdCompressParams)

import { compressStream } from '@skhaz/zstd'
import { createReadStream, createWriteStream } from 'fs'

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

decompressStream(zstdCompressParams)

import { decompressStream } from '@skhaz/zstd'
import { createReadStream, createWriteStream } from 'fs'

createReadStream('path/to/input').pipe(decompressStream()).pipe(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

1.0.21

1 month ago

1.0.20

1 month ago

1.0.19

8 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

10 months ago

1.0.15

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago