1 | var _curry1 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry1");
|
4 |
|
5 | var curryN =
|
6 | /*#__PURE__*/
|
7 | require("./curryN");
|
8 | /**
|
9 | * Returns a new function much like the supplied one, except that the first two
|
10 | * arguments' order is reversed.
|
11 | *
|
12 | * @func
|
13 | * @memberOf R
|
14 | * @since v0.1.0
|
15 | * @category Function
|
16 | * @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z)
|
17 | * @param {Function} fn The function to invoke with its first two parameters reversed.
|
18 | * @return {*} The result of invoking `fn` with its first two parameters' order reversed.
|
19 | * @example
|
20 | *
|
21 | * const mergeThree = (a, b, c) => [].concat(a, b, c);
|
22 | *
|
23 | * mergeThree(1, 2, 3); //=> [1, 2, 3]
|
24 | *
|
25 | * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3]
|
26 | * @symb R.flip(f)(a, b, c) = f(b, a, c)
|
27 | */
|
28 |
|
29 |
|
30 | var flip =
|
31 | /*#__PURE__*/
|
32 | _curry1(function flip(fn) {
|
33 | return curryN(fn.length, function (a, b) {
|
34 | var args = Array.prototype.slice.call(arguments, 0);
|
35 | args[0] = b;
|
36 | args[1] = a;
|
37 | return fn.apply(this, args);
|
38 | });
|
39 | });
|
40 |
|
41 | module.exports = flip; |
\ | No newline at end of file |