CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
maxBy.js35 linesDownload Raw Back to lodash-es
1import baseExtremum from './_baseExtremum.js';2import baseGt from './_baseGt.js';3import baseIteratee from './_baseIteratee.js';4 5/**6 * This method is like `_.max` except that it accepts `iteratee` which is7 * invoked for each element in `array` to generate the criterion by which8 * the value is ranked. The iteratee is invoked with one argument: (value).9 *10 * @static11 * @memberOf _12 * @since 4.0.013 * @category Math14 * @param {Array} array The array to iterate over.15 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.16 * @returns {*} Returns the maximum value.17 * @example18 *19 * var objects = [{ 'n': 1 }, { 'n': 2 }];20 *21 * _.maxBy(objects, function(o) { return o.n; });22 * // => { 'n': 2 }23 *24 * // The `_.property` iteratee shorthand.25 * _.maxBy(objects, 'n');26 * // => { 'n': 2 }27 */28function maxBy(array, iteratee) {29  return (array && array.length)30    ? baseExtremum(array, baseIteratee(iteratee, 2), baseGt)31    : undefined;32}33 34export default maxBy;35 
basant307/AI_Governance_Project · CoolFace