Firemitt - v0.1.9
    Preparing search index...

    Class Base64helper

    Helper class for Base64 encoding and decoding of messages.

    This class provides static methods to encode and decode messages using Base64 encoding. It is designed to work with TMessage type, allowing for serialization and deserialization of messages.

    Index
    • Decodes a Base64 string back into a message.

      This static method takes a Base64 encoded string and decodes it back into a message of type TMessage<T>. It first decodes the Base64 string into a JSON string, and then parses this JSON string back into a message object.

      Type Parameters

      • T = unknown

        The expected type of the payload in the decoded message.

      Parameters

      • base64: string

        The Base64 encoded string to be decoded.

      Returns TMessage<T>

      The decoded message object.

      If the input is not a string, or does not decode to a message object with a numeric type.

    • Encodes a message into a Base64 string.

      The message is stringified into JSON, every non-ASCII character is escaped as a JSON \uXXXX sequence (so btoa never throws on characters such as emojis, Arabic or CJK text), and the result is Base64 encoded. The output can be decoded by any version of Base64helper.decode.

      Type Parameters

      • T = unknown

        The type of the payload in the message.

      Parameters

      • message: TMessage<T>

        The message to be encoded.

      Returns string

      The Base64 encoded string representation of the message.