compose
description
Returns a function which composes its given parameter functions right to left. Function composition is at the heart of functional programming, and that's why it is one of conductor's most important functions.
But that's not all! compose
also has magic powers: it composes synchronous functions, asynchronous functions or even a mix of both! It accepts as many arguments as the rightmost function does, and has the same arity.
examples
basic example
arity preservation
Even if multiply
and minus3
do not accept the same number of arguments, compose
will help you make their composition a breeze! It will simply accept as many arguments as multiply
does : 2. You can verify that by accessing the length
property on the composition's result. Even better, compose
's result will be curried, even if its rightmost argument is not.
synchronous and asynchronous function composition
Even if multiply
and minus3
do not accept the same number of arguments, compose
will help you make their composition a breeze! It will simply accept as many arguments as multiply
does : 2. You can verify this by accessing the length
property on the composition's result. Even better, compose
's result will be curried, even if its rightmost argument is not.
Last updated