Comparing version 0.5.1 to 0.5.2
@@ -193,21 +193,2 @@ var net = require('net'); | ||
// wrapper to turn synchronous functions into asynchronous ones with the | ||
// result callback inserted as the last argument | ||
DNode.sync = function (f) { | ||
return function () { | ||
var args = [].concat.apply([],arguments); | ||
var argv = args.slice(0,-1); | ||
var cb = args.slice(-1)[0]; | ||
cb(f.apply(this,argv)); | ||
}; | ||
}; | ||
// Expose prototype methods so DNode can get at them | ||
DNode.expose = function (obj, name) { | ||
obj[name] = function () { | ||
var args = [].slice.call(arguments); | ||
return obj.constructor.prototype[name].apply(obj, args); | ||
}; | ||
}; | ||
function parseArgs (argv) { | ||
@@ -214,0 +195,0 @@ var params = {}; |
{ | ||
"name" : "dnode", | ||
"version" : "0.5.1", | ||
"version" : "0.5.2", | ||
"description" : "Call remote methods and callbacks with a JSON-based protocol. RMI for network sockets and the browser too!", | ||
@@ -5,0 +5,0 @@ "modules" : { |
@@ -8,5 +8,4 @@ var DNode = require('dnode'); | ||
var ev = new EventEmitter; | ||
ev.emit = ev.emit.bind(ev); | ||
DNode.expose(ev, 'emit'); | ||
ev.on('test1', function (a, b, c) { | ||
@@ -23,5 +22,5 @@ assert.equal(a, 1); | ||
var self = this; | ||
DNode.expose(self, 'on'); | ||
DNode.expose(self, 'removeListener'); | ||
DNode.expose(self, 'emit'); | ||
self.on = self.on.bind(self); | ||
self.removeListener = self.removeListener.bind(self); | ||
self.emit = self.emit.bind(self); | ||
@@ -28,0 +27,0 @@ self.pass = function (name, em) { |
@@ -13,6 +13,6 @@ var DNode = require('dnode'); | ||
moo : function (reply) { reply(100) }, | ||
sTimesTen : DNode.sync(function (n) { | ||
sTimesTen : function (n, cb) { | ||
assert.equal(n, 5); | ||
return n * 10; | ||
}), | ||
cb(n * 10); | ||
}, | ||
}).listen(port.toString()); // test for stringified ports too why not | ||
@@ -19,0 +19,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
361
101897
2231