All files / json-crdt-extensions/peritext PeritextNode.ts

88.88% Statements 8/9
100% Branches 0/0
80% Functions 4/5
88.88% Lines 8/9

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 26 27 2844x 44x 44x         44x   3268x       1565x       1562x             46x      
import {MNEMONIC} from './constants';
import {ExtNode} from '../../json-crdt/extensions/ExtNode';
import {ExtensionId} from '../constants';
import type {ArrNode, StrNode} from '../../json-crdt/nodes';
import type {PeritextDataNode} from './types';
import type {SliceNode} from './slice/types';
 
export class PeritextNode extends ExtNode<PeritextDataNode> {
  public text(): StrNode<string> {
    return this.data.get(0)!;
  }
 
  public slices(): ArrNode<SliceNode> {
    return this.data.get(1)!;
  }
 
  // ------------------------------------------------------------------ ExtNode
  public readonly extId = ExtensionId.peritext;
 
  public name(): string {
    return MNEMONIC;
  }
 
  public view(): string {
    return this.text().view();
  }
}