Skip to main content
Module

x/automerge/index.ts>Text

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
Go to Latest
class Text
Re-export
import { Text } from "https://deno.land/x/automerge@2.2.0/index.ts";

Constructors

new
Text(text?: string | string[] | Value[])

Properties

elems: Array<any>
readonly
length: number
spans: Array<any> | undefined
str: string | undefined
optional
[STATE]: InternalState<any>

Methods

concat(other: Text): Text
deleteAt(index: number, numDelete?)

Deletes numDelete list items starting at position index. if numDelete is not given, one item is deleted.

every(test: (v: Value) => boolean): boolean
filter(test: (v: Value) => boolean): Text
find(test: (v: Value) => boolean): Value | undefined
findIndex(test: (v: Value) => boolean): number | undefined
forEach(f: (v: Value) => undefined)
get(index: number): any
includes(elem: Value): boolean
indexOf(elem: Value)
insertAt(index: number, ...values: Array<Value | object>)

Inserts new list items values starting at position index.

join(sep?: string): string
lastIndexOf(searchElement: Value, fromIndex?: number)
map<T>(callback: (e: Value | object) => T)
reduce(f: (
previousValue: Value,
currentValue: Value,
currentIndex: number,
array: Value[],
) => Value
)
reduceRight(f: (
previousValue: Value,
currentValue: Value,
currentIndex: number,
array: Value[],
) => Value
)
set(index: number, value: Value)

Updates the list item at position index to a new value value.

slice(start?: number, end?: number)
some(test: (arg: Value) => boolean): boolean
toJSON(): string

Returns the content of the Text object as a simple string, so that the JSON serialization of an Automerge document represents text nicely.

toSpans(): Array<Value | object>

Returns the content of the Text object as a sequence of strings, interleaved with non-character elements.

For example, the value ['a', 'b', {x: 3}, 'c', 'd'] has spans: => ['ab', {x: 3}, 'cd']

toString(): string

Returns the content of the Text object as a simple string, ignoring any non-character elements.

Iterates over the text elements character by character, including any inline objects.