@sil/case
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @sil/case

Weekly Downloads

102

Version

0.3.1

License

MIT

Unpacked Size

47.5 kB

Total Files

25

Last publish

Collaborators

  • hacobvandipyan
  • silvandiepen