All files / json-crdt-extensions/mval MvalApi.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 1/1
100% Lines 10/10

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 1745x       45x   10x 10x 10x 10x 10x 10x 10x 10x      
import {ArrApi, NodeApi} from '../../json-crdt/model/api/nodes';
import type {MvalNode} from './MvalNode';
import type {ExtApi} from '../../json-crdt';
 
export class MvalApi extends NodeApi<MvalNode> implements ExtApi<MvalNode> {
  public set(json: unknown): this {
    const {api, node} = this;
    const builder = api.builder;
    const rgaApi = new ArrApi(node.data, api);
    const length = rgaApi.length();
    rgaApi.del(0, length);
    rgaApi.ins(0, [builder.json(json)]);
    rgaApi.node.removeTombstones();
    return this;
  }
}