1 | var _curry2 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry2.js");
|
---|
4 |
|
---|
5 | var pipeWith =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./pipeWith.js");
|
---|
8 |
|
---|
9 | var reverse =
|
---|
10 | /*#__PURE__*/
|
---|
11 | require("./reverse.js");
|
---|
12 | /**
|
---|
13 | * Performs right-to-left function composition using transforming function. The last function may have
|
---|
14 | * any arity; the remaining functions must be unary. Unlike `compose`, functions are passed in an array.
|
---|
15 | *
|
---|
16 | * **Note:** The result of composeWith is not automatically curried. Transforming function is not used
|
---|
17 | * on the last argument.
|
---|
18 | *
|
---|
19 | * @func
|
---|
20 | * @memberOf R
|
---|
21 | * @since v0.26.0
|
---|
22 | * @category Function
|
---|
23 | * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z)
|
---|
24 | * @param {Function} transformer The transforming function
|
---|
25 | * @param {Array} functions The functions to compose
|
---|
26 | * @return {Function}
|
---|
27 | * @see R.compose, R.pipeWith
|
---|
28 | * @example
|
---|
29 | *
|
---|
30 | * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res));
|
---|
31 | *
|
---|
32 | * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2
|
---|
33 | * composeWhileNotNil([R.inc, R.prop('age')])({}) //=> undefined
|
---|
34 | *
|
---|
35 | * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, i(...args)))
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 | var composeWith =
|
---|
40 | /*#__PURE__*/
|
---|
41 | _curry2(function composeWith(xf, list) {
|
---|
42 | return pipeWith.apply(this, [xf, reverse(list)]);
|
---|
43 | });
|
---|
44 |
|
---|
45 | module.exports = composeWith; |
---|