RangeTracker Class

Packages > @fluidframework/common-utils > RangeTracker

Helper class that keeps track of the relation between two ranges in a 1:N fashion. Primary is continuous and always maps to a single value in secondary above the base value. The range defines an increasing step function.

Used by deli to keep track of the branch map

Signature:

export declare class RangeTracker 

Constructors

List of constructors for this class
Constructor Modifiers Description
(constructor)(primary) Constructs a new instance of the RangeTracker class
(constructor)(primary, secondary) Constructs a new instance of the RangeTracker class

Properties

List of properties for this class
Property Modifiers Type Description
base number
primaryHead number Getter for the last primary that was added
secondaryHead number | undefined Getter for the last secondary that was added

Methods

List of methods on this class
Method Modifiers Description
add(primary, secondary) Add a primary, secondary pair to the range
get(primary) Get the closest range to the primary
serialize() Returns a serialized form of the RangeTracker
updateBase(primary) Update the range of primary

Constructors

RangeTracker.(constructor)

Constructs a new instance of the RangeTracker class

Signature:

constructor(primary: IRangeTrackerSnapshot);

Parameters

List of parameters
Parameter Type Description
primary IRangeTrackerSnapshot

RangeTracker.(constructor)

Constructs a new instance of the RangeTracker class

Signature:

constructor(primary: number, secondary: number);

Parameters

List of parameters
Parameter Type Description
primary number
secondary number

Properties

base

Signature:

get base(): number;

primaryHead

Getter for the last primary that was added

Signature:

get primaryHead(): number;

secondaryHead

Getter for the last secondary that was added

Signature:

get secondaryHead(): number | undefined;

Methods

add

Add a primary, secondary pair to the range

Signature:

add(primary: number, secondary: number): void;

Parameters

List of parameters
Parameter Type Description
primary number the primary number in the range
secondary number the secondary number in the range

Returns:

void

get

Get the closest range to the primary

Signature:

get(primary: number): number;

Parameters

List of parameters
Parameter Type Description
primary number the primary value to look for

Returns:

number

the closest range to the primary

serialize

Returns a serialized form of the RangeTracker

Signature:

serialize(): IRangeTrackerSnapshot;

Returns:

IRangeTrackerSnapshot

updateBase

Update the range of primary

Signature:

updateBase(primary: number): void;

Parameters

List of parameters
Parameter Type Description
primary number the primary value to update

Returns:

void