String Utilities
These are a collection of simple string manipulation utilities commonly used when working with data from the CEM.
Installation
npm install -D @wc-toolkit/cem-utilities
Remove Quotes
The removeQuotes
function removes quotes from a string.
import { removeQuotes } from '@wc-toolkit/cem-utilities';
const noQuotes = removeQuotes(`"my-component"`); // my-componentconst noQuotes = removeQuotes(`'my-component'`); // my-component
Kebab Case
The kebabCase
function converts a string to kebab-case.
import { toKebabCase } from '@wc-toolkit/cem-utilities';
const kebab = toKebabCase('myComponent'); // my-component
Sentence Case
The toSentenceCase
function converts a string to sentence case.
import { toSentenceCase } from '@wc-toolkit/cem-utilities';
const sentence = toSentenceCase('myComponent'); // My component
Pascal Case
The toPascalCase
function converts a string to PascalCase.
import { toPascalCase } from '@wc-toolkit/cem-utilities';
const pascal = toPascalCase('my-component'); // MyComponent
Camel Case
The toCamelCase
function converts a string to camelCase.
import { toCamelCase } from '@wc-toolkit/cem-utilities';
const camel = toCamelCase('my-component'); // myComponent