mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Fix RBE payload changing downstream (needs cloning before storing)
This commit is contained in:
parent
86ab73662b
commit
e89861f4e3
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-rbe",
|
||||
"version" : "0.1.11",
|
||||
"version" : "0.1.12",
|
||||
"description" : "A Node-RED node that provides report-by-exception (RBE) and deadband capability.",
|
||||
"dependencies" : {
|
||||
},
|
||||
|
@ -25,13 +25,13 @@ module.exports = function(RED) {
|
||||
if (typeof(msg.payload) === "object") {
|
||||
if (typeof(node.previous[t]) !== "object") { node.previous[t] = {}; }
|
||||
if (!RED.util.compareObjects(msg.payload, node.previous[t])) {
|
||||
node.previous[t] = msg.payload;
|
||||
node.previous[t] = RED.util.cloneMessage(msg.payload);
|
||||
if (doSend) { node.send(msg); }
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (msg.payload !== node.previous[t]) {
|
||||
node.previous[t] = msg.payload;
|
||||
node.previous[t] = RED.util.cloneMessage(msg.payload);
|
||||
if (doSend) { node.send(msg); }
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
}
|
||||
else if (Math.abs(n - node.previous[t]) > node.gap) {
|
||||
if (this.func === "deadband" || this.func === "deadbandEq") {
|
||||
if (this.func === "deadband") {
|
||||
if (node.inout === "out") { node.previous[t] = n; }
|
||||
node.send(msg);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ describe('rbe node', function() {
|
||||
msg.should.have.a.property("payload", 10);
|
||||
}
|
||||
else if (c == 3) {
|
||||
msg.should.have.a.property("payload", 22);
|
||||
msg.should.have.a.property("payload", 20);
|
||||
done();
|
||||
}
|
||||
});
|
||||
@ -129,7 +129,7 @@ describe('rbe node', function() {
|
||||
n1.emit("input", {payload:8});
|
||||
n1.emit("input", {payload:10});
|
||||
n1.emit("input", {payload:15});
|
||||
n1.emit("input", {payload:22});
|
||||
n1.emit("input", {payload:20});
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user