What’s missing from iter-ops that I want?

Originally posted on 2023-02-22

I think iter-ops for TypeScript is pretty cool but it’s missing a few things that I really want. What are they? Let’s list them out and then maybe, eventually implement them myself…

mapKey - map a single key from a data structure and leave the rest in place

This is similar to vavr’s map1 method on the tuple class. What I want to be able to do is this:

pipe(
  [{data1: 'a', data2: 'b'}],
  mapKey(data1, value => `prepend to data1 ${a}`)
)

After this operation I would expect the iterable to change from this:

{ 'data1': 'a', 'data2': 'b' }

To this:

{ 'data1': 'prepend to data1 a', 'data2': 'b' }

… more to come …