* Creates a function that iterates over `pairs` and invokes the corresponding * function of the first predicate to return truthy. The predicate-function * pairs are invoked with the `this` binding and arguments of the created * function. * * @static * @memberOf _ *
(pairs)
| 15443 | * // => 'no match' |
| 15444 | */ |
| 15445 | function cond(pairs) { |
| 15446 | var length = pairs == null ? 0 : pairs.length, |
| 15447 | toIteratee = getIteratee(); |
| 15448 | |
| 15449 | pairs = !length ? [] : arrayMap(pairs, function(pair) { |
| 15450 | if (typeof pair[1] != 'function') { |
| 15451 | throw new TypeError(FUNC_ERROR_TEXT); |
| 15452 | } |
| 15453 | return [toIteratee(pair[0]), pair[1]]; |
| 15454 | }); |
| 15455 | |
| 15456 | return baseRest(function(args) { |
| 15457 | var index = -1; |
| 15458 | while (++index < length) { |
| 15459 | var pair = pairs[index]; |
| 15460 | if (apply(pair[0], this, args)) { |
| 15461 | return apply(pair[1], this, args); |
| 15462 | } |
| 15463 | } |
| 15464 | }); |
| 15465 | } |
| 15466 | |
| 15467 | /** |
| 15468 | * Creates a function that invokes the predicate properties of `source` with |
no test coverage detected