Skip to content

leoskyrocker/camelcase-keys

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

camelcase-keys (forked)

Convert object keys to camelCase using camelcase

About this fork

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.

Install

$ npm install --save https://github.com/leoi11/camelcase-keys

Usage

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}

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.

deep

Type: boolean
Default: false

Recurse nested objects and objects in arrays.

License

MIT © Sindre Sorhus

About

Convert object keys to camelCase

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%