Created
May 9, 2018 08:55
-
-
Save black-black-cat/aa8d513220b368f6bab242df959f8181 to your computer and use it in GitHub Desktop.
toCamel and toKebab
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
function toCamel (s) { return s.replace(/-(\w)/g, (m, c) => c.toUpperCase()) } | |
function toKebab (s) { return s.replace(/([A-Z])(?=[^A-Z]+?)|([A-Z]+?)((?=[A-Z][^A-Z])|$)/g, (m, c, cc) => '-' + (c || cc||'').toLowerCase()) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment