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