1 | var _curry2 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry2");
|
4 |
|
5 | var _reduce =
|
6 | /*#__PURE__*/
|
7 | require("./internal/_reduce");
|
8 |
|
9 | var ap =
|
10 | /*#__PURE__*/
|
11 | require("./ap");
|
12 |
|
13 | var curryN =
|
14 | /*#__PURE__*/
|
15 | require("./curryN");
|
16 |
|
17 | var map =
|
18 | /*#__PURE__*/
|
19 | require("./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 |
|
39 | var 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 |
|
48 | module.exports = liftN; |
\ | No newline at end of file |