higher-order-logical-operators
Version:
Allows combination of lower order functions that evaluate to booleans. Extends Array prototype with 'one' function, which takes a callback and returns true if the callback returns true for one and only one member of the array.
20 lines (17 loc) • 504 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var and = exports.and = function and() {
for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) {
fns[_key] = arguments[_key];
}
return function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return fns.every(function (fn) {
return fn.apply(undefined, args);
});
};
};
;