Skip to content

Commit a1aea93

Browse files
committed
Changed integers for patch instructions (New object, Splice, Swap)
1 parent 5900de0 commit a1aea93

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ npm-debug.log*
1616

1717
# Files
1818
dist
19-
test*.*
19+
testing/

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ npm-debug.log*
1818
src/
1919
test/
2020
examples/
21-
test*.*
21+
testing/
2222
.editorconfig
2323
.travis.yml
2424
Gruntfile.js

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dop",
3-
"version": "0.22.10",
3+
"version": "0.23.0",
44
"main": "./dist/dop.nodejs.js",
55
"browser": "./dist/dop.js",
66
"unpkg": "./dist/dop.min.js",

src/protocol/instructions.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ dop.protocol.instructions = {
2323
// Sending the same request without parameters means a cancel/abort of the request
2424
// [1234]
2525

26-
// Subscriptor -> Owner
26+
// Subscriber -> Owner
2727
subscribe: 1, // [ 1234, <instruction>, <params...>]
2828
// [-1234, 0, <object_id>, <data_object>]
2929
// [-1234, 0, <object_id>, ['path']]
3030

31-
// Subscriptor -> Owner
31+
// Subscriber -> Owner
3232
unsubscribe: 2, // [ 1234, <instruction>, <object_id>]
3333
// [-1234, 0]
3434

35-
// Subscriptor -> Owner
36-
call: 3, // [ 1234, <instruction>, <object_id>, ['path','path'], [<params...>]]
35+
// Subscriber -> Owner
36+
call: 3, // [ 1234, <instruction>, <object_id>, ['path','subpath'], [<params...>]]
3737
// [-1234, 0, <return>]
3838

39-
// Owner -> Subscriptor
40-
broadcast: 4, // [ 1234, <instruction>, <object_id>, ['path','path'], [<params...>]]
39+
// Owner -> Subscriber
40+
broadcast: 4, // [ 1234, <instruction>, <object_id>, ['path','subpath'], [<params...>]]
4141
// [-1234, 0, <return>]
4242

43-
// Owner -> Subscriptor
43+
// Owner -> Subscriber
4444
patch: 5, // [ 1234, <instruction>, <object_id>, <version>, <patch>]
4545
// [-1234, 0]
4646

src/protocol/instructionsPatchs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
dop.protocol.instructionsPatchs = {
33
undefined: '~U', // Delete
44
function: '~F', // Remote function
5-
object: 2, // New object or array
6-
splice: 3, // Splice array
7-
swaps: 4, // Swap array
5+
object: 0, // New object or array
6+
splice: 1, // Splice array
7+
swaps: 2, // Swap array
88

99
// Non standards, only for JavaScript
1010
nan: '~N',

test/getpatchs.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ test(header+'Setting an array and mutating it', function(t) {
125125
var collector = dop.collect();
126126

127127

128-
var patchExpected = [{"array":[2,["c","b",{"B1":"string"},false,true]]}];
128+
var patchExpected = [{"array":[0,["c","b",{"B1":"string"},false,true]]}];
129129
var mutationsExpected = 5;
130130
set(object, 'array', [true,false]);
131131
object.array.push('a','b','c')
@@ -149,7 +149,7 @@ test(header+'Mutating array then mutating nested objects', function(t) {
149149
var collector = dop.collect();
150150

151151

152-
var patchExpected = [{"array":[4,[0,1]]},{"array":{"2":[2,{"B1":false}],"length":3}}];
152+
var patchExpected = [{"array":[2,[0,1]]},{"array":{"2":[0,{"B1":false}],"length":3}}];
153153
var mutationsExpected = 3;
154154
object.array.reverse();
155155
set(object.array, 2, {B1:false});
@@ -170,7 +170,7 @@ test(header+'Mutating nested objects then mutating parent array', function(t) {
170170
var collector = dop.collect();
171171

172172

173-
var patchExpected = [{"array":{"2":[2,{"B1":false}],"length":3}},{"array":[4,[0,2]]}];
173+
var patchExpected = [{"array":{"2":[0,{"B1":false}],"length":3}},{"array":[2,[0,2]]}];
174174
var mutationsExpected = 3;
175175
set(object.array, 2, {B1:false});
176176
object.array.reverse();
@@ -191,7 +191,7 @@ test(header+'Mutating array twice', function(t) {
191191
var collector = dop.collect();
192192

193193

194-
var patchExpected = [{"array":[[3,[3,0,5,4,6]],[4,[0,1,1,2,3,4]]]}];
194+
var patchExpected = [{"array":[[1,[3,0,5,4,6]],[2,[0,1,1,2,3,4]]]}];
195195
var mutationsExpected = 2;
196196
object.array.push(5,4,6);
197197
object.array.sort();
@@ -211,7 +211,7 @@ test(header+'Mutating array and mutating array deeper', function(t) {
211211
var collector = dop.collect();
212212

213213

214-
var patchExpected = [{"array":[4,[0,2]]},{"array":{"0":[4,[0,1]]}}];
214+
var patchExpected = [{"array":[2,[0,2]]},{"array":{"0":[2,[0,1]]}}];
215215
var mutationsExpected = 2;
216216
object.array.reverse();
217217
object.array[0].reverse();
@@ -230,7 +230,7 @@ test(header+'Mutating array deeper and mutating container', function(t) {
230230
var collector = dop.collect();
231231

232232

233-
var patchExpected = [{"array":{"2":[4,[0,1]]}},{"array":[4,[0,2]]}];
233+
var patchExpected = [{"array":{"2":[2,[0,1]]}},{"array":[2,[0,2]]}];
234234
var mutationsExpected = 2;
235235
object.array[2].reverse();
236236
object.array.reverse();

test/getunpatchs.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ test(header+'Setting an array and mutating it', function(t) {
130130
var collector = dop.collect();
131131

132132

133-
var patchExpected = [{"array":[4,[2,0]]},{"array":undefined}];
133+
var patchExpected = [{"array":[2,[2,0]]},{"array":undefined}];
134134
var mutationsExpected = 4;
135135
set(object, 'array', [true,false]);
136136
set(object.array, 2, {B1:[true,false]});
@@ -152,7 +152,7 @@ test(header+'Mutating array then mutating nested objects', function(t) {
152152
var collector = dop.collect();
153153

154154

155-
var patchExpected = [{"array":{"2":undefined,"length":2}},{"array":[4,[1,0]]}];
155+
var patchExpected = [{"array":{"2":undefined,"length":2}},{"array":[2,[1,0]]}];
156156
var mutationsExpected = 3;
157157
object.array.reverse();
158158
set(object.array, 2, {B1:false});
@@ -173,7 +173,7 @@ test(header+'Mutating nested objects then mutating parent array', function(t) {
173173
var collector = dop.collect();
174174

175175

176-
var patchExpected = [{"array":[4,[2,0]]},{"array":{"2":undefined,"length":2}}];
176+
var patchExpected = [{"array":[2,[2,0]]},{"array":{"2":undefined,"length":2}}];
177177
var mutationsExpected = 3;
178178
set(object.array, 2, {B1:false});
179179
object.array.reverse();
@@ -194,7 +194,7 @@ test(header+'Mutating array twice', function(t) {
194194
var collector = dop.collect();
195195

196196

197-
var patchExpected = [{"array":[[4,[4,3,2,1,1,0]],[3,[3,3]]]}];
197+
var patchExpected = [{"array":[[2,[4,3,2,1,1,0]],[1,[3,3]]]}];
198198
var mutationsExpected = 2;
199199
object.array.push(5,4,6);
200200
object.array.sort();
@@ -213,7 +213,7 @@ test(header+'Mutating array and mutating array deeper', function(t) {
213213
var collector = dop.collect();
214214

215215

216-
var patchExpected = [{"array":{"0":[4,[1,0]]}},{"array":[4,[2,0]]}];
216+
var patchExpected = [{"array":{"0":[2,[1,0]]}},{"array":[2,[2,0]]}];
217217
var mutationsExpected = 2;
218218
object.array.reverse();
219219
object.array[0].reverse();
@@ -232,7 +232,7 @@ test(header+'Mutating array deeper and mutating container', function(t) {
232232
var collector = dop.collect();
233233

234234

235-
var patchExpected = [{"array":[4,[2,0]]},{"array":{"2":[4,[1,0]]}}];
235+
var patchExpected = [{"array":[2,[2,0]]},{"array":{"2":[2,[1,0]]}}];
236236
var mutationsExpected = 2;
237237
object.array[2].reverse();
238238
object.array.reverse();

0 commit comments

Comments
 (0)