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

35 lines
974 B
JavaScript

import _curry1 from "./internal/_curry1.js";
import curryN from "./curryN.js";
/**
* Returns a new function much like the supplied one, except that the first two
* arguments' order is reversed.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z)
* @param {Function} fn The function to invoke with its first two parameters reversed.
* @return {*} The result of invoking `fn` with its first two parameters' order reversed.
* @example
*
* const mergeThree = (a, b, c) => [].concat(a, b, c);
*
* mergeThree(1, 2, 3); //=> [1, 2, 3]
*
* R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3]
* @symb R.flip(f)(a, b, c) = f(b, a, c)
*/
var flip =
/*#__PURE__*/
_curry1(function flip(fn) {
return curryN(fn.length, function (a, b) {
var args = Array.prototype.slice.call(arguments, 0);
args[0] = b;
args[1] = a;
return fn.apply(this, args);
});
});
export default flip;