Urara-Blog/node_modules/.pnpm-store/v3/files/28/3e66dc240cbae54fdc0a65a1a4c03d9cdc9f1a773795b5ac13fbbebc8071e840c2857052027ee3518d6a090d8d0031449c7c36f8138e5ca3c6867fa3e5070e
2022-08-14 01:14:53 +08:00

32 lines
897 B
Text

var isSymbol = require('./isSymbol');
/**
* The base implementation of methods like `_.max` and `_.min` which accepts a
* `comparator` to determine the extremum value.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The iteratee invoked per iteration.
* @param {Function} comparator The comparator used to compare values.
* @returns {*} Returns the extremum value.
*/
function baseExtremum(array, iteratee, comparator) {
var index = -1,
length = array.length;
while (++index < length) {
var value = array[index],
current = iteratee(value);
if (current != null && (computed === undefined
? (current === current && !isSymbol(current))
: comparator(current, computed)
)) {
var computed = current,
result = value;
}
}
return result;
}
module.exports = baseExtremum;