@cahil/utils › Globals › transforms
▸ capitalize(text
: string): string
Defined in src/transforms/capitalize.ts:19
Capitalize the first letter of a string
example
const name = capitalize('bob') // => 'Bob'
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The string to be capitalized |
Returns: string
Returns the capitalized string
▸ noramlizeURL(…urlParts
: string[]): string
Defined in src/transforms/normalizeURL.ts:62
Sanitises and safely joins sections of a URL, this includes removing duplicate slashes in the path and ensuring correctly formatted protocols.
example
const url = normalizeURL('https://cahilfoley.github.io/', '/utils') // => 'https://cahilfoley.github.io/utils'
Parameters:
Name | Type | Description |
---|---|---|
...urlParts |
string[] | The URL parts to be joined and normalized |
Returns: string
Returns the joined and normalized URL parts as a string
▸ toProperList(items
: string[]): string
Defined in src/transforms/toProperList.ts:19
Joins together several strings or numbers in a properly formatted English list. The last two items are seperated by the word ‘and’ and the remaining items are seperated by a comma and space.
example
const itemsString = toProperList(['apples', 'pears', 'bananas']) // => 'apples, pears and bananas'
Parameters:
Name | Type | Description |
---|---|---|
items |
string[] | Array of strings |
Returns: string
▸ toProperList(…items
: string[]): string
Defined in src/transforms/toProperList.ts:20
Parameters:
Name | Type |
---|---|
...items |
string[] |
Returns: string