@danielhaim/titlecaser
Version:
Converts a string to title case with multiple style options, ability to ignore certain words, and handle acronyms
19 lines (15 loc) • 504 B
JavaScript
import { TitleCaser } from './src/TitleCaser.js';
if ( String.prototype.toTitleCase === undefined ) {
String.prototype.toTitleCase = function ( options ) {
const titleCaser = new TitleCaser ( options );
return titleCaser.toTitleCase ( this );
};
}
// Export for Node.js environment
if ( typeof module === 'object' && module.exports ) {
module.exports = { TitleCaser };
}
// Export for web environment
if ( typeof window !== 'undefined' && window.document ) {
window.TitleCaser = TitleCaser;
}