source: node_modules/ramda/es/liftN.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1import _curry2 from "./internal/_curry2.js";
2import _arrayReduce from "./internal/_arrayReduce.js";
3import ap from "./ap.js";
4import curryN from "./curryN.js";
5import 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
24var 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
33export default liftN;
Note: See TracBrowser for help on using the repository browser.