2 const mapObj = require('map-obj');
3 const camelCase = require('camelcase');
4 const QuickLru = require('quick-lru');
6 const has = (arr, key) => arr.some(x => typeof x === 'string' ? x === key : x.test(key));
7 const cache = new QuickLru({maxSize: 100000});
9 const camelCaseConvert = (input, opts) => {
10 opts = Object.assign({
14 const exclude = opts.exclude;
16 return mapObj(input, (key, val) => {
17 if (!(exclude && has(exclude, key))) {
21 const ret = camelCase(key);
23 if (key.length < 100) { // Prevent abuse
32 }, {deep: opts.deep});
35 module.exports = (input, opts) => {
36 if (Array.isArray(input)) {
37 return Object.keys(input).map(key => camelCaseConvert(input[key], opts));
39 return camelCaseConvert(input, opts);