mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 22:51:18 +00:00
ee85d948e2
GitOrigin-RevId: ef2ef77e26df59d1af3df6dc664e284d3c70102d
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
const assert = require('check-types').assert
|
|
|
|
const Change = require('./change')
|
|
|
|
/**
|
|
* @constructor
|
|
* @param {number} baseVersion the new base version for the change
|
|
* @param {?Change} change
|
|
* @classdesc
|
|
* A `ChangeNote` is returned when the server has applied a {@link Change}.
|
|
*/
|
|
function ChangeNote(baseVersion, change) {
|
|
assert.integer(baseVersion, 'bad baseVersion')
|
|
assert.maybe.instance(change, Change, 'bad change')
|
|
|
|
this.baseVersion = baseVersion
|
|
this.change = change
|
|
}
|
|
|
|
module.exports = ChangeNote
|
|
|
|
/**
|
|
* For serialization.
|
|
*
|
|
* @return {Object}
|
|
*/
|
|
ChangeNote.prototype.toRaw = function changeNoteToRaw() {
|
|
return {
|
|
baseVersion: this.baseVersion,
|
|
change: this.change.toRaw(),
|
|
}
|
|
}
|
|
|
|
ChangeNote.prototype.toRawWithoutChange =
|
|
function changeNoteToRawWithoutChange() {
|
|
return {
|
|
baseVersion: this.baseVersion,
|
|
}
|
|
}
|
|
|
|
ChangeNote.fromRaw = function changeNoteFromRaw(raw) {
|
|
assert.integer(raw.baseVersion, 'bad raw.baseVersion')
|
|
assert.maybe.object(raw.change, 'bad raw.changes')
|
|
|
|
return new ChangeNote(raw.baseVersion, Change.fromRaw(raw.change))
|
|
}
|
|
|
|
ChangeNote.prototype.getBaseVersion = function () {
|
|
return this.baseVersion
|
|
}
|
|
|
|
ChangeNote.prototype.getResultVersion = function () {
|
|
return this.baseVersion + 1
|
|
}
|
|
|
|
ChangeNote.prototype.getChange = function () {
|
|
return this.change
|
|
}
|