Socket
Socket
Sign inDemoInstall

capitalizer

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    capitalizer

Capitalize a string, all words in a string, all items in an array or all values in an object


Version published
Weekly downloads
7
Maintainers
1
Install size
41.5 kB
Created
Weekly downloads
 

Readme

Source

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.

Usage

Capitalize the first letter of a string:

assert.equal(capitalize('test'), 'Test')

// or

assert.equal(capitalize.first('test'), 'Test')

Capitalize all words in a string:

assert.equal(
	capitalize.all('this is a test sentence'),
	'This Is A Test Sentence'
)

Capitalize all words in an array:

assert.equal(
	capitalize(['this', 'is', 'a', 'test', 'sentence']),
	['This', 'Is', 'A', 'Test', 'Sentence']
)

TODO: Recursively capitalize all strings in an object:

assert.equal(
	capitalize({
		name: 'john',
		hobby: 'chillin',
		address: {
			country: 'australia',
			street: 'wayne boulevard',
		}
	}),
	{
        name: 'John',
        hobby: 'Chillin',
        address: {
            country: 'Australia',
            street: 'Wayne boulevard'
        }
    }
)

Keywords

FAQs

Last updated on 21 Feb 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc