UNPKG

1.13 kBJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4
5var _reduce =
6/*#__PURE__*/
7require("./internal/_reduce");
8
9var ap =
10/*#__PURE__*/
11require("./ap");
12
13var curryN =
14/*#__PURE__*/
15require("./curryN");
16
17var map =
18/*#__PURE__*/
19require("./map");
20/**
21 * "lifts" a function to be the specified arity, so that it may "map over" that
22 * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply).
23 *
24 * @func
25 * @memberOf R
26 * @since v0.7.0
27 * @category Function
28 * @sig Number -> (*... -> *) -> ([*]... -> [*])
29 * @param {Function} fn The function to lift into higher context
30 * @return {Function} The lifted function.
31 * @see R.lift, R.ap
32 * @example
33 *
34 * const madd3 = R.liftN(3, (...args) => R.sum(args));
35 * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
36 */
37
38
39var liftN =
40/*#__PURE__*/
41_curry2(function liftN(arity, fn) {
42 var lifted = curryN(arity, fn);
43 return curryN(arity, function () {
44 return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1));
45 });
46});
47
48module.exports = liftN;
\No newline at end of file