Skip to content

Class: Tuple ​

Represents a sequence of TupleFields, typically used for hierarchical paths or protocol tuples in MOQT.

Constructors ​

Constructor ​

new Tuple(fields?): Tuple

The ordered list of fields in this tuple.

Parameters ​

fields? ​

TupleField[] = []

Returns ​

Tuple

Properties ​

fields ​

readonly fields: TupleField[] = []

Methods ​

add() ​

add(field): void

Adds a field to the tuple.

Parameters ​

field ​

TupleField

The TupleField to add.

Returns ​

void


clear() ​

clear(): void

Clears all fields from the tuple.

Returns ​

void


equals() ​

equals(other): boolean

Checks if this tuple is equal to another.

Parameters ​

other ​

Tuple

The other Tuple to compare.

Returns ​

boolean

True if all fields are equal.


get() ​

get(index): TupleField

Gets the field at the specified index.

Parameters ​

index ​

number

The field index.

Returns ​

TupleField

The TupleField at the index.

Throws ​

Error if no field exists at the index.


serialize() ​

serialize(): FrozenByteBuffer

Serializes the tuple to a FrozenByteBuffer.

Returns ​

FrozenByteBuffer

The serialized buffer.


set() ​

set(index, field): void

Sets the field at the specified index.

Parameters ​

index ​

number

The field index.

field ​

TupleField

The TupleField to set.

Returns ​

void


toUtf8Path() ​

toUtf8Path(): string

Converts the tuple to a path string, joining fields with '/'.

Returns ​

string

The path string (e.g. '/foo/bar').


deserialize() ​

static deserialize(buf): Tuple

Deserializes a Tuple from a buffer.

Parameters ​

buf ​

BaseByteBuffer

The buffer to read from.

Returns ​

Tuple

The deserialized Tuple.

Throws ​

CastingError if the count cannot be safely cast to number.

Throws ​

NotEnoughBytesError if buffer does not contain enough bytes.


fromUtf8Path() ​

static fromUtf8Path(path): Tuple

Creates a Tuple from a path string, splitting on '/'.

Parameters ​

path ​

string

The path string (e.g. '/foo/bar').

Returns ​

Tuple

A Tuple with each segment as a field.