Returns a composite function. Starting from the right, the composite function evaluates each function and passes the result as an argument to the next function. The result of the leftmost function is the result of the whole.
Only the rightmost function is explicitly permitted to accept multiple arguments. All other functions are evaluated as unary functions.
The function will throw if provided fewer than two input arguments.
throws
must provide more than one argument
Parameters
Rest...fcn: Array<Function>
functions to compose
Returns
Function
composite function
Example
functiona( x ) {
return2 * x;
}
functionb( x ) {
return x + 3;
}
functionc( x ) {
return x / 5;
}
var f = compose( c, b, a );
var z = f( 6 );
// returns 3
Function composition.
Notes
must provide more than one argument