stringzy
Version:
A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.
16 lines (15 loc) • 407 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.kebabCase = kebabCase;
function kebabCase(text) {
if (text == null)
return '';
return text
.trim()
.replace(/[\s_]+/g, '-')
.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/[^\w-]/g, '-')
.toLowerCase()
.replace(/-+/g, '-')
.replace(/^-+|-+$/g, '');
}