CompressionStream
Defined in: next/api.d.ts:508
A ponyfill of CompressionStream of the Compression Streams standard: it
compresses the chunks written to its CompressionStream.writable
side into the chunks read from its CompressionStream.readable
side, in any Format and with the options of compress.
Pipe data through it with pipeThrough(). It neither replaces nor uses
the global CompressionStream.
The chunks written may be any Input, read as the functions read
their data: bytes in a SharedArrayBuffer are copied first. A chunk of any
other type errors the stream with ERR_COMPRS_INVALID_ARG, and so does a
detached buffer. The chunks read are Bytes, which together hold
the compressed data: their sizes follow the codec, not the chunks
written. 'deflate' is the zlib format, as in the standard.
In Node.js, a chunk that the stream predicts to take 2 ms or more is
compressed on a thread of the libuv pool, so that it does not block the
event loop, and cheaper ones on the calling thread, which yields to the
event loop every few milliseconds, as the stream helpers of the package
root do. The browser build compresses each chunk on the calling thread.
Errors of the codec error the stream, with an ErrorCode as
code.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CompressionStream(
format,options?):CompressionStream
Defined in: next/api.d.ts:517
Create a stream that compresses in format, with options, which are
checked here, as compressSync checks them.
Parameters
Section titled “Parameters”format
Section titled “format”options?
Section titled “options?”Returns
Section titled “Returns”CompressionStream
Throws
Section titled “Throws”An error with an ErrorCode as code, such as
ERR_COMPRS_INVALID_ARG for an unknown format or an invalid option.
Accessors
Section titled “Accessors”[toStringTag]
Section titled “[toStringTag]”Get Signature
Section titled “Get Signature”get [toStringTag]():
string
Defined in: next/api.d.ts:522
Returns
Section titled “Returns”string
readable
Section titled “readable”Get Signature
Section titled “Get Signature”get readable():
ReadableStream<Uint8Array<ArrayBuffer>>
Defined in: next/api.d.ts:519
The side to read the compressed data from.
Returns
Section titled “Returns”ReadableStream<Uint8Array<ArrayBuffer>>
writable
Section titled “writable”Get Signature
Section titled “Get Signature”get writable():
WritableStream<Input>
Defined in: next/api.d.ts:521
The side to write the data to compress to.
Returns
Section titled “Returns”WritableStream<Input>