From 61681bb1d613e1913986cdc591c7816fcfc600d9 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Fri, 21 Sep 2018 23:02:45 +0900 Subject: [PATCH] lift processQ function --- nodes/core/storage/50-file.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/nodes/core/storage/50-file.js b/nodes/core/storage/50-file.js index abe591c9d..70d9984af 100644 --- a/nodes/core/storage/50-file.js +++ b/nodes/core/storage/50-file.js @@ -153,22 +153,23 @@ module.exports = function(RED) { } } + function processQ(queue) { + var msg = queue[0]; + processMsg(msg, function() { + queue.shift(); + if (queue.length > 0) { + processQ(queue); + } + }); + } + this.on("input", function(msg) { var msgQueue = node.msgQueue; - function processQ() { - var msg = msgQueue[0]; - processMsg(msg, function() { - msgQueue.shift(); - if (msgQueue.length > 0) { - processQ(); - } - }); - } if (msgQueue.push(msg) > 1) { // pending write exists return; } - processQ(); + processQ(msgQueue); }); this.on('close', function() {