camel-snake-kebab icon indicating copy to clipboard operation
camel-snake-kebab copied to clipboard

transform-values

Open ctford opened this issue 10 years ago • 2 comments

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.

ctford avatar Mar 16 '15 17:03 ctford

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.

qerub avatar Mar 22 '15 00:03 qerub

That sounds like a sensible approach.

On our project, we have ended up using Traversy's all-values lens instead.

ctford avatar Mar 22 '15 16:03 ctford