3.0.1 • Published 2 months ago

@itk-wasm/compress-stringify v3.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

@itk-wasm/compress-stringify

npm version

Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.

👨‍💻 Live API Demo

🕮 Documentation 📚

Installation

npm install @itk-wasm/compress-stringify

Usage

Browser interface

Import:

import {
  compressStringify,
  parseStringDecompress,
  setPipelinesBaseUrl,
  getPipelinesBaseUrl,
} from "@itk-wasm/compress-stringify"

Functions

compressStringify

Given a binary, compress and optionally base64 encode.

async function compressStringify(
  input: Uint8Array,
  options: CompressStringifyOptions = {}
) : Promise<CompressStringifyResult>
ParameterTypeDescription
inputUint8ArrayInput binary

CompressStringifyOptions interface:

PropertyTypeDescription
stringifybooleanStringify the output
compressionLevelnumberCompression level, typically 1-9
dataUrlPrefixstringdataURL prefix
webWorkernull or Worker or booleanWebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

CompressStringifyResult interface:

PropertyTypeDescription
outputUint8ArrayOutput compressed binary
webWorkerWorkerWebWorker used for computation.

parseStringDecompress

Given a binary or string produced with compress-stringify, decompress and optionally base64 decode.

async function parseStringDecompress(
  input: Uint8Array,
  options: ParseStringDecompressOptions = {}
) : Promise<ParseStringDecompressResult>
ParameterTypeDescription
inputUint8ArrayCompressed input

ParseStringDecompressOptions interface:

PropertyTypeDescription
parseStringbooleanParse the input string before decompression
webWorkernull or Worker or booleanWebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

ParseStringDecompressResult interface:

PropertyTypeDescription
outputUint8ArrayOutput decompressed binary
webWorkerWorkerWebWorker used for computation.

setPipelinesBaseUrl

Set base URL for WebAssembly assets when vendored.

function setPipelinesBaseUrl(
  baseUrl: string | URL
) : void

getPipelinesBaseUrl

Get base URL for WebAssembly assets when vendored.

function getPipelinesBaseUrl() : string | URL

Node interface

Import:

import {
  compressStringifyNode,
  parseStringDecompressNode,
} from "@itk-wasm/compress-stringify"

compressStringifyNode

Given a binary, compress and optionally base64 encode.

async function compressStringifyNode(
  input: Uint8Array,
  options: CompressStringifyNodeOptions = {}
) : Promise<CompressStringifyNodeResult>
ParameterTypeDescription
inputUint8ArrayInput binary

CompressStringifyNodeOptions interface:

PropertyTypeDescription
stringifybooleanStringify the output
compressionLevelnumberCompression level, typically 1-9
dataUrlPrefixstringdataURL prefix

CompressStringifyNodeResult interface:

PropertyTypeDescription
outputUint8ArrayOutput compressed binary

parseStringDecompressNode

Given a binary or string produced with compress-stringify, decompress and optionally base64 decode.

async function parseStringDecompressNode(
  input: Uint8Array,
  options: ParseStringDecompressNodeOptions = {}
) : Promise<ParseStringDecompressNodeResult>
ParameterTypeDescription
inputUint8ArrayCompressed input

ParseStringDecompressNodeOptions interface:

PropertyTypeDescription
parseStringbooleanParse the input string before decompression

ParseStringDecompressNodeResult interface:

PropertyTypeDescription
outputUint8ArrayOutput decompressed binary
3.0.1

2 months ago

3.0.0

4 months ago

2.0.3

5 months ago

2.0.2

5 months ago

0.5.3

9 months ago

2.0.1

6 months ago

0.6.1

8 months ago

0.5.2

9 months ago

2.0.0

6 months ago

0.6.0

8 months ago

0.5.1

9 months ago

0.4.5

1 year ago

0.5.0

12 months ago

0.4.4

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago