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.

see

TSeqText for usage information

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 or reverts (see revert param) remote operations to this local clone of the TSeq.

    Parameters

    • operation: TSeqOperation | null

      the operation to apply, or null if only reverting.

    • Default value reversions: TSeqLocalOperation[] = []

      are local operations to be reverted prior to applying operation, in reverse order of original application. The effect of these will be included in the returned splice, but not in the revert metadata.

    • Default value revert: TSeqRevert = []

      will be populated with reversion metadata for the operation

    Returns TextSplice[]

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], content: (TSeqCharTick | undefined)[], charIndex: number, force?: undefined | false | true): Iterable<TSeqPreApply>
  • Parameters

    • __namedParameters: [any, Array]
    • content: (TSeqCharTick | undefined)[]
    • charIndex: number
    • Optional force: undefined | false | true

    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

  • 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

    • Optional revert: TSeqRevert

      will be populated with reversion metadata for the returned operation.

    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 Source code licensed MIT. Privacy policy