Created
December 20, 2017 04:06
-
-
Save miketaylr/94c111892b333bfdd57f249e102155cc to your computer and use it in GitHub Desktop.
https://miketaylr.com/pres/brazil-js-2017/ cssPropToIDL
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
function cssPropToIDL(prop, lowercaseFlag = false) { | |
let output = ""; | |
let uppercaseNext; | |
if (lowercaseFlag) { | |
prop = prop.slice(1); | |
} | |
for (let char of prop) { | |
if (char === String.fromCodePoint("0x002D")) { | |
uppercaseNext = true; | |
continue; | |
} | |
if (uppercaseNext) { | |
uppercaseNext = undefined; | |
output += char.toUpperCase(); | |
} else { | |
output += char; | |
} | |
} | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment