24 lines
631 B
JavaScript
24 lines
631 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) {
|
||
|
var camelCased = str.replace (/-([a-z])/, 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);
|
||
|
}
|