Permalink
Cannot retrieve contributors at this time
34 lines (32 sloc)
991 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/lodash/maxBy.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseExtremum = require('./_baseExtremum'), | |
baseGt = require('./_baseGt'), | |
baseIteratee = require('./_baseIteratee'); | |
/** | |
* This method is like `_.max` except that it accepts `iteratee` which is | |
* invoked for each element in `array` to generate the criterion by which | |
* the value is ranked. The iteratee is invoked with one argument: (value). | |
* | |
* @static | |
* @memberOf _ | |
* @since 4.0.0 | |
* @category Math | |
* @param {Array} array The array to iterate over. | |
* @param {Function} [iteratee=_.identity] The iteratee invoked per element. | |
* @returns {*} Returns the maximum value. | |
* @example | |
* | |
* var objects = [{ 'n': 1 }, { 'n': 2 }]; | |
* | |
* _.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) | |
: undefined; | |
} | |
module.exports = maxBy; |