Created
March 3, 2021 14:21
-
-
Save pinkhominid/3f6106ba3a1a0b2b720e86c183e0bbe5 to your computer and use it in GitHub Desktop.
Case conversion utils
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
// Derived from https://stackoverflow.com/a/52551910 | |
export function camelize(str) { | |
return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()); | |
} | |
export function pascalize(str) { | |
return (' ' + str).toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment