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:
878 bytes
|
Line | |
---|
1 | var _curry3 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry3.js");
|
---|
4 |
|
---|
5 | var min =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./min.js");
|
---|
8 | /**
|
---|
9 | * Takes a function and two values, and returns whichever value produces the
|
---|
10 | * smaller 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.min, R.maxBy
|
---|
22 | * @example
|
---|
23 | *
|
---|
24 | * // square :: Number -> Number
|
---|
25 | * const square = n => n * n;
|
---|
26 | *
|
---|
27 | * R.minBy(square, -3, 2); //=> 2
|
---|
28 | *
|
---|
29 | * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1
|
---|
30 | * R.reduce(R.minBy(square), Infinity, []); //=> Infinity
|
---|
31 | */
|
---|
32 |
|
---|
33 |
|
---|
34 | var minBy =
|
---|
35 | /*#__PURE__*/
|
---|
36 | _curry3(function minBy(f, a, b) {
|
---|
37 | var resultB = f(b);
|
---|
38 | return min(f(a), resultB) === resultB ? b : a;
|
---|
39 | });
|
---|
40 |
|
---|
41 | module.exports = minBy; |
---|
Note:
See
TracBrowser
for help on using the repository browser.