snakecase-keys
Advanced tools
Comparing version 2.0.0 to 2.1.0
15
index.js
@@ -7,7 +7,18 @@ 'use strict' | ||
module.exports = function (obj, options) { | ||
options = Object.assign({deep: true}, options) | ||
options = Object.assign({ deep: true, exclude: [] }, options) | ||
return map(obj, function (key, val) { | ||
return [snakeCase(key), val] | ||
return [ | ||
matches(options.exclude, key) ? key : snakeCase(key), | ||
val | ||
] | ||
}, options) | ||
} | ||
function matches (patterns, value) { | ||
return patterns.some(function (pattern) { | ||
return typeof pattern === 'string' | ||
? pattern === value | ||
: pattern.test(value) | ||
}) | ||
} |
{ | ||
"name": "snakecase-keys", | ||
"main": "index.js", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Convert an object's keys to snake case", | ||
@@ -25,3 +25,3 @@ "license": "MIT", | ||
"tape": "^4.0.0", | ||
"standard": "^11.0.1" | ||
"standard": "^12.0.1" | ||
}, | ||
@@ -28,0 +28,0 @@ "files": [ |
@@ -1,2 +0,2 @@ | ||
# snakecase-keys [![Build Status](https://travis-ci.org/bendrucker/snakecase-keys.svg?branch=master)](https://travis-ci.org/bendrucker/snakecase-keys) | ||
# snakecase-keys [![Build Status](https://travis-ci.org/bendrucker/snakecase-keys.svg?branch=master)](https://travis-ci.org/bendrucker/snakecase-keys) [![Greenkeeper badge](https://badges.greenkeeper.io/bendrucker/snakecase-keys.svg)](https://greenkeeper.io/) | ||
@@ -48,2 +48,9 @@ > Convert an object's keys to snake case | ||
###### exclude | ||
Type: `array[string || regexp]` | ||
Default: `[]` | ||
An array of strings or regular expressions matching keys that will be excluded from snake-casing. | ||
## Related | ||
@@ -50,0 +57,0 @@ |
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3488
19
62
0