source: node_modules/ramda/src/composeWith.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.3 KB
RevLine 
[d24f17c]1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2.js");
4
5var pipeWith =
6/*#__PURE__*/
7require("./pipeWith.js");
8
9var reverse =
10/*#__PURE__*/
11require("./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
39var composeWith =
40/*#__PURE__*/
41_curry2(function composeWith(xf, list) {
42 return pipeWith.apply(this, [xf, reverse(list)]);
43});
44
45module.exports = composeWith;
Note: See TracBrowser for help on using the repository browser.