• Public
  • Public/Protected
  • All

Class ListDocumentModel

A representation of the Logootish Document Model for mapping "real," continuous known_positions to Logoot positions. This is useful when working with strings, arrays, or, just in general, anything that needs a fixed order. This does not actually store the data in question, but stores a mapping of real indices in the data to the Logoot positions of that element. This is used to transform edits between ones in the Logoot and local position spaces. One important thing to note: Logoot edits (insertions/removals) can be applied in any order. Local edits must be applied in a consistent order.


Conflict resolution does not exist. This will create significant changes to this API


  • ListDocumentModel




ldoc_bst: KnownPositionBst = new Bst((a, b) => (a.known_position - b.known_position) as CompareResult)

The BST maps out where all insertion nodes are in the local document's memory. It is used to go from position -> node


logoot_bst: LogootBst = new Bst((a, b) => a.start.cmp(b.start))

This BST maps Logoot position identifiers to their text node to allow lookup of text position from Logoot ID


removal_bst: LogootBst = new Bst((a, b) => a.start.cmp(b.start))

A map of removals that do not yet have text to remove


vector_clock: Int32 = new LogootInt()

See the Logoot paper for why. Unlike the Logoot implementation, this is incremented with each removal only and is kept constant with insertions.



  • insertLocal(position: number, len: number): object
  • Calculate the Logoot positions of a local insertion.


    {FatalError} Will throw in the event that internal corruption is encountered. If this happens, please submit an issue.


    {Error} Will throw in the event that the position being inserted is after the end of the known document model.


    • position: number

      The index of new text

    • len: number

      How much will be inserted

    Returns object

    A Logoot insertion with a Logoot position (start), a vector clock value (rclk) (copied from the document), and the length passed to the function (length). Note that the start position is not copied, so if it is modified, it will mess up the sorting trees. Ensure that it is copied before modifying it.


  • insertLogoot(nstart: LogootPosition, length: number, this_rclk: LogootInt): object
  • Calculate the local positions inserted from an insertion at a Logoot position from a given length and vector clock.


    • nstart: LogootPosition

      The start LogootPosition of the insertion

    • length: number

      The length of the insertion

    • this_rclk: LogootInt

      The vector clock when the insertion took place.

    Returns object

    An object with the insertions member set to an array with objects containing a numeric offset, which represents which part of the source string the insertion is pulling from, a numeric length, and a numeric known_position where to place the string. Insertions must be applied in the order of the return value. The object also has a removals variable set to an array of objects containing known_position and length that represent removed conflicts with existing data. These removals should be applied before the insertions.

    • insertions: object[]
    • removals: object[]


  • removeLocal(position: number, length: number): object
  • Calculate the Logoot positions and lengths of removals from a removal in the local document.


    • position: number

      The index of old text

    • length: number

      The length text that will be removed

    Returns object

    An object containing an array of removals and the calculated vector clock. Each removal contains a start LogootPosition, which is not copied, so it cannot be modified, and a numeric length.

    • rclk: LogootInt
    • removals: Removal[]


  • removeLogoot(start: LogootPosition, length: number, rclk: LogootInt): object
  • Calculate the regions of text to be removed from the local document from a Logoot position, length, and vector clock of a removal.


    • start: LogootPosition

      The start at which to start removing.

    • length: number

      How much to remove.

    • rclk: LogootInt

      The vector clock of the removal.

    Returns object

    An object containing a member removals, which is an array of objects containing a known_position at which to start removing and a length, both of which are numbers.

    • removals: object[]

Generated using TypeDoc