reptree 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # RepTree
2
+
3
+ A tree data structure using CRDTs for seamless replication between peers.
4
+
5
+ ## Description
6
+
7
+ RepTree is a tree data structure for storing vertices with properties.
8
+ It uses 2 conflict-free replicated data types (CRDTs) to manage seamless replication between peers:
9
+ - A move tree CRDT is used for the tree structure (https://martin.kleppmann.com/papers/move-op.pdf).
10
+ - A last writer wins (LWW) CRDT is used for properties.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install reptree
16
+ # or
17
+ yarn add reptree
18
+ # or
19
+ pnpm add reptree
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```typescript
25
+ import { RepTree } from 'reptree';
26
+
27
+ // Create a new tree
28
+ const tree = new RepTree('peer1');
29
+
30
+ // Root vertex is created automatically
31
+ const rootVertex = tree.rootVertex;
32
+ const rootId = rootVertex.id;
33
+
34
+ // Add child vertices
35
+ const childVertex = tree.newVertex(rootId);
36
+ const childId = childVertex.id;
37
+
38
+ // Set properties
39
+ tree.setVertexProperty(childId, 'name', 'Child Node');
40
+
41
+ // Move vertices
42
+ tree.moveVertex(childId, anotherParentId);
43
+
44
+ // Syncing between trees
45
+ const otherTree = new RepTree('peer2');
46
+ const ops = tree.getAllOps();
47
+ otherTree.merge(ops);
48
+ ```
49
+
50
+ ## License
51
+
52
+ MIT