All files / json-crdt/nodes/root RootNode.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 2/2
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26156x 156x                       156x         35213x       40x      
import {ORIGIN} from '../../../json-crdt-patch/constants';
import {ValNode} from '../val/ValNode';
import type {Model} from '../../model/Model';
import type {ITimestampStruct} from '../../../json-crdt-patch/clock';
import type {JsonNode} from '../types';
 
/**
 * The root of a JSON CRDT document. {@link RootNode} is a {@link ValNode} with
 * a special `0.0` ID, which is always the same. It is used to represent the
 * root of a document.
 *
 * @category CRDT Node
 */
export class RootNode<Value extends JsonNode = JsonNode> extends ValNode<Value> {
  /**
   * @param val Latest value of the document root.
   */
  constructor(doc: Model<any>, val: ITimestampStruct) {
    super(doc, ORIGIN, val);
  }
 
  public name(): string {
    return 'root';
  }
}