JSPM

  • Created
  • Published
  • Downloads 123
  • Score
    100M100P100Q88967F
  • License MIT

Zstd n-api addon for node.js & wasm for browsers.

Package Exports

  • @cloudpss/zstd
  • @cloudpss/zstd/config
  • @cloudpss/zstd/napi
  • @cloudpss/zstd/package.json
  • @cloudpss/zstd/wasm

Readme

@cloudpss/zstd

This is a pure esm package contains the zstd n-api addon for node.js & wasm for browsers.

Installation

npm install @cloudpss/zstd

Usage

import { compress, decompress } from '@cloudpss/zstd';

const compressed = compress(Buffer.from('Hello World!'));
const decompressed = decompress(compressed);

console.log(decompressed.toString()); // Hello World!

To explicitly use the wasm or the n-api version, import @cloudpss/zstd/wasm and @cloudpss/zstd/napi respectively.

API

compress(input: BinaryData, level?: number): Buffer

Compresses the input buffer with the given compression level (default: 4).

decompress(input: BinaryData): Buffer

Decompresses the input buffer.

Notice: If you are using this library in a browser, the Buffer classes is replaced with Uint8Array classes.