那些npm包之change-case

change-case包的主要作用是将字符串在骆驼式格式(camelCase),帕斯卡格式(PascalCase)首字母格式(Title Case),蛇底式格式(snake_case),小写格式(lowercase),大写格式(UPPERCASE),常量格式(CONSTANT_CASE)之间转换。

安装:

npm install change-case --save

使用:

var changeCase=require('change-case');
changeCase.camelCase('test string') //=> "testString"
changeCase.constantCase('test string') //=> "TEST_STRING"
changeCase.dotCase('test string') //=> "test.string"
changeCase.headerCase('test string') //=> "Test-String"
changeCase.isLowerCase('test string') //=> true
changeCase.isUpperCase('test string') //=> false
changeCase.lowerCase('TEST STRING') //=> "test string"
changeCase.lowerCaseFirst('TEST') //=> "tEST"
changeCase.noCase('test string') //=> "test string"
changeCase.paramCase('test string') //=> "test-string"
changeCase.pascalCase('test string') //=> "TestString"
changeCase.pathCase('test string') //=> "test/string"
changeCase.sentenceCase('testString') //=> "Test string"
changeCase.snakeCase('test string') //=> "test_string"
changeCase.swapCase('Test String') //=> "tEST sTRING"
changeCase.titleCase('a simple test') //=> "A Simple Test"
changeCase.upperCase('test string') //=> "TEST STRING"
changeCase.upperCaseFirst('test') //=> "Test"

你可能感兴趣的:(那些npm包之change-case)