Created
June 1, 2016 15:20
-
-
Save Wardormeur/eec5a9df20973eb73333e2a0b03b82bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function math(options) { | |
this.add('role:math,cmd:sum', function sum(msg, respond) { | |
respond(null, { answer: msg.left + msg.right }) | |
}) | |
this.add('role:math,cmd:product', function product(msg, respond) { | |
respond(null, { answer: msg.left * msg.right }) | |
}) | |
this.add('role:ope, cmd:addOne', function addOne(msg, done){ | |
msg.left = Number(msg.msg.left).valueOf()+1; | |
msg.right = Number(msg.msg.right).valueOf()+1; | |
done(null, msg); | |
}); | |
this.wrap('role:math', function (msg, respond) { | |
this.act({role :'ope', cmd:'addOne', msg: msg}, function(err, out){ | |
msg.left = out.left; | |
msg.right = out.right; | |
console.log('msg.left', out.left); | |
this.prior(msg, respond); | |
}); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment