Last active
August 28, 2017 16:25
-
-
Save tai2/58e02ced9316ca8579c469bdc9d0de9a to your computer and use it in GitHub Desktop.
snakeCaseKeys and camelCaseKeys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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