Transform keys is a pure function that changes object keys to the case you specify.
npm i -s transformkeys
import transformKeys from 'transformkeys'
const obj = transformKeys({
user_id: 1,
prop_name: 'hello'
})
obj.userId
// => 1You can specify the case by giving a second parameter:
import transformKeys from 'transformkeys'
const obj = transformKeys({
user_id: 1,
prop_name: 'hello'
}, 'pascal')
obj.UserId
// => 1For now, these cases are supported:
camelsnakedashconstantpascal
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Make sure tests pass:
npm t - Submit a pull request :D
MIT