Remove redundant msg != null checks.

This commit is contained in:
Mark Hindess
2014-09-08 21:42:16 +01:00
parent 68c9e2b41a
commit b1ba8369d4
6 changed files with 39 additions and 51 deletions

View File

@@ -32,27 +32,25 @@ module.exports = function(RED) {
var node = this;
this.on("input", function(msg) {
if (msg != null) {
if (Object.size(node.led) !== 0) {
try {
if (p2.test(msg.payload)) {
var rgb = msg.payload.split(",");
node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255);
}
else {
node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,''));
}
if (Object.size(node.led) !== 0) {
try {
if (p2.test(msg.payload)) {
var rgb = msg.payload.split(",");
node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255);
}
catch (err) {
node.warn("BlinkStick missing ?");
node.led = blinkstick.findFirst();
else {
node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,''));
}
}
else {
//node.warn("No BlinkStick found");
catch (err) {
node.warn("BlinkStick missing ?");
node.led = blinkstick.findFirst();
}
}
else {
//node.warn("No BlinkStick found");
node.led = blinkstick.findFirst();
}
});
if (Object.size(node.led) === 0) {
node.error("No BlinkStick found");