MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / createExtremum

Function createExtremum

lib/web/jshint.js:4760–4782  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 1

runInContextFunction · 0.85

Calls 6

isIterateeCallFunction · 0.85
getCallbackFunction · 0.85
isStringFunction · 0.85
toIterableFunction · 0.85
extremumByFunction · 0.85
isArrayFunction · 0.70

Tested by

no test coverage detected