camelcase-keys
Advanced tools
Comparing version 3.0.0 to 4.0.0
25
index.js
'use strict'; | ||
var mapObj = require('map-obj'); | ||
var camelCase = require('camelcase'); | ||
const mapObj = require('map-obj'); | ||
const camelCase = require('camelcase'); | ||
var has = function (arr, key) { | ||
return arr.some(function (pattern) { | ||
return typeof pattern === 'string' ? pattern === key : pattern.test(key); | ||
}); | ||
}; | ||
const has = (arr, key) => arr.some(x => typeof x === 'string' ? x === key : x.test(key)); | ||
module.exports = function (input, options) { | ||
options = options || {}; | ||
module.exports = (input, opts) => { | ||
opts = Object.assign({ | ||
exclude: [], | ||
deep: false | ||
}, opts); | ||
var exclude = options.exclude || []; | ||
return mapObj(input, function (key, val) { | ||
key = has(exclude, key) ? key : camelCase(key); | ||
return mapObj(input, (key, val) => { | ||
key = has(opts.exclude, key) ? key : camelCase(key); | ||
return [key, val]; | ||
}); | ||
}, {deep: opts.deep}); | ||
}; |
{ | ||
"name": "camelcase-keys", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Convert object keys to camelCase", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
@@ -43,7 +43,10 @@ "scripts": { | ||
"text", | ||
"convert" | ||
"convert", | ||
"deep", | ||
"recurse", | ||
"recursive" | ||
], | ||
"dependencies": { | ||
"camelcase": "^3.0.0", | ||
"map-obj": "^1.0.0" | ||
"map-obj": "^2.0.0" | ||
}, | ||
@@ -53,3 +56,6 @@ "devDependencies": { | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
@@ -21,3 +21,9 @@ # camelcase-keys [![Build Status](https://travis-ci.org/sindresorhus/camelcase-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase-keys) | ||
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true}); | ||
//=> {fooBar: true, nested: {unicornRainbow: true}} | ||
``` | ||
```js | ||
const camelcaseKeys = require('camelcase-keys'); | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
@@ -47,3 +53,3 @@ //=> {_: [], 'foo-bar': true} | ||
Type: `Array` of (`string`|`RegExp`)<br> | ||
Type: `string[]` `RegExp[]`<br> | ||
Default: `[]` | ||
@@ -53,5 +59,12 @@ | ||
##### deep | ||
Type: `boolean`<br> | ||
Default: `false` | ||
Recurse nested objects and objects in arrays. | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3618
68
14
+ Addedmap-obj@2.0.0(transitive)
- Removedmap-obj@1.0.1(transitive)
Updatedmap-obj@^2.0.0