camelcase-keys-recurse
v3.1.0
Published
Convert object keys to camelCase with optional recursion
Downloads
6
Maintainers
Readme
camelcase-keys
Convert object keys to camelCase using
camelcase
Install
$ npm install --save camelcase-keys
Usage
const camelcaseKeys = require('camelcase-keys');
camelcaseKeys({'foo-bar': true});
//=> {fooBar: true}
const argv = require('minimist')(process.argv.slice(2));
//=> {_: [], 'foo-bar': true}
camelcaseKeys(argv);
//=> {_: [], fooBar: true}
camelcaseKeys({'foo-bar': {'bar-foo': true}}, {recurse: true});
//=> {fooBar: {barFoo: true}}
camelcaseKeys({'foo-bar': {'bar-foo': true}}, {recurse: false});
//=> {fooBar: {bar-foo: true}}
API
camelcaseKeys(input, [options])
input
Type: Object
Object to camelCase.
options
Type: Object
exclude
Type: Array
of (string
|RegExp
) Default: []
Exclude keys from being camelCased.
recurse
Type: Boolean
Default: false
If true use a recursive algorithm to traverse the entire object graph otherwise only the first level keys are processed.
License
MIT © Sindre Sorhus