---
url: https://docs.moqtail.dev/ts/api/model/classes/RequestIdMap.md
---
# Class: RequestIdMap

A bidirectional map between requestId (bigint) and full track names.
Used to efficiently look up either by requestId or by name, enforcing uniqueness.

## Constructors

### Constructor

> **new RequestIdMap**(): `RequestIdMap`

#### Returns

`RequestIdMap`

## Methods

### addMapping()

> **addMapping**(`requestId`, `name`): `void`

Adds a mapping between a requestId and a full track name.

#### Parameters

##### requestId

`bigint`

The requestId to associate.

##### name

[`FullTrackName`](FullTrackName.md)

The full track name to associate.

#### Returns

`void`

#### Throws

:[RequestIdError](RequestIdError.md) if the requestId or name is already mapped to a different value.

***

### containsName()

> **containsName**(`name`): `boolean`

Checks if the map contains a given full track name.

#### Parameters

##### name

[`FullTrackName`](FullTrackName.md)

The full track name to check.

#### Returns

`boolean`

True if the name exists, false otherwise.

***

### containsRequestId()

> **containsRequestId**(`requestId`): `boolean`

Checks if the map contains a given requestId.

#### Parameters

##### requestId

`bigint`

The requestId to check.

#### Returns

`boolean`

True if the requestId exists, false otherwise.

***

### getNameByRequestId()

> **getNameByRequestId**(`requestId`): [`FullTrackName`](FullTrackName.md)

Gets the full track name for a given requestId.

#### Parameters

##### requestId

`bigint`

The requestId to look up.

#### Returns

[`FullTrackName`](FullTrackName.md)

The associated full track name.

#### Throws

:[RequestIdError](RequestIdError.md) if the requestId does not exist.

***

### getRequestIdByName()

> **getRequestIdByName**(`name`): `bigint`

Gets the requestId for a given full track name.

#### Parameters

##### name

[`FullTrackName`](FullTrackName.md)

The full track name to look up.

#### Returns

`bigint`

The associated requestId.

#### Throws

:[RequestIdError](RequestIdError.md) if the name does not exist.

***

### removeMappingByName()

> **removeMappingByName**(`name`): `bigint` | `undefined`

Removes a mapping by full track name.

#### Parameters

##### name

[`FullTrackName`](FullTrackName.md)

The full track name to remove.

#### Returns

`bigint` | `undefined`

The removed requestId, or undefined if not found.

***

### removeMappingByRequestId()

> **removeMappingByRequestId**(`requestId`): [`FullTrackName`](FullTrackName.md) | `undefined`

Removes a mapping by requestId.

#### Parameters

##### requestId

`bigint`

The requestId to remove.

#### Returns

[`FullTrackName`](FullTrackName.md) | `undefined`

The removed full track name, or undefined if not found.
