File tree 2 files changed +56
-2
lines changed
2 files changed +56
-2
lines changed Original file line number Diff line number Diff line change 1
1
* .swp
2
2
.DS_Store
3
- test /* .js
4
- test /** /* .js
5
3
node_modules
6
4
webclient /*
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Simple OT representing a number.
3
+ *
4
+ * Snapshots and operations are just integers. Applying an operation to an
5
+ * integer corresponds to adding the number. It supports inversion.
6
+ *
7
+ * It is used mainly for testing
8
+ */
9
+ module . exports = {
10
+ name : 'simple-number' ,
11
+ uri : 'http://sharejs.org/types/simple-number' ,
12
+
13
+ /**
14
+ * Creates snapshot with initial data
15
+ *
16
+ * @param {Number } [initial=0]
17
+ * @return {Number }
18
+ */
19
+ create : function ( initial ) {
20
+ if ( initial == null )
21
+ initial = 0 ;
22
+ return initial ;
23
+ } ,
24
+
25
+ /**
26
+ * Apply an operation to a snapshot and return new snapshot.
27
+ */
28
+ apply : function ( snapshot , op ) {
29
+ return snapshot + op ;
30
+ } ,
31
+
32
+ /**
33
+ * Compose operations
34
+ */
35
+ transform : function ( op1 , op2 ) {
36
+ return op1 + op2 ;
37
+ } ,
38
+
39
+ invert : function ( operation ) {
40
+ return - operation ;
41
+ } ,
42
+
43
+ /**
44
+ * Mixin to manipulate snapshots
45
+ *
46
+ * The receiver of this mixin must implement getSnapshot() and
47
+ * submitOp(operation, [callback]).
48
+ */
49
+ api : {
50
+ get : function ( ) { return this . getSnapshot ( ) } ,
51
+ add : function ( value , callback ) {
52
+ return this . submitOp ( value , callback ) ;
53
+ }
54
+ }
55
+ } ;
56
+
You can’t perform that action at this time.
0 commit comments