Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
capitalize
Advanced tools
Capitalize the first letter of a string, or all words in a string.
Capitalize the first letter of a string:
var capitalize = require('./')
var test = require('tape')
test('Capitalize first letter', function (t) {
t.plan(1)
t.equal(capitalize("united states"), "United states")
})
Or capitalize each word in a string:
test('Capitalize each word', function (t) {
t.plan(1)
t.equal(capitalize.words("united states"), "United States")
})
Thanks to @c990802 and Stack Overflow, capitalize handles international characters:
test('Capitalize words with international characters', function (t) {
t.plan(1)
t.equal(capitalize.words('hello-cañapolísas'), 'Hello-Cañapolísas')
})
and thanks to @ultraflynn, capitalize properly handles quotes within the string:
test('Capitalize each word, ignoring quotes', function(t) {
t.plan(1)
t.equal(capitalize.words("it's a nice day"), "It's A Nice Day")
})
npm install capitalize
MIT
FAQs
capitalize the first letter of a string, or all words in a string
The npm package capitalize receives a total of 48,352 weekly downloads. As such, capitalize popularity was classified as popular.
We found that capitalize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.