Created
July 24, 2017 14:34
-
-
Save ChristopherJennings/3086c7225f6b391ecca9feb6bf3affc4 to your computer and use it in GitHub Desktop.
Kentico Cloud TypeScript SDK property mapper
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
export function GetPascalCaseFromKenticoCloudName(name: string) { | |
let result = ''; | |
let upperNext = false; | |
for (let i = 0; i < name.length; i++) { | |
let isSeparator = name[i] === '_'; | |
if (i === 0 || isSeparator) { | |
upperNext = true; | |
} | |
if (!isSeparator) { | |
result = result + (upperNext ? name[i].toUpperCase() : name[i]); | |
upperNext = false; | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment