
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
The titleize npm package is a utility for converting strings to title case, where the first letter of each word is capitalized. It is useful for formatting titles or headings in text content.
Title casing a single string
This feature allows you to convert a single string to title case. It capitalizes the first letter of each word while keeping the rest of the letters in lowercase.
const titleize = require('titleize');
console.log(titleize('mr. jones is from new york.')); // 'Mr. Jones Is From New York.'
Title casing an array of strings
This feature allows you to map over an array of strings and convert each one to title case.
const titleize = require('titleize');
const titles = ['mr. jones', 'dr. smith'];
const titleCased = titles.map(title => titleize(title));
console.log(titleCased); // ['Mr. Jones', 'Dr. Smith']
Ignoring certain words from being capitalized
This feature allows you to specify an array of words to ignore during the title casing process, so they remain in lowercase.
const titleize = require('titleize');
titleize('the wind in the willows', { ignore: ['the', 'in'] }); // 'The Wind in the Willows'
The 'to-title-case' package also converts strings to title case. It is similar to 'titleize' but does not provide options to ignore certain words from being capitalized.
The 'capitalize' package can capitalize the first letter of each word in a string, similar to 'titleize'. However, it also offers functions to capitalize or lowercase entire strings, which 'titleize' does not.
The 'change-case' package is a more comprehensive string manipulation library that includes a function for title casing among many other case conversion functions. It offers more versatility compared to 'titleize' which is focused solely on title casing.
Capitalize every word in a string:
unicorn cake
→Unicorn Cake
npm install titleize
import titleize from 'titleize';
titleize('foo bar');
//=> 'Foo Bar'
titleize('foo-bar');
//=> 'Foo-Bar'
FAQs
Capitalize every word in a string: `unicorn cake` → `Unicorn Cake`
The npm package titleize receives a total of 2,493,886 weekly downloads. As such, titleize popularity was classified as popular.
We found that titleize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.