forked from kb18519142009/android_interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircular.js
More file actions
33 lines (26 loc) · 756 Bytes
/
circular.js
File metadata and controls
33 lines (26 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var dnode = require('../');
var test = require('tape');
test('circular refs', function (t) {
t.plan(7);
var server = dnode({
sendObj : function (ref, f) {
t.equal(ref.a, 1);
t.equal(ref.b, 2);
t.deepEqual(ref.c, ref);
ref.d = ref.c;
f(ref);
}
});
var client = dnode();
client.on('remote', function (remote) {
var obj = { a : 1, b : 2 };
obj.c = obj;
remote.sendObj(obj, function (ref) {
t.equal(ref.a, 1);
t.equal(ref.b, 2);
t.deepEqual(ref.c, ref);
t.deepEqual(ref.d, ref);
});
});
client.pipe(server).pipe(client);
});