23 lines
614 B
JavaScript
23 lines
614 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Convert a string from camel case to dash-case
|
|
* @param {string} string - probably a component tag name
|
|
* @returns {string} component name normalized
|
|
*/
|
|
function camelToDashCase(string) {
|
|
return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
|
|
}
|
|
|
|
/**
|
|
* Convert a string containing dashes to camel case
|
|
* @param {string} string - input string
|
|
* @returns {string} my-string -> myString
|
|
*/
|
|
function dashToCamelCase(string) {
|
|
return string.replace(/-(\w)/g, (_, c) => c.toUpperCase())
|
|
}
|
|
|
|
exports.camelToDashCase = camelToDashCase;
|
|
exports.dashToCamelCase = dashToCamelCase;
|