Created
August 17, 2017 19:28
-
-
Save turbo/7bd8b57375af3f0d6a3279cbe9a53e3e to your computer and use it in GitHub Desktop.
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
normalizeCase = (mixed, clean = {}) => ( | |
Object | |
.keys(mixed) | |
.map( | |
c => clean[c.toLowerCase()] = | |
mixed[c] instanceof Object | |
? normalizeCase(mixed[c]) | |
: mixed[c] | |
), | |
clean | |
) | |
console.log(normalizeCase({ | |
CamelCase: "Blah", | |
name: "egerihor", | |
props: { | |
john: 4, | |
PascaL: "nope" | |
} | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment