Skip to content

Instantly share code, notes, and snippets.

@ChristopherJennings
Created July 24, 2017 14:34
Show Gist options
  • Save ChristopherJennings/3086c7225f6b391ecca9feb6bf3affc4 to your computer and use it in GitHub Desktop.
Save ChristopherJennings/3086c7225f6b391ecca9feb6bf3affc4 to your computer and use it in GitHub Desktop.
Kentico Cloud TypeScript SDK property mapper
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