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

    Class CRSet<T>

    A convergent replicated set. (set = list without duplicates)

    Values are identified by the SHA-256 Base64URL digest of their canonical MessagePack encoding. Local mutations emit delta and change events; received deltas converge through merge.

    Reads and iteration return detached copies of the live values.

    Type Parameters

    • T

      The value type stored in the set.

    Index

    Constructors

    Accessors

    Methods

    • Iterates over detached copies of the current live values.

      Returns IterableIterator<T>

    • Emits the current acknowledgement frontier.

      Acknowledgement frontiers are used by peers to decide when tombstones can be garbage collected.

      Returns void

    • Adds a value to the replicated set.

      The value's content key is derived from its current canonical MessagePack encoding. If that key is already visible, the operation is a no-op. Successful additions emit delta and change events.

      Parameters

      • value: T

        Value to add.

      Returns void

      Thrown when the value cannot be encoded.

      Thrown when the value cannot be cloned into replica state.

    • Registers an event listener.

      Type Parameters

      Parameters

      • type: K

        The event type to listen for.

      • listener: EventListenerOrEventListenerObject | null

        The listener to register.

      • Optionaloptions: boolean | AddEventListenerOptions

        Listener registration options.

      Returns void

    • Deletes every visible value.

      Successful clears emit delta and change events.

      Returns void

    • Deletes a value from the replicated set.

      The value's content key is derived from its current canonical MessagePack encoding. If that key is not visible, the operation is a no-op. Successful deletions emit delta and change events.

      Parameters

      • value: T

        Value to delete.

      Returns void

      Thrown when the value cannot be encoded.

    • Calls a function once for each live value copy in replica iteration order.

      Callback values are detached copies, so mutating them does not mutate the replica.

      Parameters

      • callback: (value: T, set: this) => void

        Function to call for each value.

      • OptionalthisArg: unknown

        Optional this value for the callback.

      Returns void

    • Removes tombstones that every provided frontier has acknowledged.

      Parameters

      • frontiers: string[]

        Replica acknowledgement frontiers.

      Returns void

    • Checks whether a value is currently visible in the replicated set.

      Parameters

      • value: T

        Value to check.

      Returns boolean

      true when the value's current content key is visible.

      Thrown when the value cannot be encoded.

    • Applies a remote or local delta to the replica state.

      Accepted remote changes may emit change; dominated incoming state may emit a reply delta.

      Parameters

      • delta: CRSetDelta<T>

        The partial serialized set state to merge.

      Returns void

    • Removes an event listener.

      Type Parameters

      Parameters

      • type: K

        The event type to stop listening for.

      • listener: EventListenerOrEventListenerObject | null

        The listener to remove.

      • Optionaloptions: boolean | EventListenerOptions

        Listener removal options.

      Returns void

    • Attempts to return this set as a JSON string.

      Returns string

    • Returns detached copies of the current live values.

      Returns T[]

      The current values in replica iteration order.