From cc72f892f766ce15df06e43652190cc76dfefb1c Mon Sep 17 00:00:00 2001 From: Kazuhito Yokoi Date: Fri, 27 Sep 2019 17:14:42 +0900 Subject: [PATCH] Support msg.nodeMessageBufferMaxLength --- .../@node-red/nodes/core/function/89-delay.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/node_modules/@node-red/nodes/core/function/89-delay.js b/packages/node_modules/@node-red/nodes/core/function/89-delay.js index 079227194..a2245c4ab 100644 --- a/packages/node_modules/@node-red/nodes/core/function/89-delay.js +++ b/packages/node_modules/@node-red/nodes/core/function/89-delay.js @@ -192,6 +192,18 @@ module.exports = function(RED) { } else if (node.pauseType === "rate") { node.on("input", function(msg) { + if (msg.nodeMessageBufferMaxLength) { + node.debug("msg.nodeMessageBufferMaxLength = " + msg.nodeMessageBufferMaxLength); + if (msg.nodeMessageBufferMaxLength == 0) { + clearInterval(node.intervalID); + node.intervalID = -1; + node.buffer = []; + } else if (msg.nodeMessageBufferMaxLength < node.buffer.length) { + node.buffer = node.buffer.splice(msg.nodeMessageBufferMaxLength, + node.buffer.length - msg.nodeMessageBufferMaxLength); + } + _maxKeptMsgsCount = msg.nodeMessageBufferMaxLength; + } if (!node.drop) { if (node.intervalID !== -1) { if (msg.hasOwnProperty("rate") && node.rate !== msg.rate) {