https://github.com/ad-si/capitalizer
Capitalize a string or all words in a string or all items in an array or all values in an object
https://github.com/ad-si/capitalizer
Last synced: 6 months ago
JSON representation
Capitalize a string or all words in a string or all items in an array or all values in an object
- Host: GitHub
- URL: https://github.com/ad-si/capitalizer
- Owner: ad-si
- License: mit
- Created: 2015-02-21T17:15:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-21T18:17:10.000Z (over 10 years ago)
- Last Synced: 2025-03-10T12:16:30.844Z (7 months ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Capitalizer
Capitalize a string or all words in a string or all items in an array or all values in an object.
## Installation
```
$ npm install --save capitalizer
```and in your files
```
var capitalize = require('capitalizer')
```To use it in the browser please use [browserify](http://browserify.org).
## Usage
Capitalize the first letter of a string:
```js
assert.equal(capitalize('test'), 'Test')// or
assert.equal(capitalize.first('test'), 'Test')
```
Capitalize all words in a string:
```js
assert.equal(
capitalize.all('this is a test sentence'),
'This Is A Test Sentence'
)
```Capitalize all words in an array:
```js
assert.equal(
capitalize(['this', 'is', 'a', 'test', 'sentence']),
['This', 'Is', 'A', 'Test', 'Sentence']
)
```TODO: Recursively capitalize all strings in an object:
```js
assert.equal(
capitalize({
name: 'john',
hobby: 'chillin',
address: {
country: 'australia',
street: 'wayne boulevard',
}
}),
{
name: 'John',
hobby: 'Chillin',
address: {
country: 'Australia',
street: 'Wayne boulevard'
}
}
)
```