summaryrefslogtreecommitdiff
path: root/src/main/otTypes.ts
blob: 8e9df9f5ce2a915838e453843aa2bc859a6ddae6 (plain)
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
28
29
30
31
// OT type definitions for main process (mirror of renderer types)

export interface InsertOp {
  i: string
  p: number
}

export interface DeleteOp {
  d: string
  p: number
}

export interface CommentOp {
  c: string
  p: number
  t: string
}

export type OtOp = InsertOp | DeleteOp | CommentOp

export function isInsert(op: OtOp): op is InsertOp {
  return 'i' in op
}

export function isDelete(op: OtOp): op is DeleteOp {
  return 'd' in op
}

export function isComment(op: OtOp): op is CommentOp {
  return 'c' in op
}