@toolz/capitalize

1.0.0 • Public • Published

capitalize

capitalize is a JavaScript utility for capitalizing strings.

Usage

After installation, import the package:

import { capitalize } from '@toolz/capitalize';

.firstLetter()

Capitalizes the first letter - and only the first letter - in the string.

const API = {
   arguments: {
      string: {
         required,
         format: 'non-empty string',
      },
   },
   returns: string,
}

Examples

const florida = 'florida';
const country = 'united states of america';
console.log(capitalize.firstLetter(florida)); // Florida
console.log(capitalize.firstLetter(country)); // United states of america

.everyFirstLetter()

Splits the string by spaces (' '), treating each resulting value as a "word". It then capitalizes the first letter in each word.

const API = {
   arguments: {
      string: {
         required,
         format: 'non-empty string',
      },
   },
   returns: string,
}

Examples

const florida = 'florida';
const country = 'united states of america';
console.log(capitalize.everyFirstLetter(florida)); // Florida
console.log(capitalize.everyFirstLetter(country)); // United States Of America

Package Sidebar

Install

npm i @toolz/capitalize

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

6.53 kB

Total Files

6

Last publish

Collaborators

  • bytebodger