Skip to content

Commit

Permalink
logic: fix OR and XNOR (#6)
Browse files Browse the repository at this point in the history
* logic: fix OR
* logic: fix XNOR
* bump version
  • Loading branch information
Sineos authored Nov 25, 2018
1 parent 09e3b41 commit 7013d33
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions nodes/combine-logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,19 @@ module.exports = function (RED) {
topics: this.distinction === 'topic' ? topics : undefined,
messages: this.distinction === '_msgid' ? topics : undefined,
and: payloads.reduce((pv, cv) => pv && cv),
or: this.or(payloads),
or: payloads.reduce((pv, cv) => pv || cv),
xor: payloads.reduce((pv, cv) => pv ^ cv)
};

combine.nand = !combine.and;
combine.nor = !combine.or;
combine.xnor = !combine.xnor;
combine.xnor = !combine.xor;

return Object.assign({
topic: this.topic,
payload: combine[this.operator]
}, combine);
}

or(array) {
for (let i = 0, len = array.length; i < len; i++) {
if (array[i]) {
return true;
}
}
}
}

RED.nodes.registerType('combine-logic', CombineLogicNode);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-combine",
"version": "1.6.1",
"version": "1.6.2",
"description": "Node-RED Nodes that output combinations of consecutive incoming messages",
"keywords": [
"node-red",
Expand Down

0 comments on commit 7013d33

Please sign in to comment.