an enum entry to be used as a child of an SEnum schema node. this schema node's value must be a 2-tuple array with the first element (of type T) being the javascript value, and the second element (of type Uint8Array) being its corresponding bytes

Type Parameters

  • T extends JSPrimitive | undefined

Hierarchy

  • SchemaNode<[T, Uint8Array], "enumentry">
    • SEnumEntry

Properties

from: ((schema_obj: ClassFieldsOf<any>) => any) = ...

Type declaration

    • (schema_obj: ClassFieldsOf<any>): any
    • an abstract static method that creates an instance of this schema class, using a regular javascript object

      Parameters

      • schema_obj: ClassFieldsOf<any>

      Returns any

name?: string

name of the node, used for object property key naming by parent SchemaRecordNode

children?: SchemaChildNode<any, string>[]

an array collection of child element. typically used by non-leaf nodes, such as SchemaRecordNode and SchemaTupleNode

args: any[] = []

args that should be passed on to either the type specific encoder or decoder

doc?: string | true

an optional doc string for this schema node, that should be cleared when MINIFY is true
to achive that, you would want to write your doc strings as follows:

declare const [DEBUG, MINIFY, BUNDLE]: [boolean, boolean, boolean]
const my_schema_node: SPrimitive<number> {
type: "u4l",
doc: MINIFY || "a stupid description of this 32-bit unsinged little piece of endian."
}
type: "enumentry"

a mandatory kind descriptior of the primitive kind

value: [T, Uint8Array]

the value held by this schema node. used as a storage for interceptors to interact and read decoded value
it can also used as a means for storing default values for the encoder to utilize.
but besides those two scenarios, it should typically be left unassigned.
this also comes in handy when annotating types both for the encoder or decoder

Methods

  • manually set this schema's type to the provided type_name, and also register the new type_name to global type_registery if register = true.
    this is the only easy way to register type_names of sub-sub-classes of abstract SchemaNode.
    check out SHeadArray to see how it extends SArray, but registers its own type_name = "headarray" that's different from its parent class's type_name = "array"

    Type Parameters

    • NewTypeName extends string

    Parameters

    • type_name: NewTypeName
    • register: boolean = true

    Returns SEnumEntry<T> & {
        type: NewTypeName;
    }

  • Type Parameters

    • Name extends string

    Parameters

    • name: Name

    Returns SEnumEntry<T> & {
        name: Name;
    }

  • Parameters

    • value: [T, Uint8Array]

    Returns Require<SEnumEntry<T>, "value">

  • this functionality is made into a method instead of being embeded into SEnum.decode mainly so that it's possible to subclass it

    Returns

    true if the bytes in the provided buffer and offset match with this enum entry's bytes, else the result is false

    Parameters

    • buffer: Uint8Array
    • offset: number
    • Rest ...args: any[]

    Returns boolean

  • this functionality is made into a method instead of being embeded into SEnum.encode mainly so that it's possible to subclass it

    Returns

    true if the provided value matches with this enum entry's value, else the result is false

    Parameters

    • value: T
    • Rest ...args: any[]

    Returns boolean

  • describe how an instance of this schema node should be encoded into bytes

    Parameters

    • Optional value: T
    • Rest ...args: any[]

    Returns Uint8Array

  • describe bytes from a buffer should decode a value for this schema node

    Parameters

    • buffer: Uint8Array
    • offset: number
    • Rest ...args: any[]

    Returns Decoded<T, number>

Constructors

  • Type Parameters

    • T extends undefined | JSPrimitive

    Parameters

    • enum_value: T
    • enum_bytes: number[] | Uint8Array

    Returns SEnumEntry<T>

Generated using TypeDoc