2024-05-22 08:15:07 -04:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
/**
|
2024-09-20 09:52:23 -04:00
|
|
|
* @import { CommentOp, DeleteOp, InsertOp, Op, RetainOp } from './types'
|
2024-05-22 08:15:07 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Op} op
|
|
|
|
* @returns {op is InsertOp}
|
|
|
|
*/
|
|
|
|
export function isInsert(op) {
|
|
|
|
return 'i' in op && op.i != null
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Op} op
|
|
|
|
* @returns {op is RetainOp}
|
|
|
|
*/
|
|
|
|
export function isRetain(op) {
|
|
|
|
return 'r' in op && op.r != null
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Op} op
|
|
|
|
* @returns {op is DeleteOp}
|
|
|
|
*/
|
|
|
|
export function isDelete(op) {
|
|
|
|
return 'd' in op && op.d != null
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Op} op
|
|
|
|
* @returns {op is CommentOp}
|
|
|
|
*/
|
|
|
|
export function isComment(op) {
|
|
|
|
return 'c' in op && op.c != null && 't' in op && op.t != null
|
|
|
|
}
|