Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_baseExtremum.js 897B

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