Lets you call a function, titleCase, to transform a sentence into title case with the option of having some protected words.
npm i title-case-edward
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"
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" ✅