. . , , - , , "" ( ...).
Javascript , ( ) . - , . :
var isLabelTest = function(obj) {
return obj.label === 'test';
}
.
, :
var binaryAnd = function(predA, predB) {
return function(obj) {
return predA(obj) && predB(obj);
};
};
var binaryOr = function(predA, predB) {
return function(obj) {
return predA(obj) || predB(obj);
};
};
, :
var and = function(preds) {
return preds.reduce(binaryAnd, function(obj) {return true;});
};
var or = function(preds) {
return preds.reduce(binaryOr, function(obj) {return false;});
};
, "andArray" , true, "orArray" , true, :
var results = [];
var combinedPredicate = binaryAnd(and(andArray), or(orArray));
var pushIfCondition = function (obj) {
results.push(combinedPredicate(obj));
};
dataArray.forEach(pushIfCondition);
, , , , ramda, .