• 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.


  • ListDocumentModel


Type aliases

Static LogOperation

LogOperation: { br: BranchKey; length: number; rclk: LogootInt; start: LogootPosition; type: NodeType }

Type declaration





agressively_test_bst: boolean = false

An option that will run tests on the DBST after every operation to it. DO NOT enable in production.


branch: BranchKey


branch_order: BranchKey[] = []


canJoin: JoinFunction


clock: Int32 = new LogootInt()

This is a Lamport clock. A proper vector clock would have too many entries for large, multi-user documents. See the Logoot paper for why. Unlike the Logoot implementation, this is incremented with each removal only and is kept constant with insertions.

Optional debug_logger

debug_logger: Logger

An optional instance of the ListDocumentModel.Logger class to log all operations that modify the BST (all calls to _mergeNode) to help with bug identification when applicable.


ldoc_bst: KnownPositionBst = new DBst()

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



  • Contains all branches in order that occur after this LDM's group. Will be empty if this branch_order does not contain the group.

    Returns BranchKey[]


  • Contains all branches in order that occur before this LDM's group. Will be the entire branch_order if it does not contain the group.

    Returns BranchKey[]



  • This is the most important method in the ListDocumentModel. This method adds atoms to the BSTs. By consequence, it replaces nodes and generates conflicts as necessary to add the node to the BST. Users should never call this function directly.


    • br: BranchKey

      The branch to insert on

    • nstart: LogootPosition

      The start Logoot position of the insertion

    • length: number

      The length of the insertion

    • nrclk: LogootInt

      The clock value for the insertion

    • type: NodeType

      The type of node to add. Anything other than data will result in data being removed if it conflicts on the same branch

    • canJoin: JoinFunction

      A JoinFunction to determine if two node groups should be joined together in the same conflict group

    Returns Operation[]


  • The goal of this method is to find the Logoot position corresponding to a particular local position. Unlike the old version, this does not actually record the insertion. The output of this must be passed in to insertLogoot for that to happen. This provides greater flexibility for the programmer. All insertions will be determined on the branch variable of this class. This means that if this funcion is called and the start position is in between two atoms, the first on branch and the second not, the resulting order will leave the new atom after the first atom, but not necessarily after the second atom since conflicts allow atoms to appear out of their Logoot order. However, if an insertion is attempted between two atoms on branches that are not branch, then it will not be possible to determine where the resulting node should go. A InsertionConflictError will be thrown. UI should respond to this by informing the user to resolve the conflict first.


    • start: number

      The position of the insertion

    • length: number

      The length of the insertion

    Returns { br: BranchKey; length: number; rclk: LogootInt; start: LogootPosition }

    An object containing start (a LogootPosition), length, br (just this.branch), and rclk (just this.clock). The start value is the only one that is actually calculated. The others are returned for convenience.



  • removeLocal(start: number, length: number): { removals: Removal[] }
  • Finds the sets of Logoot positions in a certain real text range. This is used to find the removal operations to perform, but it does not actually record the updates, just like insertLocal.


    • start: number

      The position to start removing, inclusive.

    • length: number

      The length of the removal

    Returns { removals: Removal[] }

    • An object containing an array of removals. Each removal has a start LogootPosition, a numeric length, a branch (which is a BranchKey), and a rclk vector clock value.



  • selfTest(): void
  • An extremely expensive operation that scans the BSTs for obvious signs of corruption (empty CGs, non-continuous ldoc, out-of-order ldoc, etc.)


    {FatalError} If any corruption detected

    Returns void

Generated using TypeDoc