0.1.1 • Published 5 years ago

case-modifier v0.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

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