File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -196,10 +196,10 @@ export class ClockVector extends LogicalClock implements IClockVector {
196196 }
197197
198198 /**
199- * Returns a human-readable string representation of the vector clock.
199+ * Returns a human-readable string representation of the clock vector .
200200 *
201201 * @param tab String to use for indentation.
202- * @returns Human-readable string representation of the vector clock.
202+ * @returns Human-readable string representation of the clock vector .
203203 */
204204 public toString ( tab : string = '' ) : string {
205205 const last = this . peers . size ;
@@ -236,4 +236,13 @@ export class ServerClockVector extends LogicalClock implements IClockVector {
236236 public fork ( ) : ServerClockVector {
237237 return new ServerClockVector ( SESSION . SERVER , this . time ) ;
238238 }
239+
240+ /**
241+ * Returns a human-readable string representation of the clock vector.
242+ *
243+ * @returns Human-readable string representation of the clock vector.
244+ */
245+ public toString ( ) : string {
246+ return `clock ${ this . sid } .${ this . time } ` ;
247+ }
239248}
Original file line number Diff line number Diff line change @@ -41,6 +41,13 @@ export class File implements Printable {
4141 }
4242 if ( ! log ) throw new Error ( 'NO_HISTORY' ) ;
4343 if ( ! decodedModel ) decodedModel = log . replayToEnd ( ) ;
44+ if ( frontier . length ) {
45+ for ( const patch of frontier ) {
46+ const patchDecoded = decodePatch ( patch ) ;
47+ decodedModel . applyPatch ( patchDecoded ) ;
48+ log . push ( patchDecoded ) ;
49+ }
50+ }
4451 const file = new File ( decodedModel , log ) ;
4552 return file ;
4653 }
Original file line number Diff line number Diff line change @@ -102,3 +102,20 @@ describe('.toBinary()', () => {
102102 }
103103 } ) ;
104104} ) ;
105+
106+ describe ( '.unserialize()' , ( ) => {
107+ test ( 'applies frontier' , ( ) => {
108+ const { file, model} = setup ( { foo : 'bar' } ) ;
109+ const clone = model . clone ( ) ;
110+ clone . api . obj ( [ ] ) . set ( {
111+ xyz : 123 ,
112+ } ) ;
113+ const serialized = file . serialize ( {
114+ history : 'binary' ,
115+ } ) ;
116+ serialized . push ( clone . api . flush ( ) . toBinary ( ) ) ;
117+ expect ( file . model . view ( ) ) . toEqual ( { foo : 'bar' } ) ;
118+ const file2 = File . unserialize ( serialized ) ;
119+ expect ( file2 . model . view ( ) ) . toEqual ( { foo : 'bar' , xyz : 123 } ) ;
120+ } ) ;
121+ } ) ;
You can’t perform that action at this time.
0 commit comments