transformkeys
v0.1.1
Published
Transforms object properties to another case.
Downloads
14
Readme
Transform Keys
Transform keys is a pure function that changes object keys to the case you specify.
Installation
npm i -s transformkeys
Usage
import transformKeys from 'transformkeys'
const obj = transformKeys({
user_id: 1,
prop_name: 'hello'
})
obj.userId
// => 1
You 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
// => 1
For now, these cases are supported:
camel
snake
dash
constant
pascal
Contributing
- 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
License
MIT