Skip to content

Instantly share code, notes, and snippets.

View gregogalante's full-sized avatar
✌️
What's happening?

Gregorio Galante gregogalante

✌️
What's happening?
View GitHub Profile
@gregogalante
gregogalante / SnakeToCamelCase.js
Last active March 5, 2018 11:40 — forked from emcmanus/snakeToCamelCase.js
ES6 module to recursively convert snake case keys in an object to camel case using lodash.
export function camelCaseKeys(object) {
let camelCaseObject = _.cloneDeep(object)
if (_.isArray(camelCaseObject)) {
return _.map(camelCaseObject, camelCaseKeys)
}
if (_.isString(camelCaseObject)) {
return camelCaseObject
}
camelCaseObject = _.mapKeys(camelCaseObject, (value, key) => _.camelCase(key))