mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Cleanup createExtremum.
This commit is contained in:
18
lodash.js
18
lodash.js
@@ -3055,15 +3055,15 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that retrieves the extremum value of a collection.
|
||||
* Creates a function that gets the extremum value of a collection.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} exFunc The function to retrieve the extremum value.
|
||||
* @param {boolean} [isMin] Specify returning the minimum, instead of the
|
||||
* maximum, extremum value.
|
||||
* @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 the new extremum function.
|
||||
*/
|
||||
function createExtremum(exFunc, isMin) {
|
||||
function createExtremum(arrayFunc, isMin) {
|
||||
return function(collection, iteratee, thisArg) {
|
||||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||
iteratee = null;
|
||||
@@ -3075,14 +3075,12 @@
|
||||
noIteratee = false;
|
||||
iteratee = func(iteratee, thisArg, 3);
|
||||
}
|
||||
var isArr = noIteratee && isArray(collection),
|
||||
isStr = !isArr && isString(collection);
|
||||
|
||||
if (noIteratee) {
|
||||
if (isStr) {
|
||||
var isArr = isArray(collection);
|
||||
if (!isArr && isString(collection)) {
|
||||
iteratee = charAtCallback;
|
||||
} else {
|
||||
return exFunc(isArr ? collection : toIterable(collection));
|
||||
return arrayFunc(isArr ? collection : toIterable(collection));
|
||||
}
|
||||
}
|
||||
return extremumBy(collection, iteratee, isMin);
|
||||
|
||||
Reference in New Issue
Block a user