title-case-edward

1.1.6 • Public • Published

Title Case

About

Lets you call a function, titleCase, to transform a sentence into title case with the option of having some protected words.

Installation

npm i title-case-edward

Usage

Transform a sentence

You can pass the function a string which is will transform to tile case with the following rules:

  • The first and last word will always be capitalized,
  • words of three letters or less will not be capitalized,
  • only the first element of a hyphenated compound will be capitalized,
  • spelt-out numbers will be capitalized,
  • both elements of hyphenated, spelt-out numbers will be capitalized.

Example:

const titleCase = require("title-case-edward");

titleCase("i have twenty-two reasons to use this package"); //=> "I Have Twenty-Two Reasons to use This Package"

Include protected words

You can optionally pass the function a second argument of an array. The matching strings in the sentence will always be displayed the same way as in the array.

Example:

const titleCase = require("title-case-edward");

titleCase("how an fMRI is used"); //=> "How an Fmri is Used" ⛔️
titleCase("how an fMRI is used", ["fMRI"]); //=> "How an fMRI is Used" ✅

Readme

Keywords

Package Sidebar

Install

npm i title-case-edward

Weekly Downloads

1

Version

1.1.6

License

ISC

Unpacked Size

3.53 kB

Total Files

3

Last publish

Collaborators

  • eggkettle