* Creates a `_.max` or `_.min` function. * * @private * @param {Function} arrayFunc The function to get the extremum value from an array. * @param {boolean} [isMin] Specify returning the minimum, instead of the maximum, * extremum value. * @returns {Function} Returns t
(arrayFunc, isMin)
| 4758 | * @returns {Function} Returns the new extremum function. |
| 4759 | */ |
| 4760 | function createExtremum(arrayFunc, isMin) { |
| 4761 | return function(collection, iteratee, thisArg) { |
| 4762 | if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { |
| 4763 | iteratee = null; |
| 4764 | } |
| 4765 | var func = getCallback(), |
| 4766 | noIteratee = iteratee == null; |
| 4767 | |
| 4768 | if (!(func === baseCallback && noIteratee)) { |
| 4769 | noIteratee = false; |
| 4770 | iteratee = func(iteratee, thisArg, 3); |
| 4771 | } |
| 4772 | if (noIteratee) { |
| 4773 | var isArr = isArray(collection); |
| 4774 | if (!isArr && isString(collection)) { |
| 4775 | iteratee = charAtCallback; |
| 4776 | } else { |
| 4777 | return arrayFunc(isArr ? collection : toIterable(collection)); |
| 4778 | } |
| 4779 | } |
| 4780 | return extremumBy(collection, iteratee, isMin); |
| 4781 | }; |
| 4782 | } |
| 4783 | |
| 4784 | /** |
| 4785 | * Creates a `_.find` or `_.findLast` function. |
no test coverage detected