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.

23 lines (20 loc) 524 B
'use strict'; /** * 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" */ function capitalize(text) { return text.replace(/\b\w/g, function (l) { return l.toUpperCase(); }); } module.exports = capitalize;