1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

clarify random node info language

This commit is contained in:
Dave Conway-Jones 2018-09-24 19:40:33 +01:00
parent b0d98cca01
commit d32f11910b
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
3 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-random", "name" : "node-red-node-random",
"version" : "0.1.0", "version" : "0.1.1",
"description" : "A Node-RED node that when triggered generates a random number between two values.", "description" : "A Node-RED node that when triggered generates a random number between two values.",
"dependencies" : { "dependencies" : {
}, },

View File

@ -28,8 +28,10 @@
70% 70%
<script type="text/x-red" data-help-name="random"> <script type="text/x-red" data-help-name="random">
<p>Generates a random number between a low and high value.</p> <p>Generates a random number between a low and high value.</p>
<p>If you return an integer it can <i>include</i> both the low and high values.</p> <p>If you return an integer it can <i>include</i> both the low and high values.
<p>If you return a floating point value it will be <i>between</i> the low and high values.</p> <code>min <= n <= max</code></p>
<p>If you return a floating point value it will be from the low value, up to, but
not including the high value. <code>min <= n < max</code></p>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">

View File

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