Socket
Book a DemoInstallSign in
Socket

kase

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kase

Small utility to convert between camel-case, snake-case, kebab-case and more.

0.10.0
latest
Source
npmnpm
Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
Source

kase Travis Build Status

kase is a simple function for converting between common cases used in code.

Supporting:

  • camelCase
  • kebab-case
  • snake_case
  • dot.case
  • space case
  • path/case
  • Title Case
  • PascalCase
  • Header-Case

or any custom seperator string you choose (eg. '@').

Example

Input

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)

Output

'test-case'
'test_case'
'test@case'

API

kase(str, from, to)

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:
    • any - for any non-word or camel style seperator, a good general match, only use the others if you want to specifically match that style.
    • camel - for camelCase.
    • kebab - for kebab-case.
    • snake - for snake_case.
    • dot - for dot.case.
    • space - for space case.
    • path - for path/case.
    • title - for Title Case.
    • pascal - for PascalCase.
    • header - for Header-Case.
  • to - the case to convert to, can be:
    • camel - for camelCase.
    • kebab - for kebab-case.
    • snake - for snake_case.
    • dot - for dot.case.
    • space - for space case.
    • path - for path/case.
    • title - for Title Case.
    • pascal - for PascalCase.
    • header - for Header-Case.
    • or any custom seperator string you'd like, eg. '@'.

kase(str, to)

Convert str to to case style, from is automatically set to any, return the modified str.

Keywords

camel

FAQs

Package last updated on 12 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.