mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
add msg.property option to rbe, randon, smooth and base64 nodes
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user