Skip to content

BrotliCompressDictContext

Defined in: index.d.ts:14

Streaming brotli compression context with custom dictionary, in one of two modes:

  • By default, it buffers its input: transform() and flush() return an empty buffer, and finish() compresses all of the input with the dictionary, into the output of brotliCompressWithDict().
  • With { incremental: true }, it holds at most the first 4 MiB less 16 bytes of input (4,194,288 bytes, as far as brotli refers back to the dictionary), which compress with the dictionary into the output of brotliCompressWithDict() if the input ends there. A longer input is compressed with the dictionary too, as it arrives: the transform() that takes the input past those bytes returns their output, and from then on, transform() returns the output that the encoder has emitted, flush() all the output of the input so far, and finish() the rest of the stream. The stream helpers use this mode.

new BrotliCompressDictContext(dict, quality?, options?): BrotliCompressDictContext

Defined in: index.d.ts:182

quality defaults to 6. options.incremental selects the incremental mode; options must be an object, undefined or null.

Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

number | null

StreamContextOptions | null

BrotliCompressDictContext

[dispose](): void

Defined in: index.d.ts:16

Close the context, like close(): using declarations call it.

void


close(): void

Defined in: index.d.ts:210

Release the native state of the context now rather than when the context is garbage-collected. Later calls throw, and finish() releases the state too. Closing a finished or closed context does nothing. [Symbol.dispose]() is the same method, for using declarations.

void


finish(): Buffer

Defined in: index.d.ts:202

Finalize the compression and return the rest of the output: all of it, compressed from the input that the context holds, if it holds the input. Must be called once after all data has been transformed.

Buffer


finishAsync(): Promise<Buffer<ArrayBufferLike>>

Defined in: index.d.ts:253

finish() on the libuv thread pool: returns a Promise of the rest of the output, and reports every error by rejecting it. The native state is released once the call has run, whether it succeeded or not. In the browser build, it runs synchronously, on the calling thread.

At most one asynchronous call may be in flight per context: until its Promise settles, another asynchronous call rejects and a synchronous call throws <name> is busy: an asynchronous call has not finished. After close(), calls reject with <name> already closed.

Promise<Buffer<ArrayBufferLike>>


flush(): Buffer

Defined in: index.d.ts:196

Return an empty buffer while the context holds its input, as it always does by default. Incremental, once the input has passed the first 4,194,288 bytes, flush the encoder and return all the output of the input so far.

Buffer


flushAsync(): Promise<Buffer<ArrayBufferLike>>

Defined in: index.d.ts:239

flush() on the libuv thread pool: returns a Promise of the output, and reports every error by rejecting it. In the browser build, it runs synchronously, on the calling thread.

At most one asynchronous call may be in flight per context: until its Promise settles, another asynchronous call rejects and a synchronous call throws <name> is busy: an asynchronous call has not finished. After close(), calls reject with <name> already closed.

Promise<Buffer<ArrayBufferLike>>


transform(chunk): Buffer

Defined in: index.d.ts:189

Take a chunk of data. By default, keep it and return an empty buffer: the output comes from finish(). Incremental, return the output that is ready, which is empty while the context holds its input.

Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

Buffer


transformAsync(chunk): Promise<Buffer<ArrayBufferLike>>

Defined in: index.d.ts:227

transform(chunk) on the libuv thread pool: returns a Promise of the output, and reports every error, an invalid argument included, by rejecting it. The chunk is copied before the method returns, so the caller may reuse its memory at once. In the browser build, it runs synchronously, on the calling thread.

At most one asynchronous call may be in flight per context: until its Promise settles, another asynchronous call rejects and a synchronous call throws <name> is busy: an asynchronous call has not finished, such as zstd stream is busy: an asynchronous call has not finished. close() while a call is in flight releases the native state once the call settles, and its Promise still settles. After close(), calls reject with <name> already closed.

Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

Promise<Buffer<ArrayBufferLike>>