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.1 KB
|
Line | |
---|
1 | var _curry2 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry2.js");
|
---|
4 |
|
---|
5 | var _arrayReduce =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./internal/_arrayReduce.js");
|
---|
8 |
|
---|
9 | var ap =
|
---|
10 | /*#__PURE__*/
|
---|
11 | require("./ap.js");
|
---|
12 |
|
---|
13 | var curryN =
|
---|
14 | /*#__PURE__*/
|
---|
15 | require("./curryN.js");
|
---|
16 |
|
---|
17 | var map =
|
---|
18 | /*#__PURE__*/
|
---|
19 | require("./map.js");
|
---|
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 _arrayReduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1));
|
---|
45 | });
|
---|
46 | });
|
---|
47 |
|
---|
48 | module.exports = liftN; |
---|
Note:
See
TracBrowser
for help on using the repository browser.