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

The range of Locations a subscription or fetch selects. The Location Filter
Type decides which fields are set, and the value is not length-prefixed.

Every Group here is absolute, except `startGroup` of a
`LocationFilterType.RelativeStart`, which counts back from the Next
Group: 0 is the Next Group, 1 the current one. The wire carries the End Group
as a delta from the Start Group; that is undone on the way in and redone on
the way out.

If omitted from SUBSCRIBE or FETCH, the subscription or fetch is unfiltered.
If omitted from REQUEST_UPDATE, the value is unchanged.

## Implements

* [`Parameter`](../interfaces/Parameter.md)

## Constructors

### Constructor

> **new LocationFilter**(`filterType`, `startGroup?`, `startObject?`, `endGroup?`, `endObject?`): `LocationFilter`

#### Parameters

##### filterType

[`LocationFilterType`](../enumerations/LocationFilterType.md)

##### startGroup?

`bigint`

##### startObject?

`bigint`

##### endGroup?

`bigint`

##### endObject?

`bigint`

#### Returns

`LocationFilter`

#### Throws

:[ProtocolViolationError](ProtocolViolationError.md) When a field the type calls for is
missing, or the End Group is before the Start Group.

## Properties

### endGroup?

> `readonly` `optional` **endGroup?**: `bigint`

***

### endObject?

> `readonly` `optional` **endObject?**: `bigint`

***

### filterType

> `readonly` **filterType**: [`LocationFilterType`](../enumerations/LocationFilterType.md)

***

### startGroup?

> `readonly` `optional` **startGroup?**: `bigint`

***

### startObject?

> `readonly` `optional` **startObject?**: `bigint`

***

### TYPE

> `readonly` `static` **TYPE**: [`LocationFilter`](../enumerations/MessageParameterType.md#locationfilter) = `MessageParameterType.LocationFilter`

## Accessors

### absoluteStart

#### Get Signature

> **get** **absoluteStart**(): [`Location`](Location.md) | `undefined`

The Start Location an absolute filter carries; `undefined` for the others.

##### Returns

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

## Methods

### endLocation()

> **endLocation**(): [`Location`](Location.md) | `undefined`

The last Location the filter passes, inclusive, or `undefined` when it is
open-ended. A Group End is the whole of that group, so its Object is 2^64-1.

#### Returns

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

***

### fetchRange()

> **fetchRange**(`largest?`): { `end`: [`Location`](Location.md); `start`: [`Location`](Location.md); } | `undefined`

The inclusive range the filter selects under the rules for a Fetch, which
never reach past the Largest Object: an open end is the Largest Object, and
no filter at all is the whole track up to it.

`undefined` when that range is empty, which includes a track with nothing
published yet and a Next Object filter, whose start is always past the
Largest Object.

#### Parameters

##### largest?

[`Location`](Location.md)

#### Returns

{ `end`: [`Location`](Location.md); `start`: [`Location`](Location.md); } | `undefined`

***

### serializeValue()

> **serializeValue**(): `Uint8Array`

The Location Filter Type and its fields, without the Parameter Type.

#### Returns

`Uint8Array`

***

### startLocation()

> **startLocation**(`largest?`): [`Location`](Location.md) | `undefined`

The first Location the filter passes, given the track's Largest Object, or
`undefined` when there is no filter. A relative start that would fall before
group 0 is group 0; a track with nothing published yet starts a relative
filter at `{0,0}`.

#### Parameters

##### largest?

[`Location`](Location.md)

#### Returns

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

***

### toKeyValuePair()

> **toKeyValuePair**(): [`KeyValuePair`](KeyValuePair.md)

#### Returns

[`KeyValuePair`](KeyValuePair.md)

#### Implementation of

[`Parameter`](../interfaces/Parameter.md).[`toKeyValuePair`](../interfaces/Parameter.md#tokeyvaluepair)

***

### deserializeValue()

> `static` **deserializeValue**(`buf`): `LocationFilter`

Reads a Location Filter Type and exactly the fields it calls for.

#### Parameters

##### buf

[`BaseByteBuffer`](BaseByteBuffer.md)

#### Returns

`LocationFilter`

#### Throws

:[ProtocolViolationError](ProtocolViolationError.md) For an unknown Location Filter Type,
or an End Group past 2^64-1.

***

### fromKeyValuePair()

> `static` **fromKeyValuePair**(`pair`): `LocationFilter` | `undefined`

#### Parameters

##### pair

[`KeyValuePair`](KeyValuePair.md)

#### Returns

`LocationFilter` | `undefined`
