Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

better-title-case

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-title-case

> Convert a string to title case based on the [Daring Fireball](https://daringfireball.net/2008/05/title_case) rules.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
194
increased by4.86%
Maintainers
1
Weekly downloads
 
Created
Source

better-title-case

Convert a string to title case based on the Daring Fireball rules.

Rules

  • If the string is all-caps, it will be corrected
  • The following words are not capitalized by default: a, an, and, at, but, by, for, in, nor, of, on, or, so, the, to, up, yet, v, v., vs, and vs.
  • Words with capital letters other than the first are assumed to be capitalized properly and are skipped
  • It also skips any word that looks like a file path, file name, or URL
  • The first and last word are always capitalized
  • Sub-strings (those that are within quotes or parens/braces) are capitalized according to the same rules

Installation

$ npm install --save better-title-case

Usage

const titleCase = require('better-title-case');
console.log(titleCase('Nothing to Be Afraid of?'));
// Nothing to Be Afraid Of?

Advanced

You can configure better-title-case to add your own excluded words to the default list, or to prevent the use of the default list by passing a config object as the second parameter.

excludedWords

Type: Array
Default: []

Additional words to exclude from capitalization.

titleCase('Nothing to be afraid of?', {
    excludedWords: ['be']
});
// 'Nothing to be Afraid Of?'

useDefaultExcludedWords

Type: Boolean
Default: true

Disable the usage of the default list of excluded words.

titleCase('Nothing to be afraid of?', {
	useDefaultExcludedWords: false
});
// 'Nothing To Be Afraid Of?'

License

MIT © Brad Dougherty

FAQs

Package last updated on 12 Apr 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc