camelcase-keys-recurse

3.1.0 • Public • Published

camelcase-keys Build Status

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

Package Sidebar

Install

npm i camelcase-keys-recurse

Weekly Downloads

0

Version

3.1.0

License

MIT

Last publish

Collaborators

  • sjmcdowall