Skip to main content

SequenceInterval Interface

Interval implementation whose ends are associated with positions in a mutatable sequence. As such, when content is inserted into the middle of the interval, the interval expands to include that content.

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/sequence/legacy.

For more information about our API support guarantees, see here.

Signature

export interface SequenceInterval extends IInterval

Extends: IInterval

Remarks

The endpoints' positions should be treated exclusively to get reasonable behavior. E.g., an interval referring to "hello" in "hello world" should have a start position of 0 and an end position of 5.

To see why, consider what happens if "llo wor" is removed from the string to make "held". The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint slides forward to the next unremoved position, which is the "l" in "held". Users would generally expect the interval to now refer to "he" (as it is the subset of content remaining after the removal), hence the "l" should be excluded. If the interval endpoint was treated inclusively, the interval would now refer to "hel", which is undesirable.

Since the endpoints of an interval are treated exclusively but cannot be greater than or equal to the length of the associated sequence, there exist special endpoint segments, "start" and "end", which represent the position immediately before or immediately after the string respectively.

If a SequenceInterval is created on a sequence with the mergeTreeReferencesCanSlideToEndpoint feature flag set to true, the endpoints of the interval that are exclusive will have the ability to slide to these special endpoint segments. \

Properties

Property Alerts Modifiers Type Description
end Beta readonly LocalReferencePosition End endpoint of this interval.
endSide Beta readonly Side
intervalType Beta readonly IntervalType
properties Beta PropertySet Serializable bag of properties associated with the interval.
start Beta readonly LocalReferencePosition
startSide Beta readonly Side
stickiness Beta readonly IntervalStickiness

Methods

Method Alerts Return Type Description
compare(b) Beta number Compares this interval to b with standard comparator semantics: - returns -1 if this is less than b - returns 1 if this is greater than b - returns 0 if this is equivalent to b
compareEnd(b) Beta number Compares the end endpoint of this interval to b's end endpoint. Standard comparator semantics apply.
compareStart(b) Beta number Compares the start endpoint of this interval to b's start endpoint. Standard comparator semantics apply.
getIntervalId() Beta string Gets the id associated with this interval. When the interval is used as part of an interval collection, this id can be used to modify or remove the interval.
overlaps(b) Beta boolean
overlapsPos(bstart, bend) Beta boolean

Property Details

end

End endpoint of this interval.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
readonly end: LocalReferencePosition;

Type: LocalReferencePosition

Remarks

This endpoint can be resolved into a character position using the SharedString it's a part of.

endSide

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
readonly endSide: Side;

Type: Side

intervalType

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
readonly intervalType: IntervalType;

Type: IntervalType

properties

Serializable bag of properties associated with the interval.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
properties: PropertySet;

Type: PropertySet

start

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
readonly start: LocalReferencePosition;

Type: LocalReferencePosition

startSide

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
readonly startSide: Side;

Type: Side

stickiness

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
readonly stickiness: IntervalStickiness;

Type: IntervalStickiness

Method Details

compare

Compares this interval to b with standard comparator semantics: - returns -1 if this is less than b - returns 1 if this is greater than b - returns 0 if this is equivalent to b

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
compare(b: SequenceInterval): number;

Parameters

Parameter Type Description
b SequenceInterval Interval to compare against

Returns

Return type: number

compareEnd

Compares the end endpoint of this interval to b's end endpoint. Standard comparator semantics apply.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
compareEnd(b: SequenceInterval): number;

Parameters

Parameter Type Description
b SequenceInterval Interval to compare against

Returns

Return type: number

compareStart

Compares the start endpoint of this interval to b's start endpoint. Standard comparator semantics apply.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
compareStart(b: SequenceInterval): number;

Parameters

Parameter Type Description
b SequenceInterval Interval to compare against

Returns

Return type: number

getIntervalId

Gets the id associated with this interval. When the interval is used as part of an interval collection, this id can be used to modify or remove the interval.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
getIntervalId(): string;

Returns

Return type: string

overlaps

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
overlaps(b: SequenceInterval): boolean;

Parameters

Parameter Type Description
b SequenceInterval

Returns

whether this interval overlaps with b. Intervals are considered to overlap if their intersection is non-empty.

Return type: boolean

overlapsPos

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature
overlapsPos(bstart: number, bend: number): boolean;

Parameters

Parameter Type Description
bstart number
bend number

Returns

whether this interval overlaps two numerical positions.

Return type: boolean