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/caseUsage
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 > MyStringcamelCase
Convert a string to pascalCase
example:
My string > myStringkebabCase
Convert a string to kebabCase
example:
My string > my-stringsnakeCase
Convert a string to snakeCase
example:
My string > my_stringupperSnakeCase
Convert a string to upperSnakeCase
example:
My string > MY_STRINGslugCase
Convert a string to slugCase aka kebabCase
example:
My string > my-stringconstCase
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_STRINGsentenceCase
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