From f16702447edfcd30854d1ae41a7146d25c364f32 Mon Sep 17 00:00:00 2001 From: Sam Saccone Date: Fri, 1 Dec 2017 07:24:28 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=90=20Replace=20joins=20for=20loop=20w?= =?UTF-8?q?ith=20a=20.find=20array=20opt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The intent of the for loop in this case was to find (if present) an entity in the joinObserveArray who's queue has no elements, when that element was found hasValues was set to false and the for loop was exited. The semantics of this code can be replaced with a more "idiomatic" find operation which will do the following: 1. loop over each element until an element is found 2. return the found element which can be used to set hasValues to false; --- Thanks so much for your time reviewing this PR and have a great day! --- src/core/joins/activeplan.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/joins/activeplan.js b/src/core/joins/activeplan.js index b2eb6ee9b..24ce83747 100644 --- a/src/core/joins/activeplan.js +++ b/src/core/joins/activeplan.js @@ -15,12 +15,11 @@ ActivePlan.prototype.match = function () { var i, len, hasValues = true; - for (i = 0, len = this.joinObserverArray.length; i < len; i++) { - if (this.joinObserverArray[i].queue.length === 0) { - hasValues = false; - break; - } - } + + hasValues = this.joinedObserverArray.find(function(v) { + return v.queue.length === 0; + }) === undefined; + if (hasValues) { var firstValues = [], isCompleted = false;