TOC Toolkit API - v0.1.0
    Preparing search index...

    Interface Codec<T>

    A stored format of a value. decode reads data that crossed a trust boundary, so it returns a Result. A codec obeys two laws. Decoding what encode wrote gives the value back. Encoding what decode read and decoding the result again gives the same value.

    Both members are functions that work on their own, so decode serves as the decoder of a field of a larger format.

    interface Codec<T> {
        encode: (value: T) => JsonValue;
        decode: Decoder<T>;
    }

    Type Parameters

    • T
    Index
    encode: (value: T) => JsonValue
    decode: Decoder<T>