mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Remove baseIteratee and castFunction.
This commit is contained in:
9
maxBy.js
9
maxBy.js
@@ -1,6 +1,5 @@
|
||||
import baseExtremum from './_baseExtremum.js';
|
||||
import baseGt from './_baseGt.js';
|
||||
import baseIteratee from './_baseIteratee.js';
|
||||
|
||||
/**
|
||||
* This method is like `_.max` except that it accepts `iteratee` which is
|
||||
@@ -12,7 +11,7 @@ import baseIteratee from './_baseIteratee.js';
|
||||
* @since 4.0.0
|
||||
* @category Math
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
||||
* @param {Function} iteratee The iteratee invoked per element.
|
||||
* @returns {*} Returns the maximum value.
|
||||
* @example
|
||||
*
|
||||
@@ -20,14 +19,10 @@ import baseIteratee from './_baseIteratee.js';
|
||||
*
|
||||
* _.maxBy(objects, function(o) { return o.n; });
|
||||
* // => { 'n': 2 }
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.maxBy(objects, 'n');
|
||||
* // => { 'n': 2 }
|
||||
*/
|
||||
function maxBy(array, iteratee) {
|
||||
return (array && array.length)
|
||||
? baseExtremum(array, baseIteratee(iteratee, 2), baseGt)
|
||||
? baseExtremum(array, iteratee, baseGt)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user