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

case-shift

v2.5.3

Published

Simple npm package for converting the case from one format to another.

Downloads

361,791

Readme

Case-Shift Simple npm package for converting the case from one format to another.

📦 Install with the help of npm or yarn

npm install case-shift
# or
yarn add case-shift

Case Conversion

The one case string converts the below to all the categories. Follow the further documentation.

camelCase

In this category, all the method converts the camelCase string to another category string. The camelCase method supports both lowerCamelCase(isAnString) and UpperCamelCase(IsAnString) strings for conversion.

const {
	camelToCapital,
	camelToConstant,
	camelToKebab,
	camelToPascal,
	camelToSnake
} = require("case-shift");
  • camelToCapital This method converts camelCase string to capital case.
console.log(camelToCapital("isAnString"));
// Is An String
  • camelToConstant This method converts camelCase string to constant case.
console.log(camelToConstant("isAnString"));
// IS_AN_STRING
  • camelToKebab This method converts camelCase string to kebab case. If the second argument is true, returns capital kebab case string, else small kebab case string. Defaults are true.
console.log(camelToKebab("isAnString"));
// Is-An-String
console.log(camelToKebab("isAnString", false));
// is-an-string
  • camelToPascal This method converts camelCase string to pascal case.
console.log(camelToPascal("isAnString"));
// IsAnString
  • camelToSnake This method converts camelCase string to snake case. If the second argument is true, returns capital snake case string, else small snake case string. Defaults are true.
console.log(camelToSnake("isAnString"));
// Is_An_String
console.log(camelToSnake("isAnString", false));
// is_an_string

Capital Case

In this category, all the method converts the Capital Case string to another category string.

const {
	capitalToCamel,
	capitalToConstant,
	capitalToKebab,
	capitalToPascal,
	capitalToSnake
} = require("case-shift");
  • capitalToCamel This method converts Capital Case string to camelCase case. If second optional argument is true return UpperCamelCase string, default false.
console.log(capitalToCamel("Is An String"));
// isAnString
console.log(capitalToCamel("Is An String", true));
// IsAnString
  • capitalToConstant This method converts Capital Case string to constant case.
console.log(capitalToConstant("Is An String"));
// IS_AN_STRING
  • capitalToKebab This method converts Capital Case string to kebab case. If the second argument is true, returns capital kebab case string, else small kebab case string. Defaults are true.
console.log(capitalToKebab("Is An String"));
// Is-An-String
console.log(capitalToKebab("Is An String", false));
// is-an-string
  • capitalToPascal This method converts Capital Case string to pascal case.
console.log(capitalToPascal("Is An String"));
// IsAnString
  • capitalToSnake This method converts Capital Case string to snake case. If the second argument is true, returns capital snake case string, else small snake case string. Defaults are true.
console.log(capitalToSnake("Is An String"));
// Is_An_String
console.log(capitalToSnake("Is An String", false));
// is_an_string

CONSTANT_CASE

In this category, all the method converts the CONSTANT_CASE string to another category string.

const {
	constantToCamel,
	constantToCapital,
	constantToKebab,
	constantToPascal,
	constantToSnake
} = require("case-shift");
  • constantToCamel This method converts CONSTANT_CASE string to camelCase case. If second optional argument is true return UpperCamelCase string, default false.
console.log(constantToCamel("IS_AN_STRING"));
// isAnString
console.log(constantToCamel("IS_AN_STRING", true));
// IsAnString
  • constantToCapital This method converts CONSTANT_CASE string to Capital Case string.
console.log(constantToCapital("IS_AN_STRING"));
// Is An String
  • constantToKebab This method converts CONSTANT_CASE string to kebab case. If the second argument is true, returns capital kebab case string, else small kebab case string. Defaults are true.
console.log(constantToKebab("IS_AN_STRING"));
// Is-An-String
console.log(constantToKebab("IS_AN_STRING", false));
// is-an-string
  • constantToPascal This method converts CONSTANT_CASE string to pascal case.
console.log(constantToPascal("IS_AN_STRING"));
// IsAnString
  • constantToSnake This method converts CONSTANT_CASE string to snake case. If the second argument is true, returns capital snake case string, else small snake case string. Defaults are true.
console.log(constantToSnake("IS_AN_STRING"));
// Is_An_String
console.log(constantToSnake("IS_AN_STRING", false));
// is_an_string

Kebab-Case

In this category, all the method converts the Kebab-Case string to another category string.

const {
	kebabToCamel,
	kebabToCapital,
	kebabToConstant,
	kebabToPascal,
	kebabToSnake
} = require("case-shift");
  • kebabToCamel This method converts Kebab-Case string to camelCase case. If second optional argument is true return UpperCamelCase string, default false.
console.log(kebabToCamel("Is-An-String"));
// isAnString
console.log(kebabToCamel("Is-An-String", true));
// IsAnString
  • kebabToCapital This method converts Kebab-Case string to Capital Case string.
console.log(kebabToCapital("Is-An-String"));
// Is An String
  • kebabToConstant This method converts Kebab-Case string to CONSTANT_CASE string.
console.log(kebabToConstant("Is-An-String"));
// IS_AN_STRING
  • kebabToPascal This method converts Kebab-Case string to pascal case.
console.log(kebabToPascal("Is-An-String"));
// IsAnString
  • kebabToSnake This method converts Kebab-Case string to snake_case. If the second argument is true, returns capital snake_case string, else small snake_case string. Defaults are true.
console.log(kebabToSnake("Is-An-String"));
// Is_An_String
console.log(kebabToSnake("Is-An-String", false));
// is_an_string

PascalCase

In this category, all the method converts the PascalCase string to another category string.

const {
	pascalToCamel,
	pascalToCapital,
	pascalToConstant,
	pascalToKebab,
	pascalToSnake
} = require("case-shift");
  • pascalToCamel This method converts PascalCase string to camelCase case. If second optional argument is true return UpperCamelCase string, default false.
console.log(pascalToCamel("IsAnString"));
// isAnString
console.log(pascalToCamel("IsAnString", true));
// IsAnString
  • pascalToCapital This method converts PascalCase string to Capital Case string.
console.log(pascalToCapital("IsAnString"));
// Is An String
  • pascalToConstant This method converts PascalCase string to CONSTANT_CASE string.
console.log(pascalToConstant("IsAnString"));
// IS_AN_STRING
  • pascalToKebab This method converts PascalCase string to kebab-case string. If the second argument is true, returns capital kebab case string, else small kebab case string. Defaults are true.
console.log(pascalToKebab("IsAnString"));
// Is-An-String
console.log(pascalToKebab("IsAnString", false));
// is-an-string
  • pascalToSnake This method converts PascalCase string to snake_case. If the second argument is true, returns capital snake_case string, else small snake_case string. Defaults are true.
console.log(pascalToSnake("IsAnString"));
// Is_An_String
console.log(pascalToSnake("IsAnString", false));
// is_an_string

Snake_Case

In this category, all the method converts the Snake_Case string to another category string.

const {
	snakeToCamel,
	snakeToCapital,
	snakeToConstant,
	snakeToPascal,
	snakeToKebab
} = require("case-shift");
  • snakeToCamel This method converts Snake_Case string to camelCase case. If second optional argument is true return UpperCamelCase string, default false.
console.log(snakeToCamel("is_an_string"));
// isAnString
console.log(snakeToCamel("is_an_string", true));
// IsAnString
  • snakeToCapital This method converts Snake_Case string to Capital Case string.
console.log(snakeToCapital("is_an_string"));
// Is An String
  • snakeToConstant This method converts Snake_Case string to CONSTANT_CASE string.
console.log(snakeToConstant("is_an_string"));
// IS_AN_STRING
  • snakeToPascal This method converts Snake_Case string to pascal case.
console.log(snakeToPascal("is_an_string"));
// IsAnString
  • snakeToKebab This method converts Snake_Case string to kebab-case. If the second argument is true, returns capital Kebab-Case string, else small kebab-case string. Defaults are true.
console.log(snakeToKebab("is_an_string"));
// Is-An-String
console.log(snakeToKebab("is_an_string", false));
// is-an-string