From f695af587ab617f6bd57d55261c3e6cfd899a1f3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 16 Jul 2015 13:08:44 -0700 Subject: [PATCH] Remove `createExtremum`. --- lodash.src.js | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 53ef589c2..de9337583 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -3112,25 +3112,6 @@ }; } - /** - * Creates a `_.maxBy` or `_.minBy` function. - * - * @private - * @param {Function} comparator The function used to compare values. - * @param {*} exValue The initial extremum value. - * @returns {Function} Returns the new extremum function. - */ - function createExtremum(comparator, exValue) { - return function(array, iteratee, guard) { - if (guard && isIterateeCall(array, iteratee, guard)) { - iteratee = undefined; - } - return (array && array.length) - ? arrayExtremum(array, getIteratee(iteratee), comparator, exValue) - : exValue; - }; - } - /** * Creates a `_.flow` or `_.flowRight` function. * @@ -11082,7 +11063,14 @@ * _.maxBy(users, 'age'); * // => { 'user': 'fred', 'age': 40 } */ - var maxBy = createExtremum(gt, NEGATIVE_INFINITY); + function maxBy(array, iteratee, guard) { + if (guard && isIterateeCall(array, iteratee, guard)) { + iteratee = undefined; + } + return (array && array.length) + ? arrayExtremum(array, getIteratee(iteratee), gt, NEGATIVE_INFINITY) + : NEGATIVE_INFINITY; + } /** * Gets the minimum value of `array`. If `array` is empty or falsey @@ -11130,7 +11118,14 @@ * _.minBy(users, 'age'); * // => { 'user': 'barney', 'age': 36 } */ - var minBy = createExtremum(lt, POSITIVE_INFINITY); + function minBy(array, iteratee, guard) { + if (guard && isIterateeCall(array, iteratee, guard)) { + iteratee = undefined; + } + return (array && array.length) + ? arrayExtremum(array, getIteratee(iteratee), lt, POSITIVE_INFINITY) + : POSITIVE_INFINITY; + } /** * Calculates `n` rounded to `precision`.