gustavoguichard / string-ts

Strongly typed string functions
MIT License
1.19k stars 17 forks source link

replaceKeys method #213

Closed gustavoguichard closed 4 months ago

gustavoguichard commented 4 months ago

This PR adds a new helper: replaceKeys and helper type: ReplaceKeys to run a replace transformation on the keys of an object.

We could argue that adding this method opens the door for other methods, like replaceAllKeys, or deepReplaceKeys, and so on.

However I haven't ran into a use case for the other ones while I have ran on use cases for replaceKeys.

If any contributor wants to send PR for other methods it'd be nice to know the use case ;)

gustavoguichard commented 4 months ago

Does it support unions, non-literals, and template strings (if applicable)?

I think so because we are just reusing the functions that already do. That said I'll create a test just in case.

gustavoguichard commented 4 months ago

@jly36963 done