mute-structs
Version:
NodeJS module providing an implementation of the LogootSplit CRDT algorithm
66 lines (65 loc) • 2.15 kB
TypeScript
import { Dot } from "./dot";
import { Identifier } from "./identifier";
/**
* Define an interval between two identifiers sharing the same base
*/
export declare class IdentifierInterval {
static fromPlain(o: unknown): IdentifierInterval | null;
/**
* Merge as much as possible Identifiers contained into an array into IdentifierIntervals
*
* @param {Identifier[]} ids The array of Identifiers
* @return {IdentifierInterval[]} The corresponding array of IdentifierIntervals
*/
static mergeIdsIntoIntervals(ids: Identifier[]): IdentifierInterval[];
readonly idBegin: Identifier;
readonly end: number;
constructor(idBegin: Identifier, end: number);
/**
* Shortcut to retrieve the offset of the last tuple of idBegin
* This offset also corresponds to the beginning of the interval
*
* @return {number} The offset
*/
readonly begin: number;
/**
* Shortcut to retrieve the last identifier of the interval
*
* @return {Identifier} The last identifier of the interval
*/
readonly idEnd: Identifier;
/**
* Shortcut to compute the length of the interval
*
* @return {number} The length
*/
readonly length: number;
readonly base: number[];
readonly dot: Dot;
equals(aOther: IdentifierInterval): boolean;
/**
* Compute the union between this interval and [aBegin, aEnd]
*
* @param {number} aBegin
* @param {number} aEnd
* @return {IdentifierInterval} this U [aBegin, aEnd]
*/
union(aBegin: number, aEnd: number): IdentifierInterval;
/**
* Check if the provided identifier belongs to this interval
*
* @param {Identifier} id
* @return {boolean} Does the identifier belongs to this interval
*/
containsId(id: Identifier): boolean;
/**
* Retrieve a identifier from the interval from its offset
*
* @param {number} offset The offset of the identifier
* @return {Identifier} The identifier
*/
getBaseId(offset: number): Identifier;
digest(): number;
toIds(): Identifier[];
toString(): string;
}