From 747af44fc1384f5d5a22ab6b97aa544e1f94ecba Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 1 Jan 2019 23:05:13 +0000 Subject: [PATCH] Tidy up variable naming in split.js --- .../@node-red/nodes/core/logic/17-split.js | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/logic/17-split.js b/packages/node_modules/@node-red/nodes/core/logic/17-split.js index 2c8d48ebc..2bc3bf888 100644 --- a/packages/node_modules/@node-red/nodes/core/logic/17-split.js +++ b/packages/node_modules/@node-red/nodes/core/logic/17-split.js @@ -233,22 +233,22 @@ module.exports = function(RED) { RED.nodes.registerType("split",SplitNode); - var _max_kept_msgs_count; + var _maxKeptMsgsCount; - function max_kept_msgs_count(node) { - if (_max_kept_msgs_count === undefined) { + function maxKeptMsgsCount(node) { + if (_maxKeptMsgsCount === undefined) { var name = "nodeMessageBufferMaxLength"; if (RED.settings.hasOwnProperty(name)) { - _max_kept_msgs_count = RED.settings[name]; + _maxKeptMsgsCount = RED.settings[name]; } else { - _max_kept_msgs_count = 0; + _maxKeptMsgsCount = 0; } } - return _max_kept_msgs_count; + return _maxKeptMsgsCount; } - function apply_r(exp, accum, msg, index, count) { + function applyReduce(exp, accum, msg, index, count) { exp.assign("I", index); exp.assign("N", count); exp.assign("A", accum); @@ -263,7 +263,7 @@ module.exports = function(RED) { }); } - function apply_f(exp, accum, count) { + function applyFixup(exp, accum, count) { exp.assign("N", count); exp.assign("A", accum); return new Promise((resolve,reject) => { @@ -290,8 +290,8 @@ module.exports = function(RED) { var flag = is_right ? -1 : 1; var msgs = group.msgs; return getInitialReduceValue(node, node.exp_init, node.exp_init_type).then(accum => { - var reduce_exp = node.reduce_exp; - var reduce_fixup = node.reduce_fixup; + var reduceExpression = node.reduceExpression; + var fixupExpression = node.fixupExpression; var count = group.count; msgs.sort(function(x,y) { var ix = x.parts.index; @@ -301,10 +301,10 @@ module.exports = function(RED) { return 0; }); - return msgs.reduce((promise, msg) => promise.then(accum => apply_r(reduce_exp, accum, msg, msg.parts.index, count)), Promise.resolve(accum)) + return msgs.reduce((promise, msg) => promise.then(accum => applyReduce(reduceExpression, accum, msg, msg.parts.index, count)), Promise.resolve(accum)) .then(accum => { - if(reduce_fixup !== undefined) { - return apply_f(reduce_fixup, accum, count).then(accum => { + if(fixupExpression !== undefined) { + return applyFixup(fixupExpression, accum, count).then(accum => { node.send({payload: accum}); }); } else { @@ -316,7 +316,7 @@ module.exports = function(RED) { }); } - function reduce_msg(node, msg) { + function reduceMessage(node, msg) { var promise; if (msg.hasOwnProperty('parts')) { var parts = msg.parts; @@ -342,7 +342,7 @@ module.exports = function(RED) { pending_count++; var completeProcess = function() { node.pending_count = pending_count; - var max_msgs = max_kept_msgs_count(node); + var max_msgs = maxKeptMsgsCount(node); if ((max_msgs > 0) && (pending_count > max_msgs)) { node.pending = {}; node.pending_count = 0; @@ -404,8 +404,8 @@ module.exports = function(RED) { var exp_fixup = exp_or_undefined(n.reduceFixup); this.reduce_right = n.reduceRight; try { - this.reduce_exp = RED.util.prepareJSONataExpression(exp_reduce, this); - this.reduce_fixup = (exp_fixup !== undefined) ? RED.util.prepareJSONataExpression(exp_fixup, this) : undefined; + this.reduceExpression = RED.util.prepareJSONataExpression(exp_reduce, this); + this.fixupExpression = (exp_fixup !== undefined) ? RED.util.prepareJSONataExpression(exp_fixup, this) : undefined; } catch(e) { this.error(RED._("join.errors.invalid-expr",{error:e.message})); return; @@ -426,9 +426,6 @@ module.exports = function(RED) { this.build = n.build || "array"; this.accumulate = n.accumulate || "false"; - this.topics = (n.topics || []).map(function(x) { return x.topic; }); - this.merge_on_change = n.mergeOnChange || false; - this.topic_counts = undefined; this.output = n.output || "stream"; this.pending = {}; this.pending_count = 0; @@ -518,7 +515,7 @@ module.exports = function(RED) { // There are more messages to process. Get the next message and // start processing it. Recurse back in to check for any more var nextMsg = pendingMessages.shift(); - activeMessagePromise = reduce_msg(node, nextMsg) + activeMessagePromise = reduceMessage(node, nextMsg) .then(processReduceMessageQueue) .catch((err) => { node.error(err,nextMsg);