All files / json-patch/op AbstractOp.ts

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

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              21x     3486x                  
import type {CompactOpBase} from '../codec/compact/types';
import type {Path} from '@jsonjoy.com/json-pointer';
import type {OpType} from '../opcodes';
import type {Operation} from '../types';
import type {OPCODE} from '../constants';
import type {IMessagePackEncoder} from '@jsonjoy.com/json-pack/lib/msgpack';
 
export abstract class AbstractOp<O extends OpType = OpType> {
  public readonly from?: Path;
 
  constructor(public readonly path: Path) {}
 
  abstract op(): O;
  abstract code(): OPCODE;
  abstract apply(doc: unknown): {doc: unknown; old?: unknown};
  abstract toJson(parent?: AbstractOp): Operation;
  abstract toCompact(parent: undefined | AbstractOp, verbose: boolean): CompactOpBase;
  abstract encode(encoder: IMessagePackEncoder, parent?: AbstractOp): void;
}