posva / shapify

🌀Easily transform objects/rename keys with full TypeScript support
MIT License
68 stars 3 forks source link

Proposal: Add key formatters #4

Open trickstival opened 5 years ago

trickstival commented 5 years ago

Do you think it's a good idea to provide functions that change keys formatting? I've imagined something like this:

import { snakify, camelify, kebabify } from 'shapify'

const obj = {
  firstProp: 'hello',
  secondProp: 'hey'
}

snakify(obj) // { 'first_prop': 'hello', 'second_prop': 'hey' }

// The same to camelify, kebabify, etc

I think I could implement that

posva commented 5 years ago

hmm, I think this is not something used enough to be added to the library and should be kept somewhere. But instead, something like a function that transforms all keys or something using a function. It needs more thinking though, and to be honest I'm prioritizing other libraries for a while regarding features