Options
All
  • Public
  • Public/Protected
  • All
Menu

A CRDT for plain text. Characters are positioned into an n-ary tree, in which each node is a sparse array, extensible in either positive or negative index direction, 'belonging' to a process identity. The tree is read in depth-first order. The use of owned-arrays reflects an optimisation for the typical text document pattern of editing – a user extends some selected text with new text.

A TSeq requires the framework guarantees of a 'shared data type' in m-ld: operations must be applied only once, and in causal order.

experimental

Hierarchy

  • TSeqNode
    • TSeq

Index

Constructors

constructor

  • new TSeq(pid: string): TSeq
  • Parameters

    • pid: string

    Returns TSeq

Properties

Readonly path

path: TSeqName[]

The location of this node in the TSeq tree

Readonly pid

pid: string

The local process ID

Accessors

charLength

  • get charLength(): number
  • Returns number

hasRest

  • get hasRest(): boolean
  • Returns boolean

parent

  • get parent(): undefined
  • inheritdoc

    Returns undefined

Methods

apply

  • Applies remote operations to this local clone of the TSeq

    Parameters

    • operations: TSeqOperation

      the operations to apply

    • Optional cb: undefined | ((revert: TSeqRevertOperation) => void)

      a callback to recover reversion information if required

    Returns [number, number, undefined | string][]

chars

  • chars(fromCharIndex?: number): IterableIterator<TSeqCharNode>
  • Parameters

    • Default value fromCharIndex: number = 0

    Returns IterableIterator<TSeqCharNode>

checkInvariants

  • checkInvariants(): void
  • inheritdoc

    Returns void

children

  • children(): TSeqProcessArray[]
  • inheritdoc

    Returns TSeqProcessArray[]

gc

  • gc(array: TSeqProcessArray): void
  • Parameters

    • array: TSeqProcessArray

    Returns void

incCharLength

  • incCharLength(inc: number): void
  • Parameters

    • inc: number

    Returns void

isAncestorOf

  • isAncestorOf(other: TSeqContainer<TSeqCharNode> | undefined): boolean
  • Parameters

    • other: TSeqContainer<TSeqCharNode> | undefined

    Returns boolean

preApply

  • preApply(__namedParameters: [any, Array], charIndex: number): Iterable<TSeqPreApply>
  • Parameters

    • __namedParameters: [any, Array]
    • charIndex: number

    Returns Iterable<TSeqPreApply>

    the actually-affected character nodes (ignoring empty -> empty)

push

  • push(pid: string, content: string, tick: number): TSeqCharNode[]
  • Parameters

    • pid: string
    • content: string
    • tick: number

    Returns TSeqCharNode[]

restFromJSON

  • restFromJSON(json: any[]): void
  • Parameters

    • json: any[]

    Returns void

splice

  • splice(index: number, deleteCount: number, content?: string): TSeqOperation
  • Changes the text content of this TSeq by removing or replacing existing characters and/or adding new characters in place.

    Parameters

    • index: number

      zero-based index at which to start changing the text

    • deleteCount: number

      the number of characters in the text to remove from index

    • Default value content: string = ""

      the characters to add to the text, beginning from index

    Returns TSeqOperation

toJSON

  • toJSON(): any
  • inheritdoc

    Returns any

toString

  • toString(): string
  • Returns string

Static fromJSON

  • fromJSON(pid: string, json: any): TSeq
  • Create a new TSeq from a representation created with toJSON.

    Parameters

    • pid: string
    • json: any

    Returns TSeq

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method
  • Protected method

Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.10.0-edge.5 Source code licensed MIT. Privacy policy