change-case
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
camel-case | 4.1.2 | 4.01 kB | MIT | prod | |
capital-case | 1.0.4 | 3.7 kB | MIT | prod | |
constant-case | 3.0.4 | 3.65 kB | MIT | prod | |
dot-case | 3.0.4 | 3.54 kB | MIT | prod | |
header-case | 2.0.4 | 3.52 kB | MIT | prod | |
no-case | 3.0.4 | 5.6 kB | MIT | prod | |
param-case | 3.0.4 | 3.51 kB | MIT | prod | |
pascal-case | 3.1.2 | 4.09 kB | MIT | prod | |
path-case | 3.0.4 | 3.5 kB | MIT | prod | |
sentence-case | 3.0.4 | 3.79 kB | MIT | prod | |
snake-case | 3.0.4 | 3.53 kB | MIT | prod | |
tslib | 2.6.2 | 15.59 kB | 0BSD | prod |
Change-case is a highly useful JavaScript library that allows developers to seamlessly convert a string between different case formats like camelCase
, PascalCase
, Capital Case
, snake_case
, kebab-case
, CONSTANT_CASE
, and several others. This npm package augments the development process by enabling easier and faster manipulation of textual data.
To utilize change-case, start by installing the library into your project using npm. The installation command is as follows:
npm install change-case --save
Following the successful installation, you can implement the change-case functions in your JavaScript code. Here's an illustration of its usage:
const changeCase = require('change-case');
let str = "Hello World";
let camelCased = changeCase.camelCase(str); //Outputs: helloWorld
let pascalCased = changeCase.pascalCase(str); //Outputs: HelloWorld
let snakeCased = changeCase.snakeCase(str); //Outputs: hello_world
let kebabCased = changeCase.kebabCase(str); //Outputs: hello-world
let dotCased = changeCase.dotCase(str); //Outputs: hello.world
Also, change-case exports a split
function that can be used to build your own case formatting methods. For instance:
let strSplit = changeCase.split("fooBar")
.map((x) => x.toLowerCase())
.join("_"); //Outputs: "foo_bar"
Furthermore, change-case provides a feature for transforming the keys of an object to any case:
import * as changeKeys from "change-case/keys";
let newObj = changeKeys.camelCase({ TEST_KEY: true }); //Outputs: { testKey: true }
The detailed documentation and usage instructions for change-case can be found on its GitHub page: https://github.com/blakeembrey/change-case. Additionally, you can also explore the API references, options, and functions offered by the library on this page. These resources provide a comprehensive guide, helping you get the most out of the change-case library.