@github/catalyst
Version:
Helpers for creating HTML Elements as Controllers
13 lines • 496 B
JavaScript
export const dasherize = (str) => String(typeof str === 'symbol' ? str.description : str)
.replace(/([A-Z]($|[a-z]))/g, '-$1')
.replace(/--/g, '-')
.replace(/^-|-$/, '')
.toLowerCase();
export const mustDasherize = (str, type = 'property') => {
const dashed = dasherize(str);
if (!dashed.includes('-')) {
throw new DOMException(`${type}: ${String(str)} is not a valid ${type} name`, 'SyntaxError');
}
return dashed;
};
//# sourceMappingURL=dasherize.js.map