Created
July 24, 2018 18:35
-
-
Save ccarrasc/1e70fc2dd56767ff7350e506d98500e1 to your computer and use it in GitHub Desktop.
Convert PascalCased props to camelCase (not really tested)
This file contains hidden or 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
const toCamelCaseProps = (obj: any) => { | |
return Object.keys(obj).reduce((renamed, key) => { | |
let value = obj[key]; | |
if (typeof value === 'object' && value) { | |
value = toCamelCaseProps(value); | |
} | |
const camelCasedKey = key.charAt(0).toLowerCase() + key.slice(1); | |
renamed[camelCasedKey] = value; | |
return renamed; | |
}, {}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment