We currently have and and or helpers, which support two arguments.
It would be nice if instead we had helpers that resolved to true if all or any arguments resolve to true. This would work for two or more arguments.
Example helpers from a personal project:
var R = require('ramda');
function all () {
var options = R.last(arguments);
var result = true;
var values;
var i;
if (R.isNil(options.fn)) {
options = undefined;
values = arguments;
} else {
values = R.dropLast(1, arguments);
}
for (i = 0; i < values.length; i++) {
if (!values[i]) {
result = false;
break;
}
}
if (options) {
return result ? options.fn(this) : options.inverse(this);
}
return result;
};
function any () {
var options = R.last(arguments);
var values, result;
if (R.isNil(options.fn)) {
options = undefined;
values = arguments;
} else {
values = R.dropLast(1, arguments);
}
result = R.any(R.__, values);
if (options) {
return result ? options.fn(this) : options.inverse(this);
}
return result;
};
We currently have
and
andor
helpers, which support two arguments.It would be nice if instead we had helpers that resolved to true if all or any arguments resolve to true. This would work for two or more arguments.
Example helpers from a personal project: