case-switcher-js
TypeScript icon, indicating that this package has built-in type declarations

1.1.10 • Public • Published

Case Switcher

Change the casing of a string.

License: MIT npm version Code Coverage

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

Buy Me A Coffee

Package Sidebar

Install

npm i case-switcher-js

Weekly Downloads

7

Version

1.1.10

License

MIT

Unpacked Size

39.8 kB

Total Files

21

Last publish

Collaborators

  • mburkard