All files / json-crdt/partial-edit PartialEditFactory.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 2/2
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 17 18 19 20 211x       1x   1x   1x 1x       2x 2x 2x 2x 2x      
import {ClockTable} from '../../json-crdt-patch/codec/clock/ClockTable';
import type {Decoder} from '../codec/indexed/binary/Decoder';
import type {Encoder} from '../codec/indexed/binary/Encoder';
import type {IndexedFields} from '../codec/indexed/binary/types';
import {PartialEdit} from './PartialEdit';
 
export class PartialEditFactory {
  constructor(
    protected readonly decoder: Decoder,
    protected readonly encoder: Encoder,
  ) {}
 
  public startPartialEdit(clockBlob: IndexedFields['c']): PartialEdit {
    const reader = this.decoder.dec.reader;
    reader.reset(clockBlob);
    const clockTable = ClockTable.decode(reader);
    const partialEdit = new PartialEdit(this.decoder, this.encoder, clockTable);
    return partialEdit;
  }
}