Files
emaui/node_modules/es-toolkit/dist/string/capitalize.mjs
2026-05-29 15:23:46 +03:00

18 lines
542 B
JavaScript

//#region src/string/capitalize.ts
/**
* Converts the first character of string to upper case and the remaining to lower case.
*
* @template T - Literal type of the string.
* @param {T} str - The string to be converted to uppercase.
* @returns {Capitalize<T>} - The capitalized string.
*
* @example
* const result = capitalize('fred') // returns 'Fred'
* const result2 = capitalize('FRED') // returns 'Fred'
*/
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}
//#endregion
export { capitalize };