UNPKG

@technobuddha/library

Version:
12 lines (11 loc) 385 B
/** * Capitalize the first letter of each word in a string * * @param input The string to capitalize * @param __namedParameters see {@link Options} * @default lowercase false */ export function toCapitalWordCase(input, { lowerCase = false } = {}) { return (lowerCase ? input.toLowerCase() : input).replace(/\b\w/ug, l => l.toUpperCase()); } export default toCapitalWordCase;