32 lines
920 B
JavaScript
32 lines
920 B
JavaScript
|
import _curry1 from "./internal/_curry1.js";
|
||
|
import liftN from "./liftN.js";
|
||
|
/**
|
||
|
* "lifts" a function of arity > 1 so that it may "map over" a list, Function or other
|
||
|
* object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply).
|
||
|
*
|
||
|
* @func
|
||
|
* @memberOf R
|
||
|
* @since v0.7.0
|
||
|
* @category Function
|
||
|
* @sig (*... -> *) -> ([*]... -> [*])
|
||
|
* @param {Function} fn The function to lift into higher context
|
||
|
* @return {Function} The lifted function.
|
||
|
* @see R.liftN
|
||
|
* @example
|
||
|
*
|
||
|
* const madd3 = R.lift((a, b, c) => a + b + c);
|
||
|
*
|
||
|
* madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
|
||
|
*
|
||
|
* const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e);
|
||
|
*
|
||
|
* madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24]
|
||
|
*/
|
||
|
|
||
|
var lift =
|
||
|
/*#__PURE__*/
|
||
|
_curry1(function lift(fn) {
|
||
|
return liftN(fn.length, fn);
|
||
|
});
|
||
|
|
||
|
export default lift;
|