operations.ts 510 B

12345678910111213141516
  1. import {
  2. ChangeOperation,
  3. CommentOperation,
  4. DeleteOperation,
  5. InsertOperation,
  6. Operation,
  7. } from '../../../types/change'
  8. export const isInsertOperation = (op: Operation): op is InsertOperation =>
  9. 'i' in op
  10. export const isChangeOperation = (op: Operation): op is ChangeOperation =>
  11. 'c' in op && 't' in op
  12. export const isCommentOperation = (op: Operation): op is CommentOperation =>
  13. 'c' in op && !('t' in op)
  14. export const isDeleteOperation = (op: Operation): op is DeleteOperation =>
  15. 'd' in op