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

@rgbdev/change-case

v3.0.2

Published

Convert a string between camelCase, PascalCase, Title Case, snake_case and more.

Downloads

3

Readme

Change Case

NPM version NPM downloads Build status Test coverage Greenkeeper badge

Convert strings between camelCase, PascalCase, Title Case, snake_case, lowercase, UPPERCASE, CONSTANT_CASE and more.

All methods support Unicode (non-ASCII characters) and non-string entities, such as objects with a toString property, numbers and booleans. Empty values (null and undefined) will result in an empty string.

Methods are also available on npm as an individual packages.

Installation

npm install change-case --save

Usage

var changeCase = require('change-case')
//=> { isUpperCase: [Function], camelCase: [Function], ... }

Available methods (short-hand shown below, long-hand available in examples):

All methods accept two arguments, the string to change case and an optional locale.

camelCase

NPM version NPM downloads Build status Test coverage

Return as a string with the separators denoted by having the next letter capitalized.

changeCase.camelCase('test string')
//=> "testString"

constantCase

NPM version NPM downloads Build status Test coverage

Return as an upper case, underscore separated string.

changeCase.constantCase('test string')
//=> "TEST_STRING"

dotCase

NPM version NPM downloads Build status Test coverage

Return as a lower case, period separated string.

changeCase.dotCase('test string')
//=> "test.string"

headerCase

NPM version NPM downloads Build status Test coverage

Return as a title cased, dash separated string.

changeCase.headerCase('test string')
//=> "Test-String"

isLowerCase

NPM version NPM downloads Build status Test coverage

Return a boolean indicating whether the string is lower cased.

changeCase.isLowerCase('test string')
//=> true

isUpperCase

NPM version NPM downloads Build status Test coverage

Return a boolean indicating whether the string is upper cased.

changeCase.isUpperCase('test string')
//=> false

lowerCase

NPM version NPM downloads Build status Test coverage

Return the string in lower case.

changeCase.lowerCase('TEST STRING')
//=> "test string"

lowerCaseFirst

NPM version NPM downloads Build status Test coverage

Return the string with the first character lower cased.

changeCase.lowerCaseFirst('TEST')
//=> "tEST"

noCase

NPM version NPM downloads Build status Test coverage

Return the string without any casing (lower case, space separated).

changeCase.noCase('test string')
//=> "test string"

paramCase

NPM version NPM downloads Build status Test coverage

Return as a lower case, dash separated string.

changeCase.paramCase('test string')
//=> "test-string"

pascalCase

NPM version NPM downloads Build status Test coverage

Return as a string denoted in the same fashion as camelCase, but with the first letter also capitalized.

changeCase.pascalCase('test string')
//=> "TestString"

pathCase

NPM version NPM downloads Build status Test coverage

Return as a lower case, slash separated string.

changeCase.pathCase('test string')
//=> "test/string"

sentenceCase

NPM version NPM downloads Build status Test coverage

Return as a lower case, space separated string with the first letter upper case.

changeCase.sentenceCase('testString')
//=> "Test string"

snakeCase

NPM version NPM downloads Build status Test coverage

Return as a lower case, underscore separated string.

changeCase.snakeCase('test string')
//=> "test_string"

swapCase

NPM version NPM downloads Build status Test coverage

Return as a string with every character case reversed.

changeCase.swapCase('Test String')
//=> "tEST sTRING"

titleCase

NPM version NPM downloads Build status Test coverage

Return as a space separated string with the first character of every word upper cased.

changeCase.titleCase('a simple test')
//=> "A Simple Test"

upperCase

NPM version NPM downloads Build status Test coverage

Return the string in upper case.

changeCase.upperCase('test string')
//=> "TEST STRING"

upperCaseFirst

NPM version NPM downloads Build status Test coverage

Return the string with the first character upper cased.

changeCase.upperCaseFirst('test')
//=> "Test"

Related

TypeScript

Includes a TypeScript definition.

License

MIT