1.1.10 • Published 1 year ago

case-switcher-js v1.1.10

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

This library provides functions to change the casing convention of a string.

Supported cases:

  • camelCase
  • dot.case
  • kebab-case
  • PascalCase
  • path/case
  • snake_case
  • Title Case
  • UPPER.DOT.CASE
  • UPPER-KEBAB-CASE
  • UPPER_SNAKE_CASE

Install

npm i case-switcher-js
yarn add case-switcher-js

Demo

import {
  toCamel,
  toDot,
  toKebab,
  toPascal,
  toPath,
  toSnake,
  toTitle,
  toUpperDot,
  toUpperKebab,
  toUpperSnake,
} from "case-switcher-js"

let sample = "avocado bagel-coffeeDONUTEclair_food.gravy"

toCamel(sample)  // -> "avocadoBagelCoffeeDONUTEclairFoodGravy"
toDot(sample)  // -> "avocado.bagel.coffee.donut.eclair.food.gravy"
toKebab(sample)  // -> "avocado-bagel-coffee-donut-eclair-food-gravy"
toPascal(sample)  // -> "AvocadoBagelCoffeeDONUTEclairFoodGravy"
toPath(sample)  // -> "avocado/bagel/coffee/donut/eclair/food/gravy"
toSnake(sample)  // -> "avocado_bagel_coffee_donut_eclair_food_gravy"
toTitle(sample)  // -> "Avocado Bagel Coffee DONUT Eclair Food Gravy"
toUpperDot(sample)  // -> "AVOCADO.BAGEL.COFFEE.DONUT.ECLAIR.FOOD.GRAVY"
toUpperKebab(sample)  // -> "AVOCADO-BAGEL-COFFEE-DONUT-ECLAIR-FOOD-GRAVY"
toUpperSnake(sample)  // -> "AVOCADO_BAGEL_COFFEE_DONUT_ECLAIR_FOOD_GRAVY"

Support The Developer