Skip to main content

Class: ZlibEncoder

@divine/uri.ZlibEncoder

The br, gzip, x-gzip and deflate encoder applies or removes various zlib-related encodings to the provided byte stream.

Hierarchy

Constructors

constructor

Protected new ZlibEncoder(type)

Constructs a new Encoder instance.

Parameters

NameTypeDescription
typestringThe encoding format this encoder object was instanciated for.

Inherited from

Encoder.constructor

Defined in

uri/src/encoders.ts:114

Properties

type

Readonly type: string

The encoding format this encoder object was instanciated for.

Inherited from

Encoder.type

Defined in

uri/src/encoders.ts:114

Methods

decode

decode(stream): AsyncIterable<Buffer>

Decodes the provided byte stream into an new byte stream.

This method must be implemented by the actual subclass.

Throws

EncoderError On decoding errors.

Parameters

NameTypeDescription
streamAsyncIterable<Buffer>The stream to decode.

Returns

AsyncIterable<Buffer>

The decoded stream.

Overrides

Encoder.decode

Defined in

uri/src/encoders.ts:310


encode

encode(stream): AsyncIterable<Buffer>

Encodes the provided byte stream into an new byte stream.

This method must be implemented by the actual subclass.

Throws

EncoderError On encoding errors.

Parameters

NameTypeDescription
streamAsyncIterable<Buffer>The stream to encode.

Returns

AsyncIterable<Buffer>

The encoded stream.

Overrides

Encoder.encode

Defined in

uri/src/encoders.ts:300


decode

Static decode(stream, types): Readable & AsyncIterable<Buffer>

Decodes the provided stream using one or more encoders.

Throws

EncoderError On decoding errors or if the encoding format is not recognized.

Parameters

NameTypeDescription
streamstring | Buffer | AsyncIterable<Buffer>The data to encode. If a string, it will first converted to UTF-8.
typesstring | string[]An encoding format or an ordered list of encoding formats to apply (in reverse!) to the stream. A list may either be a comma-separated string or an array of strings.

Returns

Readable & AsyncIterable<Buffer>

An encoded byte stream.

Inherited from

Encoder.decode

Defined in

uri/src/encoders.ts:80


encode

Static encode(stream, types): Readable & AsyncIterable<Buffer>

Encodes the provided stream using one or more encoders.

Throws

EncoderError On encoding errors or if the encoding format is not recognized.

Parameters

NameTypeDescription
streamstring | Buffer | AsyncIterable<Buffer>The data to encode. If a string, it will first converted to UTF-8.
typesstring | string[]An encoding format or an ordered list of encoding formats to apply to the stream. A list may either be a comma-separated string or an array of strings.

Returns

Readable & AsyncIterable<Buffer>

An encoded byte stream.

Inherited from

Encoder.encode

Defined in

uri/src/encoders.ts:55


register

Static register(type, encoder): typeof Encoder

Registers a new encoder. All subclasses must register their encoding type support with this method.

Parameters

NameTypeDescription
typestringThe encoding format the encoder can handle.
encodertypeof EncoderThe Encoder subclass to register.

Returns

typeof Encoder

The Encoder base class (for method chaining).

Inherited from

Encoder.register

Defined in

uri/src/encoders.ts:41