frontitygit
Version:
A Frontity source package for the REST API of self-hosted and WordPress.com sites
13 lines (12 loc) • 306 B
text/typescript
/**
* Receive a string in snake or kebab case and return it capitalized in upper
* camel case.
*
* @param str - Input string.
* @returns - Capitalized string.
*/
export default (str: string) =>
str
.split(/[\s-_]+/)
.map((word) => `${word[0].toUpperCase()}${word.slice(1)}`)
.join("");