Skip to main content

Class: Base64Encoder

@divine/uri.Base64Encoder

The base64 and base64url encoder applies or removes the Base64 encodings to the provided byte stream. When encoding, lines will never be wider than 64 characters.

Hierarchy​

Constructors​

constructor​

• Protected new Base64Encoder(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:278


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:236


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