json-joy
    Preparing search index...

    Class ArrNode<Element>

    Represents the arr JSON CRDT type, which is a Replicated Growable Array (RGA). Each element ot the array is a reference to another JSON CRDT node.

    Type Parameters

    Hierarchy

    • AbstractRga<E[]>
      • ArrNode

    Implements

    Index

    Constructors

    Properties

    count: number = 0
    doc: Model<any>

    Unique ID within a document.

    ids: undefined | Chunk<ITimestampStruct[]> = undefined
    root: undefined | Chunk<ITimestampStruct[]> = undefined

    Methods

    • Returns ID of the RGA slot (not the referenced JSON node) at a given position in the array. The ID is a timestamp the unique slot of the element in the RGA. To retrieve the JSON node ID referenced by the slot, use get method.

      Parameters

      • position: number

        The position of the element to get.

      Returns undefined | ITimestampStruct

      ID of the RGA slot.

      Rename to getRef.

    • Returns a JSON node at a given position in the array.

      Parameters

      • position: number

        The position of the element to get.

      Returns undefined | JsonNode<unknown>

      A JSON node, if any.

    • Parameters

      • startChunk: undefined | Chunk<ITimestampStruct[]>

        Chunk from which to start the range. If undefined, the chunk containing from will be used. This is an optimization to avoid a lookup.

      • from: ITimestampStruct

        ID of the first element in the range.

      • to: ITimestampStruct

        ID of the last element in the range.

      • callback: (chunk: Chunk<ITimestampStruct[]>, off: number, len: number) => boolean | void

        Function to call for each chunk slice in the range. If it returns truthy value, the iteration will stop.

      Returns void | Chunk<ITimestampStruct[]>

      Reference to the last chunk in the range.

      All ".rangeX()" method are not performance optimized. For hot paths it is better to hand craft the loop.