Small utility to convert between camel-case, snake-case, kebab-case and more.
kase is a simple function for converting between common cases used in code.
Supporting:
or any custom seperator string you choose (eg. ‘@’).
yarn add kase
or npm install kase
var {kase} = require('kase')
// import {kase} from 'kase' // If you're using es modules.
var str = 'testCase'
str = kase(str, 'camel', 'kebab')
console.log(str)
// or
str = 'testCase'
str = kase(str, 'snake')
console.log(str)
// or custom seperator
str = 'testCase'
str = kase(str, '@')
console.log(str)
'test-case'
'test_case'
'test@case'
Convert str
from from
case style to to
case style, return the modified str
.
str
- the string to convert.from
- the case to convert from, will only match seperators in this specific style, can be:to
- the case to convert to, can be:'@'
.Convert str
to to
case style, from
is automatically set to any
, return the modified str
.
Return true
if all characters in str
are uppercase, false
otherwise.
Return true
if all characters in str
are lowercase, false
otherwise.