mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Fix random node to handle to or from being 0
and add tests to close #955
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-random",
|
||||
"version" : "0.4.0",
|
||||
"version" : "0.4.1",
|
||||
"description" : "A Node-RED node that when triggered generates a random number between two values.",
|
||||
"dependencies" : {
|
||||
},
|
||||
|
@@ -18,9 +18,8 @@ module.exports = function(RED) {
|
||||
if (node.low) { // if the the node has a value use it
|
||||
tmp.low = Number(node.low);
|
||||
} else if ('from' in msg) { // else see if a 'from' is in the msg
|
||||
if (Number(msg.from)) { // if it is, and is a number, use it
|
||||
tmp.low = Number(msg.from);
|
||||
} else { // otherwise setup NaN error
|
||||
tmp.low = Number(msg.from);
|
||||
if (isNaN(msg.from)) { // if it isn't a number setup NaN error
|
||||
tmp.low = NaN;
|
||||
tmp.low_e = " From: " + msg.from; // setup to show bad incoming msg.from
|
||||
}
|
||||
@@ -31,9 +30,8 @@ module.exports = function(RED) {
|
||||
if (node.high) { // if the the node has a value use it
|
||||
tmp.high = Number(node.high);
|
||||
} else if ('to' in msg) { // else see if a 'to' is in the msg
|
||||
if (Number(msg.to)) { // if it is, and is a number, use it
|
||||
tmp.high = Number(msg.to);
|
||||
} else { // otherwise setup NaN error
|
||||
tmp.high = Number(msg.to);
|
||||
if (isNaN(msg.to)) { // if it isn't a number setup NaN error
|
||||
tmp.high = NaN
|
||||
tmp.high_e = " To: " + msg.to // setup to show bad incoming msg.to
|
||||
}
|
||||
|
Reference in New Issue
Block a user