Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
change-case-all
Advanced tools
All change-case methods bundled in a single module
Weekly downloads
Package description
The change-case-all npm package is a utility library that provides a comprehensive set of functions for transforming the case of strings. It includes functionalities for converting strings to camel case, capital case, constant case, dot case, header case, no case, param case, pascal case, path case, sentence case, snake case, and swap case. This makes it a versatile tool for formatting strings in various coding and writing styles.
Camel Case
Converts a string to camel case, which is a common case style in programming where the first letter of each word is capitalized except for the first word.
"use strict"; const { camelCase } = require('change-case-all'); console.log(camelCase('test string')); // 'testString'
Constant Case
Transforms a string to constant case, typically used for defining constants in programming, where all letters are uppercase and spaces are replaced by underscores.
"use strict"; const { constantCase } = require('change-case-all'); console.log(constantCase('test string')); // 'TEST_STRING'
Pascal Case
Converts a string to pascal case, similar to camel case but with the first letter of the first word also capitalized. Commonly used for class names in programming.
"use strict"; const { pascalCase } = require('change-case-all'); console.log(pascalCase('test string')); // 'TestString'
Snake Case
Transforms a string to snake case, where all letters are lowercase and spaces are replaced by underscores. Widely used in programming, especially in variable naming.
"use strict"; const { snakeCase } = require('change-case-all'); console.log(snakeCase('test string')); // 'test_string'
Lodash is a comprehensive utility library that, among its wide range of functions, includes methods for changing the case of strings (e.g., _.camelCase, _.snakeCase). While lodash offers similar string case conversion functionalities, it is a much larger library aimed at providing a broad spectrum of utility functions beyond string case conversion.
The 'case' package is another npm library focused on string case conversion. It supports various case transformations similar to change-case-all. However, change-case-all provides a more extensive set of case conversion utilities, making it a more versatile choice for projects that require diverse string manipulation capabilities.
Readme
Change case functions for all cases in TypeScript and JavaScript.
Combined version of all change-case
methods, so you do not need to install them separately.
ESM and CJS bundles are included, also backwards compatible with change-case@4.1.0.
change-case-all@2.0.0
introduces a Case
helper class, which can be used to access all methods.
npm install --save change-case-all
import { Case } from 'change-case-all';
const camel = Case.camel('test string'); // testString
const upper = Case.upper('test string'); // TEST STRING
import { camelCase, upperCase, ... } from 'change-case-all';
const camel = camelCase('test string'); // testString
const upper = upperCase('test string'); // TEST STRING
const { Case } = require('change-case-all');
const camel = Case.camel('foo-bar'); // fooBar
const snake = Case.snake('fooBar'); // foo_bar
const { camelCase, snakeCase } = require('change-case-all');
const camel = camelCase('foo-bar'); // fooBar
const snake = snakeCase('fooBar'); // foo_bar
change-case@5.2.0
Case
helper class: e.g. Case.camel('test string'); // testString
TitleCase@4.1.0
failing in tests, thus kept at 3.0.3
import { Case } from 'change-case-all';
const str = 'test string';
camel = Case.camel(str); // testString
capital = Case.capital(str); // Test String
constant = Case.constant(str); // TEST_STRING
dot = Case.dot(str); // test.string
no = Case.no(str); // test string
pascal = Case.pascal(str); // TestString
path = Case.path(str); // test/string
sentence = Case.sentence(str); // Test string
snake = Case.snake(str); // test_string
train = Case.train(str); // Test-String
kebap = Case.kebap(str); // test-string
sponge = Case.sponge(str); // TeSt StRiNg
swapCase = Case.swap(str); // TEST STRING
title = Case.title(str); // Test String
uppper = Case.upper(str); // TEST STRING
localeUpper = Case.localeUpper(str, 'en'); // TEST STRING
lower = Case.lower(str); // test string
localeLower = Case.localeLower(str, 'en'); // test string
lowerFirst = Case.lowerFirst(str); // test string
upperFirst = Case.upperFirst(str); // Test string
isUpper = Case.isUpper(str); // false
isLower = Case.isLower(str); // true
import { camelCase, upperCase, ... } from 'change-case-all';
const str = 'test string';
camel = camelCase(str); // testString
capital = capitalCase(str); // Test String
constant = constantCase(str); // TEST_STRING
dot = dotCase(str); // test.string
no = noCase(str); // test string
pascal = pascalCase(str); // TestString
path = pathCase(str); // test/string
sentence = sentenceCase(str); // Test string
snake = snakeCase(str); // test_string
train = trainCase(str); // Test-String
kebap = kebapCase(str); // test-string
sponge = spongeCase(str); // TeSt StRiNg
swapCase = swapCase(str); // TEST STRING
title = titleCase(str); // Test String
uppper = upperCase(str); // TEST STRING
localeUpper = localeUpperCase(str, 'en'); // TEST STRING
lower = lowerCase(str); // test string
localeLower = localeLowerCase(str, 'en'); // test string
lowerFirst = lowerCaseFirst(str); // test string
upperFirst = upperCaseFirst(str); // Test string
isUpper = isUpperCase(str); // false
isLower = isLowerCase(str); // true
FAQs
All change-case methods bundled in a single module
The npm package change-case-all receives a total of 4,245,529 weekly downloads. As such, change-case-all popularity was classified as popular.
We found that change-case-all demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.