Change Case
Quickly convert strings between camelCase
, PascalCase
, Title Case
, snake_case
, lowercase
, UPPERCASE
, CONSTANT_CASE
and more.
Installation
npm install change-case --save
Usage
var changeCase = require('change-case');
isUpperCase changeCase.isUpper(string)
Return a boolean indicating the string is upper cased.
changeCase.isUpperCase('test string');
isLowerCase changeCase.isLower(string)
Return a boolean indicating the string is lower cased.
changeCase.isLowerCase('test string');
upperCase changeCase.upper(string)
Return an upper cased string.
changeCase.upperCase('test string');
upperCaseFirst changeCase.ucFirst(string)
Return a string with the first character upper cased.
changeCase.upperCaseFirst('test');
lowerCase changeCase.lower(string)
Return a lower cased string.
changeCase.lowerCase('TEST STRING');
titleCase changeCase.title(string)
Return a space separated string with the first character of every word upper cased.
changeCase.titleCase('a simple test');
sentenceCase changeCase.sentence(string)
Return a lower cased, space separated string.
changeCase.sentenceCase('testString');
camelCase changeCase.camel(string)
Return a string with the separators denoted by having the next letter capitalized.
changeCase.camelCase('test string');
pascalCase changeCase.pascal(string)
Return a string denoted in the same fashion as camelCase
, but with the first letter capitalized.
changeCase.pascalCase('test string');
snakeCase changeCase.snake(string)
Return a lower cased, space separated string.
changeCase.snakeCase('test string');
--> "test_string"
paramCase changeCase.param(string)
Return a lower cased, dash separated string.
changeCase.paramCase('test string');
dotCase changeCase.dot(string)
Return a lower cased, period separated string.
changeCase.dotCase('test string');
pathCase changeCase.path(string)
Return a lower cased, slash separated string.
changeCase.pathCase('test string');
constantCase changeCase.constant(string)
Return an upper cased, underscore separated string.
changeCase.constantCase('test string');
swapCase changeCase.swap(string)
Return a string with lower case characters upper cased and upper case character lower cased.
changeCase.swapCase('Test String');
License
MIT