Skip to content

Utility functions to determine and convert the case of strings.

License

Notifications You must be signed in to change notification settings

Shresht7/case-convert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

case-convert

Utility functions to determine and convert the case of strings.

Usage

import { toCamelCase } from 'case-convert'

const result = toCamelCase('a-new-hope')    //  aNewHope

API Reference

Case

export enum Case {
    Camel = 'CAMEL',    //  camelCase
    Snake = 'SNAKE',    //  snake_case
    Kebab = 'KEBAB',    //  kebab-case
    Title = 'TITLE',    //  TitleCase
}

convert

Convert the string to the given case type

import { Case, convert } from 'case-convert'

const result = convert('a-new-hope', Case.Camel)    //  aNewHope

check

Check if the string is of the given case type

import { check, Case } from 'case-convert'

check('a-new-hope', Case.Camel)  //  false
check('a_new_hope', Case.Snake)  //  true

determineCase

Determine the case type of the string

import { determineCase } from 'case-convert'

const result = determineCase('ANewHope')    //  Case.Title = "TITLE"

capitalize and uncapitalize

Capitalize or uncapitalize a string

import { capitalize, uncapitalize } from 'case-convert'

capitalize('a new hope')    //  A new hope
uncapitalize('A New Hope')  //  a New Hope

toCamelCase, toSnakeCase, toKebabCase and toTitleCase

Convert the string to the given format

import { toCamelCase, toSnakeCase, toKebabCase, toTitleCase } from 'case-convert'

toCamelCase("some-string")  //  someString
toSnakeCase("someString")   //  some_string
toKebabCase("SomeString")   //  some-string
toTitleCase("some_string")  //  SomeString

📑 License

This project is licensed under the MIT License.

About

Utility functions to determine and convert the case of strings.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published