swc/bundler/tests/.cache/deno/7ed31e79626ae13ed08a2ad28a04566f63b8209e.ts

37 lines
1.0 KiB
TypeScript
Raw Normal View History

// Loaded from https://deno.land/x/ramda@v0.27.2/source/flip.js
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 = _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;