@huyennbl/capitalize-word
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

capitalize-word

Installation

npm install @huyennbl/capitalize-word

Usage

capitalizeWord(str, word)

  • 1st argument: input string
  • 2nd argument: word to be capitalized in str
  • Returns a new string with all the matched word (case-insensitive) in str, having first letter capitalized, and the remaining characters of each word are in lowercase.
  • Partially matches are ignore, e.g.: capitalizeWord('github', 'git') will still return 'github')
import { capitalizeWord } from '@huyennbl/capitalize-word'

capitalizeWord('frank talks about it frankly', 'frank');
// 'Frank talks about it frankly'
// => first 'frank' is fully match, so capitalized. 'frankly' is partially match, hence ignored.

capitalizeWord('Lorem ipsum...', 'ipsUM')
// 'Lorem Ipsum...'

Package Sidebar

Install

npm i @huyennbl/capitalize-word

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.11 kB

Total Files

7

Last publish

Collaborators

  • huyennbl