08-27-周三_17-09-29

This commit is contained in:
2025-08-27 17:10:05 +08:00
commit 86df397d8f
12735 changed files with 1145479 additions and 0 deletions

30
node_modules/dnode/test/bidirectional.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
var dnode = require('../');
var test = require('tape');
test('bidirectional', function (t) {
t.plan(3);
var server = dnode(function (client) {
this.timesX = function (n,f) {
t.equal(n, 3, "timesX's n == 3");
client.x(function (x) {
t.equal(x, 20, 'client.x == 20');
f(n * x);
});
};
});
var client = dnode({
x : function (f) { f(20) }
});
client.on('remote', function (remote) {
remote.timesX(3, function (res) {
t.equal(res, 60, 'result of 20 * 3 == 60');
client.end();
server.end();
});
});
client.pipe(server).pipe(client);
});