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 🙏

© 2025 – Pkg Stats / Ryan Hefner

capitalizr

v1.0.3

Published

A simple Utility to capitalize a string in javascript

Downloads

11

Readme

capitalizr

capitalizr is a simple JavaScript utility to capitalize the first letter of a string with options for different capitalization styles.

Installation

To install capitalizr, use npm:

npm install capitalizr

Usage

You can use capitalizr in both plain JavaScript and in React. Here are examples of each.

Example in Plain JavaScript

You can use require() to import capitalizr in Node.js or JavaScript environments that support CommonJS.

const capitalizr = require('capitalizr');

console.log(capitalizr("hello WORLD")); // Default: "Hello world"
console.log(capitalizr("heLLo from me", 1)); // Option 1: "Hello From Me"
console.log(capitalizr("hello from mE. i am a fish.", 2)); // Option 2: "Hello from me. I am a fish."

Example in React

In a React project, you can use capitalizr with either require() or ES module import syntax.

Using require() in React

const capitalizr = require('capitalizr');

function App() {
    const text = "react is cool. i love coding.";
    return (
        <div>
            <h1>{capitalizr(text, 2)}</h1>
        </div>
    );
}

export default App;

Using import in React

import capitalizr from 'capitalizr';

function App() {
    const text = "hello world from react";
    return (
        <div>
            <h1>{capitalizr(text, 1)}</h1>
        </div>
    );
}

export default App;

API

capitalizr(str, option = 0)

Parameters:

  • str (string): The input string to capitalize.
  • option (number): The capitalization option (default is 0).
    • 0: Capitalizes only the first letter of the entire string.
    • 1: Capitalizes the first letter of each word in the string.
    • 2: Capitalizes the first letter of each sentence in the string, where sentences are separated by .

Returns:

  • A new string with the specified capitalization applied.

Examples

// Default: Capitalizes only the first letter
capitalizr("hello world"); // "Hello world"

// Option 1: Capitalizes the first letter of each word
capitalizr("hello world from react", 1); // "Hello World From React"

// Option 2: Capitalizes the first letter of each sentence
capitalizr("hello world. i am a fish.", 2); // "Hello world. I am a fish."

License

This project is licensed under the MIT License.