@@ -14,75 +14,75 @@ import {
1414import { Tree } from './tree' ;
1515import { Node } from './node' ;
1616
17- export class CrdtTree < T > {
18- operationLogs : OperationLog < T > [ ] = [ ] ;
17+ export class CrdtTree {
18+ operationLogs : OperationLog [ ] = [ ] ;
1919 clock : Clock ;
20- tree = new Tree < T > ( ) ;
20+ tree = new Tree ( ) ;
2121
2222 constructor ( id : string ) {
2323 this . clock = new Clock ( id ) ;
2424 }
2525
26- get ( id : string ) : Node < T > | undefined {
26+ get ( id : string ) : Node | undefined {
2727 return this . tree . get ( id ) ;
2828 }
2929
30- addLog ( log : OperationLog < T > ) {
30+ addLog ( log : OperationLog ) {
3131 this . operationLogs . push ( log ) ;
3232 }
3333
3434 generateOperationAdd (
3535 targetId : string ,
3636 parentId : string ,
37- description : T ,
38- ) : OperationAdd < T > {
37+ description : string ,
38+ ) : OperationAdd {
3939 this . clock . increment ( ) ;
4040 const clock = this . clock . copy ( ) ;
41- const input : OperationAddInput < T > = {
41+ const input : OperationAddInput = {
4242 id : targetId ,
4343 parentId,
4444 description,
4545 clock,
4646 } ;
47- return new OperationAdd < T > ( input ) ;
47+ return new OperationAdd ( input ) ;
4848 }
4949
50- generateOperationDelete ( targetId : string ) : OperationDelete < T > {
50+ generateOperationDelete ( targetId : string ) : OperationDelete {
5151 this . clock . increment ( ) ;
5252 const clock = this . clock . copy ( ) ;
5353 const input : OperationInput = {
5454 id : targetId ,
5555 clock,
5656 } ;
57- return new OperationDelete < T > ( input ) ;
57+ return new OperationDelete ( input ) ;
5858 }
5959
60- generateOperationMove ( targetId : string , parentId : string ) : OperationMove < T > {
60+ generateOperationMove ( targetId : string , parentId : string ) : OperationMove {
6161 this . clock . increment ( ) ;
6262 const clock = this . clock . copy ( ) ;
6363 const input : OperationMoveInput = {
6464 id : targetId ,
6565 parentId,
6666 clock,
6767 } ;
68- return new OperationMove < T > ( input ) ;
68+ return new OperationMove ( input ) ;
6969 }
7070
7171 generateOperationUpdate (
7272 targetId : string ,
73- description : T ,
74- ) : OperationUpdate < T > {
73+ description : string ,
74+ ) : OperationUpdate {
7575 this . clock . increment ( ) ;
7676 const clock = this . clock . copy ( ) ;
77- const input : OperationUpdateInput < T > = {
77+ const input : OperationUpdateInput = {
7878 id : targetId ,
7979 description,
8080 clock,
8181 } ;
82- return new OperationUpdate < T > ( input ) ;
82+ return new OperationUpdate ( input ) ;
8383 }
8484
85- applyOperation ( operation : Operation < T > ) {
85+ applyOperation ( operation : Operation ) {
8686 this . clock = this . clock . merge ( operation . clock ) ;
8787
8888 if ( this . operationLogs . length === 0 ) {
@@ -94,7 +94,7 @@ export class CrdtTree<T> {
9494 const lastOperation =
9595 this . operationLogs [ this . operationLogs . length - 1 ] . operation ;
9696 if ( operation . clock . compare ( lastOperation . clock ) === COMPARE . LESS ) {
97- const prevLog = this . operationLogs . pop ( ) as OperationLog < T > ;
97+ const prevLog = this . operationLogs . pop ( ) as OperationLog ;
9898 prevLog . operation . undoOperation ( this . tree , prevLog ) ;
9999 this . applyOperation ( operation ) ;
100100 const redoLog = prevLog . operation . redoOperation ( this . tree , prevLog ) ;
@@ -105,25 +105,25 @@ export class CrdtTree<T> {
105105 }
106106 }
107107
108- applyOperations ( operations : Operation < T > [ ] ) {
108+ applyOperations ( operations : Operation [ ] ) {
109109 for ( const operation of operations ) this . applyOperation ( operation ) ;
110110 }
111111
112- static parse < T > ( json : string ) {
112+ static parse ( json : string ) {
113113 const parsedJson = JSON . parse ( json ) ;
114- const crdtTree = new CrdtTree < T > ( '0' ) ;
114+ const crdtTree = new CrdtTree ( '0' ) ;
115115 crdtTree . clock = Clock . parse ( JSON . stringify ( parsedJson . clock ) ) ;
116- crdtTree . tree = Tree . parse < T > ( JSON . stringify ( parsedJson . tree ) ) ;
116+ crdtTree . tree = Tree . parse ( JSON . stringify ( parsedJson . tree ) ) ;
117117
118118 const operationTypeMap = {
119- add : OperationAdd . parse < T > ,
120- delete : OperationDelete . parse < T > ,
121- move : OperationMove . parse < T > ,
122- update : OperationUpdate . parse < T > ,
119+ add : OperationAdd . parse ,
120+ delete : OperationDelete . parse ,
121+ move : OperationMove . parse ,
122+ update : OperationUpdate . parse ,
123123 } ;
124124
125125 const parsedOperationLogs = parsedJson . operationLogs . map (
126- ( operationLog : OperationLog < T > ) => {
126+ ( operationLog : OperationLog ) => {
127127 const operationType = operationLog . operation . operationType ;
128128 operationLog . operation = operationTypeMap [ operationType ] (
129129 operationLog . operation ,
0 commit comments