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

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,7 +32,6 @@ 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)) {
@ -52,7 +51,6 @@ module.exports = function(RED) {
//node.warn("No BlinkStick found");
node.led = blinkstick.findFirst();
}
}
});
if (Object.size(node.led) === 0) {
node.error("No BlinkStick found");

View File

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

View File

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

View File

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

View File

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

View File

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