Convert object keys to camelCase using
camelcase
This fork diverges from the author's repo, and only included a very useful feature provided in the original package added in v4.0.0.
There were another breaking change in v4.0.0 which is upgrading to es6: When used by our react app, we don't transpile es6 in the node_modules dir. When the es6 syntax is read by Uglify, things break.
Therefore, our solution is to maintain our own fork without the breaking change.
$ npm install --save https://github.com/leoi11/camelcase-keys
const camelcaseKeys = require('camelcase-keys');
camelcaseKeys({'foo-bar': true});
//=> {fooBar: true}
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true});
//=> {fooBar: true, nested: {unicornRainbow: true}}
const camelcaseKeys = require('camelcase-keys');
const argv = require('minimist')(process.argv.slice(2));
//=> {_: [], 'foo-bar': true}
camelcaseKeys(argv);
//=> {_: [], fooBar: true}
Type: Object
Object to camelCase.
Type: Object
Type: Array
of (string
|RegExp
)
Default: []
Exclude keys from being camelCased.
Type: boolean
Default: false
Recurse nested objects and objects in arrays.
MIT © Sindre Sorhus