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
Transform a string between camelCase
, PascalCase
, Capital Case
, snake_case
, param-case
, CONSTANT_CASE
and others.
Installation
npm install change-case --save
Usage
import {
camelCase,
capitalCase,
constantCase,
dotCase,
headerCase,
noCase,
paramCase,
pascalCase,
pathCase,
sentenceCase,
snakeCase
} from "change-case";
Methods can also be installed independently. All functions also accept options
as the second argument.
License
MIT