Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OctetsType

A type storing a variable-length array of bytes. This is intended for data that doesn't fit any other category, e.g. the contents of a PNG file.

Example:

let type = new sb.OctetsType

Hierarchy

  • AbsoluteType<ArrayBuffer | Uint8Array, ArrayBuffer>
    • OctetsType

Index

Constructors

constructor

  • Returns OctetsType

Accessors

Static _value

  • get _value(): number

Methods

addToBuffer

consumeValue

  • consumeValue(buffer: ArrayBuffer, offset: number): ReadResult<ArrayBuffer>
  • Parameters

    • buffer: ArrayBuffer
    • offset: number

    Returns ReadResult<ArrayBuffer>

equals

  • equals(otherType: unknown): boolean
  • Parameters

    • otherType: unknown

    Returns boolean

getHash

  • getHash(): string

getSignature

  • getSignature(): string

Private isBuffer

Private isSameType

  • isSameType(otherType: unknown): otherType is OctetsType
  • Determines whether the input is a Type with the same class

    Parameters

    • otherType: unknown

      A value, usually a Type instance

    Returns otherType is OctetsType

    whether this and otherType are instances of the same Type class

readValue

  • readValue(valueBuffer: ArrayBuffer | Uint8Array, offset?: number): ArrayBuffer
  • Parameters

    • valueBuffer: ArrayBuffer | Uint8Array
    • offset: number = 0

    Returns ArrayBuffer

toBuffer

  • toBuffer(): ArrayBuffer

valueBuffer

  • valueBuffer(value: ArrayBuffer | Uint8Array): ArrayBuffer
  • Parameters

    • value: ArrayBuffer | Uint8Array

    Returns ArrayBuffer

writeValue

  • Appends value bytes to an AppendableBuffer according to the type

    Example:

    let octets = new Uint8Array([1, 2, 3, 4, 5])
    type.writeValue(buffer, octets)
    // or
    type.writeValue(buffer, octets.buffer)
    
    throws

    If the value doesn't match the type, e.g. new sb.StringType().writeValue(buffer, 23)

    Parameters

    • buffer: AppendableBuffer

      The buffer to which to append

    • value: ArrayBuffer | Uint8Array

      The value to write

    Returns void

Generated using TypeDoc