Socket
Book a DemoInstallSign in
Socket

@directus/format-title

Package Overview
Dependencies
Maintainers
2
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@directus/format-title

Custom formatter that converts any string into Title Case

12.0.0
Source
npmnpm
Version published
Weekly downloads
8.3K
-32.28%
Maintainers
2
Weekly downloads
 
Created
Source

@directus/format-title

Custom formatter that converts any string into Title Case.

Capital letters are used for principal words. Articles, conjunctions, and prepositions do not get capital letters unless they start or end the title.

InputOutput
snowWhiteAndTheSevenDwarfsSnow White and the Seven Dwarfs
NewcastleUponTyneNewcastle Upon Tyne
brighton_on_seaBrighton on Sea
apple_releases_new_ipadApple Releases New iPad
7-food-trends7 Food Trends

The package contains a list of words that use some sort of special casing, for example: McDonalds, iPhone, and YouTube.

Installation

npm install @directus/format-title

Usage

The package by default converts camelCase, PascalCase, underscore, and "regular" sentences to Title Case.

formatTitle(string, [separator]);

formatTitle('snowWhiteAndTheSevenDwarfs');
// => Snow White and the Seven Dwarfs

You can provide an optional separator regex as a second parameter to support splitting the string on different characters. By default, this regex is set to /\s|-|_/g.

License

This package is licensed under the MIT License. See the LICENSE file for more information.

Additional Resources

Keywords

title-case

FAQs

Package last updated on 16 Jan 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.