Git Product home page Git Product logo

casex's Introduction

casex

All in one function for transforming word casings

npm version Build Status code style: prettier Maintainability Test Coverage

Install

๐Ÿ“ฆ 275B gziped

npm install --save casex

or https://unpkg.com/casex

Usage

import casex from 'casex';

casex(text, pattern);

How the pattern works

For casex any character that is not a letter (accents are not letters for javascript) is a breakpoint.

In this example: Ca_se

  • C: first letter of the first word
  • a: second and subsequent letters of the first word
  • _: anything between the first two and last two letters is glue and will be repeted between words
  • s: first letter of the second and subsequent words
  • e: second and subsequent letters of the second and subsequent words

Confusing? Check out the demo and/or examples below. I'm sure you'll get the hang of it :)

Note: You could use any other letters to describe, such as aa$aa or na_me. What matters is that it takes the first two and last two letters for checking capitalization and whatever is in the middle is "glue".

Examples

For these examples I'll use the text i_am the-real JohnDoe

lowercase

  • Pattern: case
  • Output: iamtherealjohndoe

UPPERCASE

  • Pattern: CASE
  • Output: IAMTHEREALJOHNDOE

snake_case

  • Pattern: ca_se
  • Output: i_am_the_real_john_doe

spinal-case

  • Pattern: ca-se
  • Output: i-am-the-real-john-doe

camelCase

  • Pattern: caSe
  • Output: iAmTheRealJohnDoe

UpperCamelCase

  • Pattern: CaSe
  • Output: IAmTheRealJohnDoe

Sentence case

  • Pattern: Ca se
  • Output: I am the real john doe

Title Case

  • Pattern: Ca Se
  • Output: I Am The Real John Doe

Motivation

casex is part of a scaffolding tool I'm building and I decided to publish it separetely. The scaffolding tool will be linked here once it's out :)

Resources

casex's People

Contributors

pedsmoreira avatar

Watchers

James Cloos avatar Prashant Sharma 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.