mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-01 02:33:54 +03:00
27 lines
485 B
Markdown
27 lines
485 B
Markdown
|
# capitalize
|
||
|
|
||
|
Converts the first character of string to upper case and the remaining to lower case.
|
||
|
|
||
|
## Signature
|
||
|
|
||
|
```typescript
|
||
|
function capitalize<T extends string>(str: T): Capitalize<T>;
|
||
|
```
|
||
|
|
||
|
### Parameters
|
||
|
|
||
|
`str` (`T`): The string to be converted to uppercase.
|
||
|
|
||
|
### Returns
|
||
|
|
||
|
(`Capitalize<string>`): The capitalized string.
|
||
|
|
||
|
## Examples
|
||
|
|
||
|
```typescript
|
||
|
import { capitalize } from 'es-toolkit/string';
|
||
|
|
||
|
capitalize('fred'); // returns 'Fred'
|
||
|
capitalize('FRED'); // returns 'Fred'
|
||
|
```
|