mirror of
https://github.com/swc-project/swc.git
synced 2024-12-30 00:52:29 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
// 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;
|