From d555241d03fa6f14fe1d085642eed8f41ee5c9e5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 30 Dec 2014 18:37:45 -0600 Subject: [PATCH] Cleanup `createExtremum`. --- lodash.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lodash.js b/lodash.js index ace1fab29..1408525e0 100644 --- a/lodash.js +++ b/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);