24 lines
629 B
JavaScript
24 lines
629 B
JavaScript
/**
|
|
* Transforms a kebab-case string to camelCase. A kebab-case string
|
|
* is a string with hyphen character as word separator.
|
|
*
|
|
* @param {String} str The hyphenized string
|
|
* @return {String} The camelized string
|
|
*/
|
|
export function kebabToCamel(str) {
|
|
let camelCased = str.replace(/-([a-z])/g, function(g) {
|
|
return g[1].toUpperCase();
|
|
});
|
|
return camelCased;
|
|
}
|
|
|
|
/**
|
|
* Transforms the first letter of a string to uppercase.
|
|
*
|
|
* @param {String} str The input string
|
|
* @return {String} The transformed string
|
|
*/
|
|
export function firstUpper(str) {
|
|
return str.charAt(0).toUpperCase() + str.substr(1);
|
|
}
|