string-case-kit
v1.0.3
Published
A lightweight, zero‑dependency TypeScript utility for professional string manipulation. Whether you're building a CLI, a web app, or an API, **String Case Kit** handles every case transformation with a clean, chainable API.
Readme
String Case Kit
A lightweight, zero‑dependency TypeScript utility for professional string manipulation. Whether you're building a CLI, a web app, or an API, String Case Kit handles every case transformation with a clean, chainable API.
Features
- Zero Dependencies – Pure TypeScript/JavaScript
- Type Safe – Fully typed interfaces for the best DX
- Smart Detection – Automatically detects the case of your input string
- NPM Ready – Tree‑shakeable and lightweight
- Chainable Logic – Simple functional approach to string transformations
Installation
npm install string-case-kitQuick Start ⚡
import { converter } from "string-case-kit";
const myStr = converter("hello_world_api");
console.log(myStr.toCamelCase());
// helloWorldApi
console.log(myStr.toPascalCase());
// HelloWorldApi
console.log(myStr.toKebabCase());
// hello-world-apiAPI Reference 📖
Case Conversions
toCamelCase() → helloWorldApi
toPascalCase() → HelloWorldApi
toSnakeCase() → hello_world_api
toScreamingSnakeCase() → HELLO_WORLD_API
toKebabCase() → hello-world-api
toDotCase() → hello.world.api
toPathCase() → hello/world/api
Formatting
toTitleCase() → Hello World Api
toSentenceCase() → Hello world api
toUpperCase() → HELLO WORLD API
toLowerCase() → hello world api
Utilities
toggleCase() → flips upper/lower case for each character
reverse() → reverses the string
all() → returns all case formats at once
detect() → detects the case type (camelCase, snakeCase, etc.)
is.camelCase() → boolean check for camelCase
custom(separator?: string) → custom separator join
slug() → URL‑friendly slug
words() → array of words
count() → { words, chars }
Example Usage 🔧
const str = converter("MyAwesomeAPI");
console.log(str.detect());
// pascalCase
console.log(str.is.camelCase());
// false
console.log(str.all());
/*
{
camelCase: "myAwesomeApi",
pascalCase: "MyAwesomeApi",
snakeCase: "my_awesome_api",
screamingSnakeCase: "MY_AWESOME_API",
kebabCase: "my-awesome-api",
dotCase: "my.awesome.api",
pathCase: "my/awesome/api",
titleCase: "My Awesome Api",
sentenceCase: "My awesome api",
upperCase: "MY AWESOME API",
lowerCase: "my awesome api"
}
*/