Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / globule / node_modules / lodash / _baseExtremum.js
1 var isSymbol = require('./isSymbol');
2
3 /**
4  * The base implementation of methods like `_.max` and `_.min` which accepts a
5  * `comparator` to determine the extremum value.
6  *
7  * @private
8  * @param {Array} array The array to iterate over.
9  * @param {Function} iteratee The iteratee invoked per iteration.
10  * @param {Function} comparator The comparator used to compare values.
11  * @returns {*} Returns the extremum value.
12  */
13 function baseExtremum(array, iteratee, comparator) {
14   var index = -1,
15       length = array.length;
16
17   while (++index < length) {
18     var value = array[index],
19         current = iteratee(value);
20
21     if (current != null && (computed === undefined
22           ? (current === current && !isSymbol(current))
23           : comparator(current, computed)
24         )) {
25       var computed = current,
26           result = value;
27     }
28   }
29   return result;
30 }
31
32 module.exports = baseExtremum;