source: node_modules/ramda/es/maxBy.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 820 bytes
Line 
1import _curry3 from "./internal/_curry3.js";
2import max from "./max.js";
3/**
4 * Takes a function and two values, and returns whichever value produces the
5 * larger result when passed to the provided function.
6 *
7 * @func
8 * @memberOf R
9 * @since v0.8.0
10 * @category Relation
11 * @sig Ord b => (a -> b) -> a -> a -> a
12 * @param {Function} f
13 * @param {*} a
14 * @param {*} b
15 * @return {*}
16 * @see R.max, R.minBy
17 * @example
18 *
19 * // square :: Number -> Number
20 * const square = n => n * n;
21 *
22 * R.maxBy(square, -3, 2); //=> -3
23 *
24 * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5
25 * R.reduce(R.maxBy(square), 0, []); //=> 0
26 */
27
28var maxBy =
29/*#__PURE__*/
30_curry3(function maxBy(f, a, b) {
31 var resultB = f(b);
32 return max(f(a), resultB) === resultB ? b : a;
33});
34
35export default maxBy;
Note: See TracBrowser for help on using the repository browser.