Interface Configuration

Represents the configuration passed to configure.

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

Hierarchy (view full)

Properties

CompressionStream?: typeof TransformStreamLike

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

Default Value

{@link CodecStream}
DecompressionStream?: typeof TransformStreamLike

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

Default Value

{@link CodecStream}
Deflate?: typeof ZipDeflate

The codec implementation used to compress data.

Default Value

{@link ZipDeflate}
Inflate?: typeof ZipInflate

The codec implementation used to decompress data.

Default Value

{@link ZipInflate}
chunkSize?: number

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

Default Value

524288
maxWorkers?: number

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

Default Value

navigator.hardwareConcurrency

terminateWorkerTimeout?: number

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

Default Value

5000
useCompressionStream?: boolean

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

Default Value

true
useWebWorkers?: boolean

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

Default Value

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

  • Optional deflate?: string[]

    The URIs of the scripts implementing used for compression.

  • Optional inflate?: string[]

    The URIs of the scripts implementing used for decompression.