A utility to convert the first letter of each word to an uppercase value, with special exceptions for English contractions and possessives. Non-string values will cause a ZeroDepError
to be thrown.
Full documentation is available at the zerodep.app page.
All @zerodep packages support both ESM and CJS.
import { stringTitleCase } from '@zerodep/string-titlecase';
// or
const { stringTitleCase } = require('@zerodep/string-titlecase');
stringTitleCase('california'); // "California"
stringTitleCase('New york'); // "New York"
stringTitleCase('sanchez-ferrero'); // "Sanches-Ferrero"
stringTitleCase('this is IMPORANT'); // "This Is IMPORANT"
stringTitleCase("o'neill"); // "O'Neill"
stringTitleCase('3.14 pi'); // "3.14 Pi"
stringTitleCase('éclair'); // "Éclair"
stringTitleCase("john's"); // "John's"
stringTitleCase("i'll be there"); // "I'll Be There"
stringTitleCase(''); // ""
stringTitleCase({ not: 'a string' }); // throws ZeroDepError: Value is not a string