From e41893eccbfbf60e8abafdd8c24e8a719f79fdaf Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 22 Apr 2015 13:18:55 +0100 Subject: [PATCH] Random node always returns floating point --- function/random/package.json | 2 +- function/random/random.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/function/random/package.json b/function/random/package.json index 541fa5b7..89fba90b 100644 --- a/function/random/package.json +++ b/function/random/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-random", - "version" : "0.0.2", + "version" : "0.0.3", "description" : "A Node-RED node that that when triggered generates a random number between two values.", "dependencies" : { }, diff --git a/function/random/random.js b/function/random/random.js index dda4d6ed..767632fb 100644 --- a/function/random/random.js +++ b/function/random/random.js @@ -1,5 +1,5 @@ /** - * Copyright 2014 IBM Corp. + * Copyright 2014, 2015 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ module.exports = function(RED) { this.inte = n.inte || false; var node = this; this.on("input", function(msg) { - if (node.inte === true) { + if (node.inte == "true" || node.inte === true) { msg.payload = 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;