JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 113
  • Score
    100M100P100Q74692F
  • License MIT

Convert cases

Package Exports

  • @sil/case
  • @sil/case/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sil/case) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Case

Installation

npm install @sil/case

Usage

import { kebabCase } from "@sil/case";

const myString = "This Is My STRING";

const myStringKebabCase = kebabCase(myString); // result: this-is-my-string

Functions

PascalCase

Convert a string to pascalCase

example:

My String > MyString

camelCase

Convert a string to pascalCase

example:

My string > myString

kebabCase

Convert a string to kebabCase

example:

My string > my-string

snakeCase

Convert a string to snakeCase

example:

My string > my_string

upperSnakeCase

Convert a string to upperSnakeCase

example:

My string > MY_STRING

slugCase

Convert a string to slugCase aka kebabCase

example:

My string > my-string

constCase

Constants usually use an upperSnakeCase, but don't allow the string to start with a number. constCase does exactly that. It adds an _ at the beginning of a string whenever it starts with a number.

example:

My string > MY_STRING
1 String > _1_STRING

sentenceCase

Converts any string to a sentence case, which means just lowercase letters and spaces. Starting with a capital letter. This function is helpful to make const variables etc look nice in headers.

example:

MY_STRING > My string
my-string > My string