JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 149
  • Score
    100M100P100Q89070F
  • License MIT

Zstd binding for Nodejs, with TypeScript support.

Package Exports

  • @skhaz/zstd
  • @skhaz/zstd/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@skhaz/zstd) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@skhaz/zstd

license issues stars commits

Zstd binding for Nodejs, with TypeScript 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