1 var apply = require(
'./_apply'),
2 arrayMap = require(
'./_arrayMap'),
3 baseIteratee = require(
'./_baseIteratee'),
4 baseRest = require(
'./_baseRest');
7 var FUNC_ERROR_TEXT =
'Expected a function';
38 function cond(pairs) {
39 var length = pairs == null ? 0 : pairs.length,
40 toIteratee = baseIteratee;
42 pairs = !length ? [] : arrayMap(pairs,
function(pair) {
43 if (typeof pair[1] !=
'function') {
44 throw new TypeError(FUNC_ERROR_TEXT);
46 return [toIteratee(pair[0]), pair[1]];
49 return baseRest(
function(args) {
51 while (++index < length) {
52 var pair = pairs[index];
53 if (apply(pair[0],
this, args)) {
54 return apply(pair[1],
this, args);
60 module.exports = cond;