If this wasn't as common, I'd probably investigate making a function that takes a predicate and an array and makes an iterator of entries that new Map() can consume.
But like this, I only iterate once to populate multiple Maps.
Plus there's the cases where I receive an object (including from JSON), so normal iteration wouldn't work:
That is an interesting case that I hadn't considered before. I will definitely have to look into it while exploring JavaScript ecosystem more thoroughly!
Do you know if there's anything
juxt
like that would help this case:There is often a case where I have multiple indexes, so I end up doing something like this:
If this wasn't as common, I'd probably investigate making a function that takes a predicate and an array and makes an iterator of entries that
new Map()
can consume.But like this, I only iterate once to populate multiple
Map
s.Plus there's the cases where I receive an object (including from JSON), so normal iteration wouldn't work:
Something like "multiple reducers in one iteration"
That is an interesting case that I hadn't considered before. I will definitely have to look into it while exploring JavaScript ecosystem more thoroughly!
In OOP it would probably be this: