Skip to content

Instantly share code, notes, and snippets.

@sintaxi
Created September 4, 2012 02:58
Show Gist options
  • Save sintaxi/3616045 to your computer and use it in GitHub Desktop.
Save sintaxi/3616045 to your computer and use it in GitHub Desktop.
var dnode = require('dnode');
exports.createServer = function(){
var server = dnode({
foo : function (s, cb) {
cb(s.replace(/[aeiou]{2,}/, 'oo').toUpperCase())
}
})
return server
}
exports.createClient = function(port){
var remote = function(method){
var method = method;
return function(){
var args = Array().slice.call(arguments)
var callback = args.pop()
var d = dnode.connect(port)
d.on('remote', function (remote) {
args.push(function(){
callback.apply(this, Array().slice.call(arguments))
d.end()
})
remote[method].apply(this, args)
})
}
}
var transform = remote
return {
transform: remote("transform")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment