https://github.com/bytebodger/capitalize
A JavaScript utility for capitalizing strings
https://github.com/bytebodger/capitalize
Last synced: about 1 year ago
JSON representation
A JavaScript utility for capitalizing strings
- Host: GitHub
- URL: https://github.com/bytebodger/capitalize
- Owner: bytebodger
- License: mit
- Created: 2021-04-02T23:28:46.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-03T00:14:03.000Z (about 5 years ago)
- Last Synced: 2025-05-19T00:17:28.803Z (about 1 year ago)
- Language: JavaScript
- Size: 79.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# capitalize
`capitalize` is a JavaScript utility for capitalizing strings.
## Usage
After installation, import the package:
```javascript
import { capitalize } from '@toolz/capitalize';
```
### .firstLetter()
Capitalizes the first letter - and only the first letter - in the string.
```javascript
const API = {
arguments: {
string: {
required,
format: 'non-empty string',
},
},
returns: string,
}
```
**Examples**
```javascript
const florida = 'florida';
const country = 'united states of america';
console.log(capitalize.firstLetter(florida)); // Florida
console.log(capitalize.firstLetter(country)); // United states of america
```
### .everyFirstLetter()
Splits the string by spaces (`' '`), treating each resulting value as a "word". It then capitalizes the first letter in each word.
```javascript
const API = {
arguments: {
string: {
required,
format: 'non-empty string',
},
},
returns: string,
}
```
**Examples**
```javascript
const florida = 'florida';
const country = 'united states of america';
console.log(capitalize.everyFirstLetter(florida)); // Florida
console.log(capitalize.everyFirstLetter(country)); // United States Of America
```