Pedro Ávila
Aug 31, 2018 · 1 min read

I think the main concern here isn’t reusability. It’s actually readability. Yes, you can extract the functions used in filter and map, and reuse them inside the reducer, but still the readability of filter/map would be much better. Here’s an example of that, I’m gonna use Ramda’s `propEq` and `merge` instead of the functions inside of the filter/map:

Same result, but it’s a lot easier to read and understand what’s happening with the filter/map version. I’d probably stick with the filter/map version, unless I have a performance issue.

If someone knows how to improve the readability of the reduce version using function composition I’d love to know!

    Pedro Ávila

    Written by