1.0.3 • Published 2 years ago
typed-case v1.0.3
If I should maintain this repo, please ⭐️
DM me on Twitter if you have questions or suggestions.
About
A zero-dependency package for converting between string casings in a type-safe way.
Supported Casings
| Name |
|---|
| camelCase |
| PascalCase |
| kebab-case |
| snake_case |
| Train-Case |
| CONSTANT_CASE |
| Title Case |
| UPPER CASE |
| lower case |
Installation
yarn add typed-casenpm install typed-casepnpm add typed-caseContents
Usage
CamelCase
import { toCamelCase, CamelCase } from "typed-case";
toCamelCase("hello world"); // "helloWorld"
toCamelCase("hello_world"); // "helloWorld"
toCamelCase("hello-world"); // "helloWorld"Preserve UpperCase
toCamelCase("hello WORLD"); // "helloWORLD"
toCamelCase("hello WORLD", { preserveUpperCase: false }); // "helloWorld"PascalCase
import { toPascalCase, PascalCase } from "typed-case";
toPascalCase("hello world"); // "HelloWorld"
toPascalCase("hello_world"); // "HelloWorld"
toPascalCase("hello-world"); // "HelloWorld"Preserve UpperCase
toPascalCase("hello WORLD"); // "HelloWORLD"
toPascalCase("hello WORLD", { preserveUpperCase: false }); // "HelloWorld"TrainCase
import { toTrainCase, TrainCase } from "typed-case";
toTrainCase("hello world"); // "Hello-World"
toTrainCase("hello_world"); // "Hello-World"
toTrainCase("hello-world"); // "Hello-World"TitleCase
import { toTitleCase, TitleCase } from "typed-case";
toTitleCase("hello world"); // "Hello World"
toTitleCase("hello_world"); // "Hello World"
toTitleCase("hello-world"); // "Hello World"Preserve UpperCase
toTrainCase("hello WORLD"); // "Hello-WORLD"
toTrainCase("hello WORLD", { preserveUpperCase: false }); // "Hello-World"KebabCase
import { toKebabCase, KebabCase } from "typed-case";
toKebabCase("hello world"); // "hello-world"
toKebabCase("hello_world"); // "hello-world"
toKebabCase("hello-world"); // "hello-world"SnakeCase
import { toSnakeCase, SnakeCase } from "typed-case";
toSnakeCase("hello world"); // "hello_world"
toSnakeCase("hello_world"); // "hello_world"
toSnakeCase("hello-world"); // "hello_world"ConstantCase
import { toConstantCase, ConstantCase } from "typed-case";
toConstantCase("hello world"); // "HELLO_WORLD"
toConstantCase("hello_world"); // "HELLO_WORLD"
toConstantCase("hello-world"); // "HELLO_WORLD"UpperCase, LowerCase
import { toUpperCase, toLowerCase, UpperCase, LowerCase } from "typed-case";
toUpperCase("hello world"); // "HELLO WORLD"
toLowerCase("HELLO WORLD"); // "hello world"Capitalize, Uncapitalize
import { capitalize, uncapitalize } from "typed-case";
capitalize("hello world"); // "Hello world"
uncapitalize("Hello world"); // "hello world"