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

Merge pull request #68 from hindessm/remove-redundant-null-checks

Remove redundant msg != null checks.
This commit is contained in:
Nick O'Leary 2014-09-08 21:53:47 +01:00
commit 01d1eadf65
6 changed files with 39 additions and 51 deletions

View File

@ -32,7 +32,6 @@ module.exports = function(RED) {
var node = this; var node = this;
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
if (Object.size(node.led) !== 0) { if (Object.size(node.led) !== 0) {
try { try {
if (p2.test(msg.payload)) { if (p2.test(msg.payload)) {
@ -52,7 +51,6 @@ module.exports = function(RED) {
//node.warn("No BlinkStick found"); //node.warn("No BlinkStick found");
node.led = blinkstick.findFirst(); node.led = blinkstick.findFirst();
} }
}
}); });
if (Object.size(node.led) === 0) { if (Object.size(node.led) === 0) {
node.error("No BlinkStick found"); node.error("No BlinkStick found");

View File

@ -43,7 +43,6 @@ module.exports = function(RED) {
if (device) { if (device) {
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
if (p1.test(msg.payload)) { if (p1.test(msg.payload)) {
var r = parseInt(msg.payload.slice(1,3),16); var r = parseInt(msg.payload.slice(1,3),16);
var g = parseInt(msg.payload.slice(3,5),16); var g = parseInt(msg.payload.slice(3,5),16);
@ -57,7 +56,6 @@ module.exports = function(RED) {
} else { } else {
node.warn("incompatable input - " + msg.payload); node.warn("incompatable input - " + msg.payload);
} }
}
}); });
} else { } else {
node.warn("no digispark RGB found"); node.warn("no digispark RGB found");

View File

@ -25,14 +25,12 @@ module.exports = function(RED) {
var node = this; var node = this;
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
var state = 0; var state = 0;
if ( msg.payload == 1 || msg.payload === true || msg.payload == "on" ) { state = 1; } if ( msg.payload == 1 || msg.payload === true || msg.payload == "on" ) { state = 1; }
node.wemoSwitch.setBinaryState(state, function(err, result) { node.wemoSwitch.setBinaryState(state, function(err, result) {
if (err) { node.warn(err); } if (err) { node.warn(err); }
//else { node.log(result); } //else { node.log(result); }
}); });
}
}); });
} }
RED.nodes.registerType("wemo out",WemoOut); RED.nodes.registerType("wemo out",WemoOut);

View File

@ -25,7 +25,6 @@ module.exports = function(RED) {
var node = this; var node = this;
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
var mac = this.mac || msg.mac || null; var mac = this.mac || msg.mac || null;
if (mac != null) { if (mac != null) {
if (chk.test(mac)) { if (chk.test(mac)) {
@ -36,7 +35,6 @@ module.exports = function(RED) {
else { node.warn('WOL: bad mac address "'+mac+'"'); } else { node.warn('WOL: bad mac address "'+mac+'"'); }
} }
else { node.warn("WOL: no mac address specified"); } else { node.warn("WOL: no mac address specified"); }
}
}); });
} }
RED.nodes.registerType("wake on lan",WOLnode); RED.nodes.registerType("wake on lan",WOLnode);

View File

@ -44,7 +44,6 @@ module.exports = function(RED) {
if (mpc != null) { if (mpc != null) {
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
try { try {
//node.mpc.command(msg.payload); //node.mpc.command(msg.payload);
node.mpc.command(msg.payload, msg.param, function(err, results) { node.mpc.command(msg.payload, msg.param, function(err, results) {
@ -52,7 +51,6 @@ module.exports = function(RED) {
//else { console.log(results); } //else { console.log(results); }
}); });
} catch (err) { node.log("error: "+err); } } catch (err) { node.log("error: "+err); }
}
}); });
node.mpc.on('error', function(err) { node.mpc.on('error', function(err) {

View File

@ -32,13 +32,11 @@ function DDBOutNode(n) {
var ddb = new aws.DynamoDB(); var ddb = new aws.DynamoDB();
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
ddb.putItem({ "TableName": this.table, ddb.putItem({ "TableName": this.table,
"Item": attrWrapper.wrap(msg.payload) }, "Item": attrWrapper.wrap(msg.payload) },
function(err, data) { function(err, data) {
if (err) { util.log(err); } if (err) { util.log(err); }
}); });
}
}); });
} }
RED.nodes.registerType("ddb out", DDBOutNode); RED.nodes.registerType("ddb out", DDBOutNode);