Socket
Socket
Sign inDemoInstall

camelcase-keys

Package Overview
Dependencies
3
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.1.0

20

index.js
'use strict';
const mapObj = require('map-obj');
const camelCase = require('camelcase');
const QuickLru = require('quick-lru');
const has = (arr, key) => arr.some(x => typeof x === 'string' ? x === key : x.test(key));
const cache = new QuickLru({maxSize: 100000});
module.exports = (input, opts) => {
opts = Object.assign({
exclude: [],
deep: false
}, opts);
const exclude = opts.exclude;
return mapObj(input, (key, val) => {
key = has(opts.exclude, key) ? key : camelCase(key);
if (!(exclude && has(exclude, key))) {
if (cache.has(key)) {
key = cache.get(key);
} else {
const ret = camelCase(key);
if (key.length < 100) { // Prevent abuse
cache.set(key, ret);
}
key = ret;
}
}
return [key, val];
}, {deep: opts.deep});
};

20

package.json
{
"name": "camelcase-keys",
"version": "4.0.0",
"version": "4.1.0",
"description": "Convert object keys to camelCase",

@@ -16,3 +16,4 @@ "license": "MIT",

"scripts": {
"test": "xo && ava"
"test": "xo && ava",
"bench": "matcha bench/bench.js"
},

@@ -49,12 +50,21 @@ "files": [

"dependencies": {
"camelcase": "^3.0.0",
"map-obj": "^2.0.0"
"camelcase": "^4.1.0",
"map-obj": "^2.0.0",
"quick-lru": "^1.0.0"
},
"devDependencies": {
"ava": "*",
"matcha": "^0.7.0",
"xo": "*"
},
"xo": {
"esnext": true
"overrides": [
{
"files": "bench/bench.js",
"rules": {
"import/no-unresolved": "off"
}
}
]
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc