Icard/angular-clarity-master(work.../node_modules/ramda/es/maxBy.js

35 lines
820 B
JavaScript
Raw Normal View History

2024-07-16 15:23:22 +00:00
import _curry3 from "./internal/_curry3.js";
import max from "./max.js";
/**
* Takes a function and two values, and returns whichever value produces the
* larger result when passed to the provided function.
*
* @func
* @memberOf R
* @since v0.8.0
* @category Relation
* @sig Ord b => (a -> b) -> a -> a -> a
* @param {Function} f
* @param {*} a
* @param {*} b
* @return {*}
* @see R.max, R.minBy
* @example
*
* // square :: Number -> Number
* const square = n => n * n;
*
* R.maxBy(square, -3, 2); //=> -3
*
* R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5
* R.reduce(R.maxBy(square), 0, []); //=> 0
*/
var maxBy =
/*#__PURE__*/
_curry3(function maxBy(f, a, b) {
var resultB = f(b);
return max(f(a), resultB) === resultB ? b : a;
});
export default maxBy;