Today my colleague Federico introduced me to the functional programming library of lodash. We were using
Here’s how we used it:
fp.compose we could pass it the two transformation functions and it would apply one after the other.
Without lodash fp.compose, it would be this:
With lodash fp.compose, we can do this:
So that’s cool! I just found the order a bit counter intuitive.
Luckily I came across
fp.pipe which does the same thing but in the opposite direction. So the data flows from left to right.
I think that’s easier to understand.
Kind of like piping data through a list of functions in Elixir.
Or even piping in bash for that matter!
That’s probably something that most developers will be familiar with, so I feel more comfortable using the
fp.pipe function in our code. Easier to understand!