Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TupleType<E, READ_E>

A type storing a fixed-length array of values of the same type.

Example:

//For storing a 3x3 matrix
//This represents values just as efficiently
//as a single tuple with 9 elements
let type = new sb.TupleType({
  type: new sb.TupleType({
    type: new sb.FloatType,
    length: 3
  }),
  length: 3
})

Type parameters

  • E

    The type of each element in the tuple

  • READ_E: E = E

    The type of each element in the read tuple

Hierarchy

  • AbsoluteType<E[], READ_E[]>
    • TupleType

Index

Constructors

constructor

  • Type parameters

    • E

    • READ_E = E

    Parameters

    Returns TupleType<E, READ_E>

Properties

Readonly length

length: number

The length passed to the constructor

Readonly type

type: Type<E, READ_E>

The Type passed to the constructor

Accessors

Static _value

  • get _value(): number

Methods

addToBuffer

consumeValue

  • consumeValue(buffer: ArrayBuffer, offset: number, baseValue?: READ_E[]): ReadResult<READ_E[]>
  • Parameters

    • buffer: ArrayBuffer
    • offset: number
    • Optional baseValue: READ_E[]

    Returns ReadResult<READ_E[]>

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 TupleType<E, READ_E>
  • Determines whether the input is a Type with the same class

    Parameters

    • otherType: unknown

      A value, usually a Type instance

    Returns otherType is TupleType<E, READ_E>

    whether this and otherType are instances of the same Type class

readValue

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

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

    Returns READ_E[]

toBuffer

  • toBuffer(): ArrayBuffer

valueBuffer

  • valueBuffer(value: E[]): ArrayBuffer
  • Parameters

    • value: E[]

    Returns ArrayBuffer

writeValue

  • Appends value bytes to an AppendableBuffer according to the type

    Example:

    type.writeValue(buffer, [
      [1, 2, 3],
      [4, 5, 6],
      [7, 8, 9]
    ])
    
    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: E[]

      The value to write

    Returns void

Generated using TypeDoc