Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Encoder

Hierarchy

  • Encoder

Index

Constructors

constructor

  • new Encoder(protos: any): Encoder

Properties

protos

protos: any

Methods

checkMsg

  • checkMsg(msg: object, protos: object): boolean
  • Check if the msg follow the defination in the protos

    Parameters

    • msg: object
      • [key: string]: any
    • protos: object
      • [key: string]: any

    Returns boolean

encode

  • encode(route: string, msg: object): Buffer
  • Parameters

    • route: string
    • msg: object
      • [key: string]: any

    Returns Buffer

encodeArray

  • encodeArray(array: Array<number>, proto: object, offset: number, buffer: Buffer, protos: object): number
  • Encode reapeated properties, simple msg and object are decode differented

    Parameters

    • array: Array<number>
    • proto: object
      • [key: string]: any
    • offset: number
    • buffer: Buffer
    • protos: object
      • [key: string]: any

    Returns number

encodeMsg

  • encodeMsg(buffer: Buffer, offset: number, protos: object, msg: object): number
  • Parameters

    • buffer: Buffer
    • offset: number
    • protos: object
      • [key: string]: any
    • msg: object
      • [key: string]: any

    Returns number

encodeProp

  • encodeProp(value: any, type: string, offset: number, buffer: Buffer, protos?: object): number
  • Parameters

    • value: any
    • type: string
    • offset: number
    • buffer: Buffer
    • Optional protos: object
      • [key: string]: any

    Returns number

encodeTag

  • encodeTag(type: "string" | "uInt32" | "sInt32" | "int32" | "float" | "double" | "message", tag: number): number[]
  • Parameters

    • type: "string" | "uInt32" | "sInt32" | "int32" | "float" | "double" | "message"
    • tag: number

    Returns number[]

init

  • init(protos: any): void

writeBytes

  • writeBytes(buffer: Buffer, offset: number, bytes: Array<number>): number
  • Parameters

    • buffer: Buffer
    • offset: number
    • bytes: Array<number>

    Returns number