Use _.all() in Filter._build_predicate.

By using _.all() instead of a for loop, we avoid a tiny bit of
confusing between "break" being for a switch statement and being for
the loop.

(imported from commit cd6e7ff788b50f4dadce93e7f0efcb381bc59270)
This commit is contained in:
Steve Howell
2014-01-30 16:11:23 -05:00
parent 15b0f9dcc7
commit 3a412b35e1

View File

@@ -253,14 +253,9 @@ Filter.prototype = {
// build JavaScript code in a string and then eval() it.
return function (message) {
var operand, i, index;
for (i = 0; i < operators.length; i++) {
// Inside this loop, the correct protocol for a test is to
// * "return false" if the value does not match
// * "break" if there is a match
// If you "return true", you circumvent all future operators
operand = operators[i].operand;
switch (operators[i].operator) {
return _.all(operators, function (term) {
var operand = term.operand;
switch (term.operator) {
case 'is':
if (operand === 'private') {
if (message.type !== 'private') {
@@ -343,10 +338,9 @@ Filter.prototype = {
}
break;
}
}
// All filters passed.
return true;
});
};
}
};