Options
All
  • Public
  • Public/Protected
  • All
Menu

K stands for Konstruct

Helper for constructing xml-like javascript object.

Index

Functions

Functions

  • ARRAY<S>(type: S, content: Buffer, attr?: KAttrMap): KARRAY<S>
  • ARRAY<S>(type: S, content: number[], attr?: KAttrMap): KARRAY<S>
  • ARRAY<S>(type: S, content: bigint[], attr?: KAttrMap): KARRAY<S>
  • Example:

    {
    tag: K.ARRAY('s32', [1, 2, 3], {attr: "4"})
    }

    Represents:

    <tag __type="s32" __count="3" attr="2">1 2 3</tag>
    

    Type parameters

    • S: "s8" | "u8"

    Parameters

    • type: S

      __type attribute, which is used during encoding and compression

    • content: Buffer

      array of data, __count attribute will be automatically set to content.length

    • Optional attr: KAttrMap

      attribute map in addition to __type and __count

    Returns KARRAY<S>

  • Type parameters

    Parameters

    • type: S
    • content: number[]
    • Optional attr: KAttrMap

    Returns KARRAY<S>

  • Type parameters

    Parameters

    • type: S
    • content: bigint[]
    • Optional attr: KAttrMap

    Returns KARRAY<S>

  • ATTR<M, T>(attr: M, inner?: T): KATTR<M> & T
  • Example:

    {
    tag: K.ATTR({attr: "1"}, {
    inner: [{}, {}]
    })
    }

    Represents:

    <tag attr="1">
    <inner/>
    <inner/>
    </tag>

    Type parameters

    Parameters

    • attr: M

      Attribute map

    • Optional inner: T

      Inner tag/data

    Returns KATTR<M> & T

  • ITEM(type: "str", content: string, attr?: KAttrMap): KITEM<"str">
  • ITEM(type: "bin", content: Buffer, attr?: KAttrMap): KITEM<"bin">
  • ITEM(type: "ip4", content: string, attr?: KAttrMap): KITEM<"ip4">
  • ITEM(type: "bool", content: boolean, attr?: KAttrMap): KITEM<"bool">
  • ITEM<S>(type: S, content: number, attr?: KAttrMap): KITEM<S>
  • ITEM<S>(type: S, content: bigint, attr?: KAttrMap): KITEM<S>
  • ITEM<S>(type: S, content: number[], attr?: KAttrMap): KITEM<S>
  • ITEM<S>(type: S, content: bigint[], attr?: KAttrMap): KITEM<S>

Generated using TypeDoc