mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
* Enable strings category methods tests * Ensure escape, pad, padEnd, padStart, trim, trimEnd, trimStart, unescape return an empty string for falsey values * Coerce value to string using toString in truncate, capitalize and case methods * Ensure createCaseFirst returns an empty string for falsey values
21 lines
485 B
JavaScript
21 lines
485 B
JavaScript
import upperFirst from './upperFirst.js'
|
|
import toString from './toString.js'
|
|
|
|
/**
|
|
* Converts the first character of `string` to upper case and the remaining
|
|
* to lower case.
|
|
*
|
|
* @since 3.0.0
|
|
* @category String
|
|
* @param {string} [string=''] The string to capitalize.
|
|
* @returns {string} Returns the capitalized string.
|
|
* @example
|
|
*
|
|
* capitalize('FRED')
|
|
* // => 'Fred'
|
|
*/
|
|
const capitalize = (string) => upperFirst(toString(string).toLowerCase())
|
|
|
|
|
|
export default capitalize
|