mr-case
Version:
55 functions to seamlessly transform strings, arrays, and object keys between different cases (camelCase, snake_case, kebab-case, PascalCase, Title Case, and more), clean and format text, extract URL components, and perform common text operations like mas
11 lines (8 loc) • 356 B
JavaScript
function textToPascal(text) {
if (typeof text !== 'string' || !text.trim()) throw new Error('Input must be a non-empty string');
return text
.replace(/[^a-zA-Z0-9]+/g, ' ')
.replace(/\b\w/g, char => char.toUpperCase())
.replace(/\s+/g, ''); // Remove spaces after capitalization
}
module.exports = textToPascal;