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

One Range Filter parameter. Unlike other parameters it may repeat in a message,
once per SetID (and Property Type).

Without a `setId` it is the zero-length form, which in REQUEST_UPDATE removes the
filters of its kind.

The Ranges are held as the wire's deltas and only added back by [RangeFilter.ranges](#ranges): a sum past 2^64-1 is answered with a REQUEST_ERROR for the
request that carried it, which a parser that rejected it could not do.

## Implements

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

## Constructors

### Constructor

> **new RangeFilter**(`kind`, `setId?`, `propertyType?`, `deltas?`): `RangeFilter`

#### Parameters

##### kind

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

##### setId?

`number`

##### propertyType?

`bigint`

##### deltas?

readonly [`RangeDelta`](../type-aliases/RangeDelta.md)\[] = `[]`

#### Returns

`RangeFilter`

#### Throws

:[ProtocolViolationError](ProtocolViolationError.md) When the Property Type's presence does not
match the kind, or a removal carries anything but its kind.

## Properties

### deltas

> `readonly` **deltas**: readonly [`RangeDelta`](../type-aliases/RangeDelta.md)\[] = `[]`

***

### kind

> `readonly` **kind**: [`RangeFilterKind`](../enumerations/RangeFilterKind.md)

***

### propertyType?

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

***

### setId?

> `readonly` `optional` **setId?**: `number`

## Accessors

### isRemoval

#### Get Signature

> **get** **isRemoval**(): `boolean`

The zero-length form, which removes the filters of its kind.

##### Returns

`boolean`

***

### rangeCount

#### Get Signature

> **get** **rangeCount**(): `number`

How many Ranges the filter holds, which is what a peer's range limit counts.

##### Returns

`number`

## Methods

### ranges()

> **ranges**(): [`Range`](../interfaces/Range.md)\[]

The Ranges with their deltas added back.

#### Returns

[`Range`](../interfaces/Range.md)\[]

#### Throws

:[InvalidFilterError](InvalidFilterError.md) When a bound exceeds 2^64-1.

***

### serializeValue()

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

The SetID, Property Type if any, and the Ranges, without the Type or Length.

#### Returns

`Uint8Array`

***

### toKeyValuePair()

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

#### Returns

[`KeyValuePair`](KeyValuePair.md)

#### Implementation of

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

***

### validate()

> **validate**(): [`Range`](../interfaces/Range.md)\[]

The Ranges, once everything a filter of this kind has to satisfy holds.

#### Returns

[`Range`](../interfaces/Range.md)\[]

#### Throws

:[InvalidFilterError](InvalidFilterError.md) For an odd Property Type, a priority above
255, or a bound past 2^64-1.

***

### fromKeyValuePair()

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

Decodes a Range Filter value. The Value ends with the last Range, so a Start
with nothing after it is an open-ended last Range.

#### Parameters

##### pair

[`KeyValuePair`](KeyValuePair.md)

#### Returns

`RangeFilter` | `undefined`
