Giter Club home page Giter Club logo

kase's Introduction

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. '@').

Install

yarn add kase or npm install kase

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.

kase.isUpper(str) / kase.isUpperCase(str) / isUpperCase(str)

Return true if all characters in str are uppercase, false otherwise.

kase.isLower(str) / kase.isLowerCase(str) / isLowerCase(str)

Return true if all characters in str are lowercase, false otherwise.

kase's People

Contributors

arccoza avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.