compose.js•796 B
var pipe = require('./pipe');
var reverse = require('./reverse');
/**
* Performs right-to-left function composition. The rightmost function may have
* any arity; the remaining functions must be unary.
*
* **Note:** The result of compose is not automatically curried.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z)
* @param {...Function} functions
* @return {Function}
* @see R.pipe
* @example
*
* var f = R.compose(R.inc, R.negate, Math.pow);
*
* f(3, 4); // -(3^4) + 1
*/
module.exports = function compose() {
if (arguments.length === 0) {
throw new Error('compose requires at least one argument');
}
return pipe.apply(this, reverse(arguments));
};