Introduction
Last updated
Last updated
conductor is a modern utility library to help you control the execution flow using functional programming.
It provides a set of utility functions which can be used both with asynchronous and synchronous code, allowing you to control your execution flow very clearly and with a minimum of code. The library is designed in a functional programming spirit, to provide a coherent API and highly composable functions. Think of it as if Ramda & Async had a baby.
Read more on Why I'm building conductor.
Here are a few examples of what you can do with conductor.
You can use map
with an asynchronous mapper and directly use the await
keyword. No need to use Promise.all
like you need to with Array.prototype.map
or lodash.map
.
You can compose functions seamlessly, without ever wondering if you need to use Promise.prototype.then
because one function returns a Promise
. Simply add await
before compose if one your functions is asynchronous.
All functions in conductor are curried by default, which means they can be used in a partially applied form to define very modular and composable blocks in your code. In the example above, we have an array of jedis
, and we want to retrieve a concatenated string of all the good guys' name. We first define an isGood
function, which will filter out the bad guys. Then, we create a mapping functiongetName
which will retrieve each jedi's name. Finally, we create a concatenating function called concat
. We can now easily compose them and pass thejedis
array to the resulting function. Notice how we created small & modular point-free functions, and only passed the input data when we actually needed to.