Skip to content

Instantly share code, notes, and snippets.

@tai2
Last active August 28, 2017 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tai2/58e02ced9316ca8579c469bdc9d0de9a to your computer and use it in GitHub Desktop.
Save tai2/58e02ced9316ca8579c469bdc9d0de9a to your computer and use it in GitHub Desktop.
snakeCaseKeys and camelCaseKeys
function snakeCaseKeys(obj) {
const tr = obj => _.transform(obj, (result, value, key) => {
result[_.snakeCase(key)] = _.isPlainObject(value) ? tr(value) : value
});
return tr(obj);
}
function camelCaseKeys(obj) {
const tr = obj => _.transform(obj, (result, value, key) => {
result[_.camelCase(key)] = _.isPlainObject(value) ? tr(value) : value
});
return tr(obj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment