mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17: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
|
* @private
|
||||||
* @param {Function} exFunc The function to retrieve the 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
|
* @param {boolean} [isMin] Specify returning the minimum, instead of the maximum,
|
||||||
* maximum, extremum value.
|
* extremum value.
|
||||||
* @returns {Function} Returns the new extremum function.
|
* @returns {Function} Returns the new extremum function.
|
||||||
*/
|
*/
|
||||||
function createExtremum(exFunc, isMin) {
|
function createExtremum(arrayFunc, isMin) {
|
||||||
return function(collection, iteratee, thisArg) {
|
return function(collection, iteratee, thisArg) {
|
||||||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
iteratee = null;
|
iteratee = null;
|
||||||
@@ -3075,14 +3075,12 @@
|
|||||||
noIteratee = false;
|
noIteratee = false;
|
||||||
iteratee = func(iteratee, thisArg, 3);
|
iteratee = func(iteratee, thisArg, 3);
|
||||||
}
|
}
|
||||||
var isArr = noIteratee && isArray(collection),
|
|
||||||
isStr = !isArr && isString(collection);
|
|
||||||
|
|
||||||
if (noIteratee) {
|
if (noIteratee) {
|
||||||
if (isStr) {
|
var isArr = isArray(collection);
|
||||||
|
if (!isArr && isString(collection)) {
|
||||||
iteratee = charAtCallback;
|
iteratee = charAtCallback;
|
||||||
} else {
|
} else {
|
||||||
return exFunc(isArr ? collection : toIterable(collection));
|
return arrayFunc(isArr ? collection : toIterable(collection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return extremumBy(collection, iteratee, isMin);
|
return extremumBy(collection, iteratee, isMin);
|
||||||
|
|||||||
Reference in New Issue
Block a user