Socket
Socket
Sign inDemoInstall

change-case

Package Overview
Dependencies
18
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    change-case

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


Version published
Maintainers
1
Install size
128 kB
Created

Package description

What is change-case?

The change-case package is a utility library that provides various functions to transform strings between different cases, such as camel case, snake case, kebab case, and more. It is useful for formatting strings in different coding conventions or textual formats.

What are change-case's main functionalities?

camelCase

Converts a string to camel case.

const { camelCase } = require('change-case');
console.log(camelCase('test string')); // 'testString'

snakeCase

Converts a string to snake case.

const { snakeCase } = require('change-case');
console.log(snakeCase('test string')); // 'test_string'

kebabCase

Converts a string to kebab case.

const { kebabCase } = require('change-case');
console.log(kebabCase('test string')); // 'test-string'

titleCase

Converts a string to title case.

const { titleCase } = require('change-case');
console.log(titleCase('test string')); // 'Test String'

constantCase

Converts a string to constant case.

const { constantCase } = require('change-case');
console.log(constantCase('test string')); // 'TEST_STRING'

Other packages similar to change-case

Readme

Source

Change Case

NPM version NPM downloads Build status Test coverage

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"

TypeScript

Includes a TypeScript definition.

License

MIT

Keywords

FAQs

Last updated on 14 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc