add msg.property option to rbe, randon, smooth and base64 nodes

This commit is contained in:
Dave Conway-Jones
2018-01-30 21:42:14 +00:00
parent 4ed7ab590d
commit be79b6a1c6
17 changed files with 527 additions and 565 deletions

View File

@@ -6,14 +6,17 @@ module.exports = function(RED) {
this.low = Number(n.low || 1);
this.high = Number(n.high || 10);
this.inte = n.inte || false;
this.property = n.property||"payload";
var node = this;
this.on("input", function(msg) {
var value;
if (node.inte == "true" || node.inte === true) {
msg.payload = Math.round(Number(Math.random()) * (node.high - node.low + 1) + node.low - 0.5);
value = Math.round(Number(Math.random()) * (node.high - node.low + 1) + node.low - 0.5);
}
else {
msg.payload = Number(Math.random()) * (node.high - node.low) + node.low;
value = Number(Math.random()) * (node.high - node.low) + node.low;
}
RED.util.setMessageProperty(msg,node.property,value);
node.send(msg);
});
}