Convert object keys to camelCase
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2dd25eb Oct 16, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bench Meta tweaks Oct 16, 2018
.editorconfig Meta tweaks Oct 16, 2018
.gitattributes Meta tweaks Oct 16, 2018
.gitignore Meta tweaks Oct 16, 2018
.npmrc Meta tweaks Oct 16, 2018
.travis.yml Meta tweaks Oct 16, 2018
index.js Meta tweaks Oct 16, 2018
license Meta tweaks Oct 16, 2018
package.json 5.0.0 Oct 16, 2018
readme.md Meta tweaks Oct 16, 2018
test.js Meta tweaks Oct 16, 2018

readme.md

camelcase-keys Build Status

Convert object keys to camelCase using camelcase

Install

$ npm install camelcase-keys

Usage

const camelcaseKeys = require('camelcase-keys');

// Convert an object
camelcaseKeys({'foo-bar': true});
//=> {fooBar: true}

// Convert an array of objects
camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]);
//=> [{fooBar: true}, {barFoo: false}]

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}

API

camelcaseKeys(input, [options])

input

Type: Object Object[]

Object or array of objects to camelCase.

options

Type: Object

exclude

Type: Array<string|RegExp>
Default: []

Exclude keys from being camelCased.

deep

Type: boolean
Default: false

Recurse nested objects and objects in arrays.

Related

License

MIT © Sindre Sorhus