Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

case-switcher-js

mburkard84MIT1.1.10TypeScript support: included

Library to change the casing convention of strings

string, string manipulation, case convention, camel case, dot case, kebab case, pascal case, snake case, title case

readme

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