|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
589 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | /**
|
|---|
| 2 | * Converts the first character of string to upper case and the remaining to lower case.
|
|---|
| 3 | *
|
|---|
| 4 | * @template T - Literal type of the string.
|
|---|
| 5 | * @param {T} str - The string to be converted to uppercase.
|
|---|
| 6 | * @returns {Capitalize<T>} - The capitalized string.
|
|---|
| 7 | *
|
|---|
| 8 | * @example
|
|---|
| 9 | * const result = capitalize('fred') // returns 'Fred'
|
|---|
| 10 | * const result2 = capitalize('FRED') // returns 'Fred'
|
|---|
| 11 | */
|
|---|
| 12 | declare function capitalize<T extends string>(str: T): Capitalize<T>;
|
|---|
| 13 | type Capitalize<T extends string> = T extends `${infer F}${infer R}` ? `${Uppercase<F>}${Lowercase<R>}` : T;
|
|---|
| 14 |
|
|---|
| 15 | export { capitalize };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.