0.3.0 • Published 1 year ago

itk-compress-stringify v0.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

itk-compress-stringify

npm version

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

Example

Documentation

Installation

npm install itk-compress-stringify

Usage

Browser interface

Import:

import {
  compressStringify,
  parseStringDecompress,
  setPipelinesBaseUrl,
  getPipelinesBaseUrl,
  setPipelineWorkerUrl,
  getPipelineWorkerUrl,
} from "itk-compress-stringify"

Functions

compressStringify

Given a binary, compress and optionally base64 encode.

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

CompressStringifyOptions interface:

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

CompressStringifyResult interface:

PropertyTypeDescription
webWorkerWorkerWebWorker used for computation
outputUint8ArrayOutput compressed binary

parseStringDecompress

Given a binary or string produced with compressStringify, decompress and optionally base64 decode.

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

ParseStringDecompressOptions interface:

PropertyTypeDescription
parseStringbooleanParse the input string before decompression

ParseStringDecompressResult interface:

PropertyTypeDescription
webWorkerWorkerWebWorker used for computation
outputUint8ArrayOutput decompressed binary

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

setPipelineWorkerUrl

Set base URL for the itk-wasm pipeline worker script when vendored.

function setPipelineWorkerUrl(
  baseUrl: string | URL
) : void

getPipelineWorkerUrl

Get base URL for the itk-wasm pipeline worker script when vendored.

function getPipelineWorkerUrl() : string | URL

Node interface

Import:

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

compressStringifyNode

Given a binary, compress and optionally base64 encode.

async function compressStringifyNode(
  input: Uint8Array,
  options: CompressStringifyOptions = {}
) : 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 CompressedStringify, decompress and optionally base64 decode.

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

ParseStringDecompressNodeOptions interface:

PropertyTypeDescription
parseStringbooleanParse the input string before decompression

ParseStringDecompressNodeResult interface:

PropertyTypeDescription
outputUint8ArrayOutput decompressed binary
0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago