Created
May 4, 2017 00:31
-
-
Save chadedrupt/5ef892a5751184367b3e7f138d5d35eb to your computer and use it in GitHub Desktop.
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
import * as _ from 'lodash' | |
const camelize = (object: any): any => { | |
if (_.isArray(object)) return _.map(object, camelize) | |
if (_.isPlainObject(object)) return _.chain(object) | |
.mapKeys((value: any, key: any) => _.camelCase(key)) | |
.mapValues((value: any) => camelize(value)) | |
.value() | |
return object | |
} | |
export default camelize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment