npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

custom-capitalization

v1.1.0

Published

A package for capitalizing words with customizable exclusion lists.

Downloads

14

Readme

Custom-Capitalization

NPM Version NPM License

Custom-Capitalization is a JavaScript library that provides functions for capitalizing words in a sentence with customizable excluded words. It offers an easy-to-use interface for developers to capitalize sentences while excluding specific words from capitalization.

Features

  • Sentence Capitalization: Capitalize words in a sentence while preserving the capitalization of specific words.
  • Customizable Exclusion: Set default excluded words and add custom excluded words to control which words should not be capitalized.
  • Dynamic Exclusion Management: Easily add, remove, and move words between default and custom excluded word lists.
  • Flexible Usage: Use individual functions for setting excluded words, or directly capitalize sentences with customizable exclusion rules.

Changelog

Version 1.1.0 (April 1, 2024)

  • Corrected version number from 1.0.2 to 1.1.0.

Version 1.0.2 (March 28, 2024)

  • Updated import syntax for easier usage:
    • Previously: import { setDefault, setCustom, delDefault, delCustom, moveDefaultToCustom, moveCustomToDefault, capitalize, capitalizeAllWords, defaultExcludedWords, customExcludedWords } from 'custom-capitalization';
    • Now: import customCapitalization from 'custom-capitalization';

Version 1.0.1 (March 27, 2024)

  • Corrected the path to the main file in package.json

Version 1.0.0 (March 26, 2024)

  • Initial release of Custom-Capitalization.

Installation

To install Custom-Capitalization, you can use npm:

npm install custom-capitalization

Usage

Basic Usage

import customCapitalization from 'custom-capitalization';

console.log(customCapitalization.capitalize('that quick brown fox jumps over the lazy dog in the park', true, true)); // Output: That Quick Brown Fox Jumps Over the Lazy Dog in the Park

console.log(customCapitalization.capitalizeAllWords('that quick brown fox jumps over the lazy dog in the park')); // Output: THAT QUICK BROWN FOX JUMPS OVER THE LAZY DOG IN THE PARK

Excluding Words

import customCapitalization from 'custom-capitalization';

customCapitalization.setDefault('that', 'over');
customCapitalization.setCustom('dog','fox');

console.log(customCapitalization.capitalize('that quick brown fox jumps over the lazy dog in the park', true, true)); // Output: That Quick Brown fox Jumps over the Lazy dog in the Park

Removing and Moving Words

import customCapitalization from 'custom-capitalization';

customCapitalization.setCustom('dog','fox');

customCapitalization.delDefault('in', 'the');
customCapitalization.delCustom('fox');

customCapitalization.moveDefaultToCustom('that');
customCapitalization.moveCustomToDefault('dog');

console.log(customCapitalization.capitalize('That quick brown fox jumps over the lazy dog in the park with joy', true, true)); // Output: That Quick Brown Fox Jumps Over The Lazy dog In The Park With Joy

Default Excluded Words

The defaultExcludedWords variable contains a set of words that are excluded from capitalization by default. These words are commonly used as articles, conjunctions, and prepositions that are typically not capitalized in sentences.

Current Default Excluded Words

  • a, an, the, and, but, or, for, nor, on, at, to, by, in, of

These words can be removed from the default excluded list using the delDefault function provided by the library.

License

This project is licensed under the ISC License - see the LICENSE.md file for details.