UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

19 lines (18 loc) 502 B
/** * Capitalizes the first letter of each word in a given string. * * @param {string} text - The input string to be transformed. * @returns {string} The transformed string with each word's first letter capitalized. * @deprecated * * @example * capitalize("hello world"); // "Hello World" * * @example * capitalize("my little pony"); // "My Little Pony" */ export default function capitalize(text) { return text.replace(/\b\w/g, function (l) { return l.toUpperCase(); }); }