1 | import _curry2 from "./internal/_curry2.js";
|
---|
2 | import _arrayReduce from "./internal/_arrayReduce.js";
|
---|
3 | import ap from "./ap.js";
|
---|
4 | import curryN from "./curryN.js";
|
---|
5 | import map from "./map.js";
|
---|
6 | /**
|
---|
7 | * "lifts" a function to be the specified arity, so that it may "map over" that
|
---|
8 | * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply).
|
---|
9 | *
|
---|
10 | * @func
|
---|
11 | * @memberOf R
|
---|
12 | * @since v0.7.0
|
---|
13 | * @category Function
|
---|
14 | * @sig Number -> (*... -> *) -> ([*]... -> [*])
|
---|
15 | * @param {Function} fn The function to lift into higher context
|
---|
16 | * @return {Function} The lifted function.
|
---|
17 | * @see R.lift, R.ap
|
---|
18 | * @example
|
---|
19 | *
|
---|
20 | * const madd3 = R.liftN(3, (...args) => R.sum(args));
|
---|
21 | * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
|
---|
22 | */
|
---|
23 |
|
---|
24 | var liftN =
|
---|
25 | /*#__PURE__*/
|
---|
26 | _curry2(function liftN(arity, fn) {
|
---|
27 | var lifted = curryN(arity, fn);
|
---|
28 | return curryN(arity, function () {
|
---|
29 | return _arrayReduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1));
|
---|
30 | });
|
---|
31 | });
|
---|
32 |
|
---|
33 | export default liftN; |
---|