camel-snake-kebab
camel-snake-kebab copied to clipboard
transform-values
Should there be a counterpart to transform-keys called transform-values? This would apply t to non-map leaves.
I have a current project where a kebabed value can appear both in key position and value position, so I need to transform it consistently.
I'm happy to submit a pull-request if this is something CSK is interested in.
When you want to transform both keys and values I think it makes sense to use clojure.walk/postwalk directly, like this: (postwalk #(if (keyword? %) (->snake_case_string %) %) {:fooish-bar :fooish-bar}).
I added transform-keys because it's such a common operation and a bit clumsy to do with postwalk directly. I'm not convinced transform-values would see much use, so I'm going to let this issue linger until somebody more chimes in that they miss it.
That sounds like a sensible approach.
On our project, we have ended up using Traversy's all-values lens instead.