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
lodash
Lodash is a comprehensive utility library that includes methods for string case transformation, such as _.camelCase, _.snakeCase, and _.kebabCase. It offers a wider range of utilities beyond string case conversion, making it more versatile but also larger in size compared to change-case.
case
The 'case' package is another string case conversion library that supports various case transformations. It is similar to change-case but has a different API and may have different case conversion implementations.
string-case
String-case is a library that provides case conversion functions similar to change-case. It may offer a different set of features or API design, which could be preferred by some developers over change-case.
Change Case
Quickly convert strings between camelCase, PascalCase, Title Case, snake_case, lowercase, UPPERCASE, CONSTANT_CASE, etc.
Installation
npm install change-case --save
API
var changeCase = require('change-case');
- changeCase.upperCase(string)
- changeCase.lowerCase(string)
- changeCase.titleCase(string [, ignoreInsignificantWords])
- changeCase.camelCase(string)
- changeCase.snakeCase(string)
- changeCase.paramCase(string)
- changeCase.dotCase(string)
- changeCase.pathCase(string)
- changeCase.constantCase(string)
- changeCase.switchCase(string)
changeCase.upperCase('test string')
changeCase.lowerCase('TEST STRING')
changeCase.titleCase('test string')
changeCase.titleCase('this is a test string', true)
changeCase.camelCase('test string')
changeCase.snakeCase('test string')
changeCase.paramCase('test string')
changeCase.dotCase('test string')
changeCase.pathCase('test string')
changeCase.constantCase('test string')
changeCase.switchCase('TeST stRInG')
License
MIT