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
↳
ZlibEncoder
Constructors
constructor
• Protected new ZlibEncoder(type)
Constructs a new Encoder instance.
Parameters
| Name | Type | Description |
|---|---|---|
type | string | The encoding format this encoder object was instanciated for. |
Inherited from
Defined in
Properties
type
• Readonly type: string
The encoding format this encoder object was instanciated for.
Inherited from
Defined in
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
| Name | Type | Description |
|---|---|---|
stream | AsyncIterable<Buffer> | The stream to decode. |
Returns
AsyncIterable<Buffer>
The decoded stream.
Overrides
Defined in
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
| Name | Type | Description |
|---|---|---|
stream | AsyncIterable<Buffer> | The stream to encode. |
Returns
AsyncIterable<Buffer>
The encoded stream.
Overrides
Defined in
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
| Name | Type | Description |
|---|---|---|
stream | string | Buffer | AsyncIterable<Buffer> | The data to encode. If a string, it will first converted to UTF-8. |
types | string | 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
Defined in
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
| Name | Type | Description |
|---|---|---|
stream | string | Buffer | AsyncIterable<Buffer> | The data to encode. If a string, it will first converted to UTF-8. |
types | string | 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
Defined in
register
▸ Static register(type, encoder): typeof Encoder
Registers a new encoder. All subclasses must register their encoding type support with this method.
Parameters
| Name | Type | Description |
|---|---|---|
type | string | The encoding format the encoder can handle. |
encoder | typeof Encoder | The Encoder subclass to register. |
Returns
typeof Encoder
The Encoder base class (for method chaining).