main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
858 bytes
|
Line | |
---|
1 | var _curry3 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry3.js");
|
---|
4 |
|
---|
5 | var max =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./max.js");
|
---|
8 | /**
|
---|
9 | * Takes a function and two values, and returns whichever value produces the
|
---|
10 | * larger result when passed to the provided function.
|
---|
11 | *
|
---|
12 | * @func
|
---|
13 | * @memberOf R
|
---|
14 | * @since v0.8.0
|
---|
15 | * @category Relation
|
---|
16 | * @sig Ord b => (a -> b) -> a -> a -> a
|
---|
17 | * @param {Function} f
|
---|
18 | * @param {*} a
|
---|
19 | * @param {*} b
|
---|
20 | * @return {*}
|
---|
21 | * @see R.max, R.minBy
|
---|
22 | * @example
|
---|
23 | *
|
---|
24 | * // square :: Number -> Number
|
---|
25 | * const square = n => n * n;
|
---|
26 | *
|
---|
27 | * R.maxBy(square, -3, 2); //=> -3
|
---|
28 | *
|
---|
29 | * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5
|
---|
30 | * R.reduce(R.maxBy(square), 0, []); //=> 0
|
---|
31 | */
|
---|
32 |
|
---|
33 |
|
---|
34 | var maxBy =
|
---|
35 | /*#__PURE__*/
|
---|
36 | _curry3(function maxBy(f, a, b) {
|
---|
37 | var resultB = f(b);
|
---|
38 | return max(f(a), resultB) === resultB ? b : a;
|
---|
39 | });
|
---|
40 |
|
---|
41 | module.exports = maxBy; |
---|
Note:
See
TracBrowser
for help on using the repository browser.