overleaf/services/document-updater/app/js/Utils.js
Eric Mc Sween 377cd82f20 Merge pull request #16928 from overleaf/em-hpos-hlen
Add history metadata to updates sent to project-history

GitOrigin-RevId: 915beaa01f2bbe48869a40b229397be8e0401852
2024-02-14 09:05:02 +00:00

40 lines
743 B
JavaScript

// @ts-check
/**
* @typedef {import('./types').CommentOp} CommentOp
* @typedef {import('./types').DeleteOp} DeleteOp
* @typedef {import('./types').InsertOp} InsertOp
* @typedef {import('./types').Op} Op
*/
/**
* Returns true if the op is an insert
*
* @param {Op} op
* @returns {op is InsertOp}
*/
function isInsert(op) {
return 'i' in op && op.i != null
}
/**
* Returns true if the op is an insert
*
* @param {Op} op
* @returns {op is DeleteOp}
*/
function isDelete(op) {
return 'd' in op && op.d != null
}
/**
* Returns true if the op is a comment
*
* @param {Op} op
* @returns {op is CommentOp}
*/
function isComment(op) {
return 'c' in op && op.c != null
}
module.exports = { isInsert, isDelete, isComment }