Deeply camelCases object keys, works on all environments where at least ES5 is available (IE9+), using UMD. Tiny in size, has no dependencies.
npm install camelcase-keys-all-env- Works on all environments where at least ES5 is available (IE9+).
- Works with snake_case, kebab-case (spinal-case) and PascalCase keys
- Supports Arrays and nested objects
- Best performing algorithm in most cases (see benchmarks)
- No dependencies
- Browser friendly
- Tiny in size (~1kB minified)
- A minified version included (./dist/camelcase-keys.min.js)
js
import camelcaseKeys from 'camelcase-keys-all-env'
`$3
- note the .default in the require statement
`js
var camelcaseKeys = require('camelcase-keys-all-env').default
``js
// Test object
const objStub = {
'some-very_long-key': 1,
Other_key_for_good_measure: false,
nested_key: [
true,
{
'Something_nested-deeply': 'asd',
},
false,
{
'other-nested-key': {
deeply_nested_key: true,
},
},
],
'yet-another-key': 'value',
}const camelcaseObj = camelcaseKeys(objStub)
`$3
> I recommend bundling this package with your application, using Webpack / Browserify /... If you can't / don't want to, you can append it to the "global" context (in case of a browser, it will probably be the window object)#### Browser
- download the minified version of the package from ./dist/camelcase-keys.min.js
- Upload it to your server / CDN
- Add a script element to your page
`html
`Setup
$3
`bash
$ yarn add camelcase-keys-all-env
`$3
`bash
$ npm install --save camelcase-keys-all-env
`Scripts
$3
`bash
$ yarn bench
`
- Runs a benchmark using one complex and one simple JSON object with comparison to other similar packages.$3
`bash
$ yarn build
`
- Generates a transpiled and minified (Babel) file in the ./dist directory$3
`bash
$ yarn test
`
- Runs unit tests$3
`bash
$ yarn lint
`
- Checks the code style (eslint)$3
`bash
$ yarn codestyle
``