Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 1x 1x 1x 1x 1x 14x 7x 7x 1x 6x 1x 5x 24x 24x 125x 213x 22x 22x 54x 155x 1x 1x 1x | 'use strict';
const predicates = require('./predicates');
const utils = require('./utils');
const every = Array.prototype.every;
const some = Array.prototype.some;
const predicate = module.exports;
function ternary(pred, a, b) {
if (predicates.bool(pred)) {
return pred ? a : b;
}
if (predicates.undef(a)) {
return utils.partial(predicate.ternary, pred);
}
if (predicates.undef(b)) {
return utils.partial(predicate.ternary, pred, a);
}
return predicate.ternary(pred(a, b), a, b);
}
function and() {
const predicateArgs = arguments;
return function _and() {
const args = arguments;
return every.call(predicateArgs, p => p.apply(null, args));
};
}
function or() {
const predicateArgs = arguments;
return function _or() {
const args = arguments;
return some.call(predicateArgs, p => p.apply(null, args));
};
}
predicate.ternary = ternary;
predicate.and = and;
predicate.or = or;
|