Skip to content

Convert string to target CaseType, like: camelCase, snakeCase, properCase, constantCase...

License

Notifications You must be signed in to change notification settings

rexerwang/case-modifier

Repository files navigation

case-modifier License Version

Convert string to target CaseType, like: camelCase, snakeCase, properCase, constantCase

Install

npm i case-modifier

Usage

import * as CaseModifier from 'case-modifier'

// type: camelCase
CaseModifier.CASE_CAMEL

CaseModifier.camelCase('we-will-rock-the-word') // weWillRockTheWord

// type: snakeCase
CaseModifier.CASE_SNAKE
CaseModifier.snakeCase('we-will-rock-the-word') // we_will_rock_the_word

// type: kebabCase
CaseModifier.CASE_KEBAB
CaseModifier.CASE_DASH
CaseModifier.kebabCase('WeWillRockTheWord') // we-will-rock-the-word

// type: properCase
CaseModifier.CASE_PROPER
CaseModifier.CASE_PASCAL
CaseModifier.properCase('we-will-rock-the-word') // WeWillRockTheWord

// type: constantCase
CaseModifier.CASE_CONSTANT
CaseModifier.constantCase('WeWillRockTheWord') // WE_WILL_ROCK_THE_WORD


// covert(str, caseType)
CaseModifier.convert('we-will-rock-the-word') // weWillRockTheWord
CaseModifier.convert('we-will-rock-the-word', CaseModifier.CASE_PROPER) // WeWillRockTheWord


// if not support, just return source string
CaseModifier.convert('We will rock the word') // We will rock the word

About

Convert string to target CaseType, like: camelCase, snakeCase, properCase, constantCase...

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published