Interface Configuration

Represents the configuration passed to configure.

interface Configuration {
    chunkSize?: number;
    CompressionStream?: typeof TransformStreamLike;
    DecompressionStream?: typeof TransformStreamLike;
    Deflate?: typeof ZipDeflate;
    Inflate?: typeof ZipInflate;
    maxWorkers?: number;
    terminateWorkerTimeout?: number;
    useCompressionStream?: boolean;
    useWebWorkers?: boolean;
    workerScripts?: {
        deflate?: string[];
        inflate?: string[];
    };
}

Hierarchy (view full)

Properties

chunkSize?: number

The size of the chunks in bytes during data compression/decompression.

524288
CompressionStream?: typeof TransformStreamLike

The stream implementation used to compress data when useCompressionStream is set to false.

CodecStream

DecompressionStream?: typeof TransformStreamLike

The stream implementation used to decompress data when useCompressionStream is set to false.

CodecStream

Deflate?: typeof ZipDeflate

The codec implementation used to compress data.

ZipDeflate

Inflate?: typeof ZipInflate

The codec implementation used to decompress data.

ZipInflate

maxWorkers?: number

The maximum number of web workers used to compress/decompress data simultaneously.

navigator.hardwareConcurrency

terminateWorkerTimeout?: number

The delay in milliseconds before idle web workers are automatically terminated. You can call terminateWorkers() to terminate idle workers.

5000
useCompressionStream?: boolean

true to use the native API CompressionStream/DecompressionStream to compress/decompress data.

true
useWebWorkers?: boolean

true to use web workers to compress/decompress data in non-blocking background processes.

true
workerScripts?: {
    deflate?: string[];
    inflate?: string[];
}

The URIs of the compression/decompression scripts run in web workers.

It allows using alternative deflate implementations or specifying a URL to the worker script if the CSP of the page blocks scripts imported from a Blob URI. The properties deflate and inflate must specify arrays of URLs to import the deflate/inflate web workers, respectively. The first URL is relative to the base URI of the document. The other URLs are relative to the URL of the first script. Scripts in the array are executed in order. If you only use deflation or inflation, the unused deflate/inflate property can be omitted.

Here is an example:

configure({
workerScripts: {
deflate: ["library_path/custom-worker.js", "./custom-deflate.js"],
inflate: ["library_path/custom-worker.js", "./custom-inflate.js"]
}
});

If the CSP of the page blocks scripts imported from a Blob URI you can use z-worker.js from https://github.com/gildas-lormeau/zip.js/tree/master/dist and specify the URL where it can be found.

Here is an example:

configure({
workerScripts: {
deflate: ["library_path/z-worker.js"],
inflate: ["library_path/z-worker.js"]
}
});

Type declaration

  • Optionaldeflate?: string[]

    The URIs of the scripts implementing used for compression.

  • Optionalinflate?: string[]

    The URIs of the scripts implementing used for decompression.