@danielhaim/titlecaser
Version:
A powerful utility for transforming text to title case with support for multiple style guides and extensive customization options.
25 lines (22 loc) • 757 B
TypeScript
export interface TitleCaserOptions {
style?: 'ap' | 'apa' | 'chicago' | 'wikipedia' | 'nyt' | 'british';
smartQuotes?: boolean;
neverCapitalize?: string[];
wordReplacementsList?: Array<{ [key: string]: string }>;
debug?: boolean;
}
export class TitleCaser {
constructor(options?: TitleCaserOptions);
toTitleCase(text: string): string;
setReplaceTerms(terms: Array<{ [key: string]: string }>): void;
addReplaceTerm(term: string, replacement: string): void;
removeReplaceTerm(term: string): void;
addExactPhraseReplacements(phrases: Array<{ [key: string]: string }>): void;
setStyle(style: string): void;
}
export default TitleCaser;
declare global {
interface String {
toTitleCase(options?: TitleCaserOptions): string;
}
}