summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/arrayMax.js
blob: 3f62469f912ff2ed262e0d1f0992f5c3262799af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/** Used as references for `-Infinity` and `Infinity`. */
var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;

/**
 * A specialized version of `_.max` for arrays without support for iteratees.
 *
 * @private
 * @param {Array} array The array to iterate over.
 * @returns {*} Returns the maximum value.
 */
function arrayMax(array) {
  var index = -1,
      length = array.length,
      result = NEGATIVE_INFINITY;

  while (++index < length) {
    var value = array[index];
    if (value > result) {
      result = value;
    }
  }
  return result;
}

module.exports = arrayMax;