@lou.codes/iterables is a collection of curried utils to work with iterables
in a functional fashion without having to use
while and so on directly.
I always liked the curried approach of stuff like
map in which you generate a
mapping function first:
And then you can use it to map any array:
When I discovered how powerful that style was, I wanted to use it all over. Now the “limitation” of those types of functions is that they first run the mapping function on every item, before going to the next. Iterators on the other side run all functions on each item, which in some scenarios can be more efficient.
This from my point of view is great, so I wanted to have a library that would allow me to use this style of programming with iterators, and that’s how this library was born.
I built this library using TypeScript, with configurations from my shared configs. I made it ESM only as soon as Node started supporting ESM modules, and I made it tree-shakeable by using named exports.
Over the development of this library I found some challenges like making the result of iterators iterable again, so we can map multiple times from the same iterator.
I went back and forward with the idea of making utils handle async
automatically, but the cost in size and performance made me decide to split the
I’ve also used it in some private projects, with great results.