source: node_modules/ramda/src/compose.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]1var pipe =
2/*#__PURE__*/
3require("./pipe.js");
4
5var reverse =
6/*#__PURE__*/
7require("./reverse.js");
8/**
9 * Performs right-to-left function composition. The last argument may have
10 * any arity; the remaining arguments must be unary.
11 *
12 * **Note:** The result of compose is not automatically curried.
13 *
14 * @func
15 * @memberOf R
16 * @since v0.1.0
17 * @category Function
18 * @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z)
19 * @param {...Function} ...functions The functions to compose
20 * @return {Function}
21 * @see R.pipe
22 * @example
23 *
24 * const classyGreeting = (firstName, lastName) => "The name's " + lastName + ", " + firstName + " " + lastName
25 * const yellGreeting = R.compose(R.toUpper, classyGreeting);
26 * yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND"
27 *
28 * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7
29 *
30 * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b)))
31 * @symb R.compose(f, g, h)(a)(b) = f(g(h(a)))(b)
32 */
33
34
35function compose() {
36 if (arguments.length === 0) {
37 throw new Error('compose requires at least one argument');
38 }
39
40 return pipe.apply(this, reverse(arguments));
41}
42
43module.exports = compose;
Note: See TracBrowser for help on using the repository browser.