@sovereignbase/convergent-replicated-list
    Preparing search index...

    Class CRList<T>

    A convergent replicated list.

    Iteration, find(), some(), and forEach() expose the same live value references. Mutating returned objects directly can mutate replica state without producing a CRDT delta, so callers must isolate values before out-of-band mutation. Local mutations emit delta and change events; remote merges emit change events.

    Type Parameters

    • T

      The value type stored in the list.

    Index

    Constructors

    Accessors

    Methods

    • Iterates over current live values in index order.

      Returns IterableIterator<T>

    • Emits an acknowledgement frontier for currently retained deleted item ids.

      Returns void

    • Inserts values after an index.

      If afterIndex is omitted, values are appended at the end of the list.

      Parameters

      • values: T[]

        Values to insert.

      • OptionalafterIndex: number

        The index to insert after.

      Returns void

    • Removes one or more entries starting at an index.

      Parameters

      • index: number

        The first index to remove.

      • count: number = 1

        Number of entries to remove. Defaults to 1.

      Returns void

    • Returns the first live value matching a predicate in index order.

      Predicate values are live references. Mutating them directly can mutate the list without emitting a delta.

      Parameters

      • predicate: (this: unknown, value: T, index: number, list: this) => unknown

        Function to test each live value.

      • OptionalthisArg: unknown

        Optional this value for the predicate.

      Returns T | undefined

    • Calls a function once for each live value in index order.

      Callback values are live references. Mutating them directly can mutate the list without emitting a delta.

      Parameters

      • callback: (value: T, index: number, list: this) => void

        Function to call for each live value.

      • OptionalthisArg: unknown

        Optional this value for the callback.

      Returns void

    • Garbage-collects deleted item ids covered by acknowledgement frontiers.

      Parameters

      • frontiers: (readonly [number, number, number, number])[]

        Replica acknowledgement frontiers.

      Returns void

    • Reads an item in the live list projection by index.

      Returns a live value reference.

      Parameters

      • index: number

        The index to read.

      Returns T | undefined

    • Applies a remote gossip delta to this list.

      Emits a change event when the merge changes the live projection.

      Parameters

      Returns void

    • Inserts values before an index.

      If beforeIndex is omitted, values are inserted at the start of the list.

      Parameters

      • values: T[]

        Values to insert.

      • OptionalbeforeIndex: number

        The index to insert before.

      Returns void

    • Overwrites entries starting at an index.

      Parameters

      • index: number

        The index to start overwriting at.

      • values: T[]

        Values to write.

      Returns void

    • Emits the current CRList snapshot.

      Snapshot value payloads are live references. Mutating them can mutate replica state without emitting a delta.

      Returns void

    • Tests whether any live value matches a predicate in index order.

      Predicate values are live references. Mutating them directly can mutate the list without emitting a delta.

      Parameters

      • predicate: (this: unknown, value: T, index: number, list: this) => unknown

        Function to test each live value.

      • OptionalthisArg: unknown

        Optional this value for the predicate.

      Returns boolean

    • Returns a CRList snapshot of this list.

      Snapshot value payloads are live references. Mutating them can mutate replica state without emitting a delta.

      Called automatically by JSON.stringify.

      Returns CRListSnapshot<T>

    • Attempts to return this list snapshot as a JSON string.

      This can fail when list values are not JSON-compatible.

      Returns string