In my opinion, first is easier to read because of not so many abstractions. I'd prefer to create extra abstractions only when implementation becomes big. Then it becomes simpler to understand which parts of code are worth separate abstractions and which are not.
Personally I'd prefer using normal JavaScript instead of using a magical wrapper that does exactly the same as a simple
.map
.I do build wrappers where it makes sense, but often I'd rather use the following strategy to clean up my code.
Here is a simple example, where I go from a messy implementation:
To a more cleaner implementation:
In my opinion, first is easier to read because of not so many abstractions. I'd prefer to create extra abstractions only when implementation becomes big. Then it becomes simpler to understand which parts of code are worth separate abstractions and which are not.
Agreed, when it's small, totally. I see them bigger than the surrounding component, then I think it should be separated.