Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit e956b28

Browse files
committed
more explanation
1 parent 5b9c1c0 commit e956b28

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

lib/document.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Document {
109109
/*
110110
Public: Modify the Document's text.
111111
112-
The modification can be a deletion, insertion, or both.
112+
The modification can be a deletion, insertion, or both (an overwrite).
113113
If `end` is after `start` in the document, the operation is a deletion.
114114
If `text` is passed, the operation is an insertion.
115115
@@ -176,6 +176,7 @@ class Document {
176176
* `layerUpdatesById` {Object} of shape:
177177
* {Number} Marker layer ID
178178
* {Numer} Marker ID
179+
* {Marker}
179180
180181
Returns an {Array} of the marker update operation.
181182
*/
@@ -236,7 +237,9 @@ class Document {
236237
}
237238

238239
/*
239-
Public: Undoes one or more operations.
240+
Public: Undoes the latest Transaction on the undo stack.
241+
242+
If there's a barrier before the latest Transaction, nothing happens.
240243
241244
Returns null or {Object} of shape:
242245
* `markers` {Object} of shape:
@@ -279,7 +282,7 @@ class Document {
279282
}
280283

281284
/*
282-
Public: Redoes one or more operations.
285+
Public: Redoes the latest Transaction on the redo stack.
283286
284287
Returns null or {Object} of shape:
285288
* `markers` {Object} of shape:
@@ -332,9 +335,13 @@ class Document {
332335
}
333336

334337
/*
335-
Public: Sets the interval for grouping transactions.
338+
Public: Sets the interval for grouping Transactions.
339+
340+
If the updates grouping interval would contain the two latest transactions,
341+
they are grouped.
336342
337343
* `groupingInterval` {Number} of milliseconds
344+
338345
*/
339346
applyGroupingInterval (groupingInterval) {
340347
const topEntry = this.undoStack[this.undoStack.length - 1]
@@ -419,6 +426,9 @@ class Document {
419426
/*
420427
Public: Reverts the document to a checkpoint in the undo stack.
421428
429+
If a barrier exists in the undo stack before the checkpoint matching
430+
`checkpointId`, the reversion fails.
431+
422432
* `checkpointId` {Number}
423433
* `options` {Object} of shape:
424434
* `deleteCheckpoint` {Bool}
@@ -791,7 +801,6 @@ class Document {
791801
792802
Returns {Object} of shape:
793803
* `markerUpdates` {Object} of shape:
794-
// TODO confirm site ID here
795804
* {Number} Site ID
796805
* {Number} Marker layer ID
797806
* {Number} Marker ID

lib/serialization.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
const {Operation} = require('./teletype-crdt_pb')
22

3+
/*
4+
Public: Serializes an operation.
5+
6+
* `op` operation {Object}, either a splice, undo, or marker update.
7+
8+
Returns a serialize message {Object}
9+
*/
310
function serializeOperation (op) {
411
const operationMessage = new Operation()
512
switch (op.type) {
@@ -118,6 +125,13 @@ function serializePoint ({row, column}) {
118125
return pointMessage
119126
}
120127

128+
/*
129+
Public: Serializes an operation.
130+
131+
* `operationMessage` operation message {Object}
132+
133+
Returns an operation {Object}
134+
*/
121135
function deserializeOperation (operationMessage) {
122136
if (operationMessage.hasSplice()) {
123137
return deserializeSplice(operationMessage.getSplice())

0 commit comments

Comments
 (0)