caseflip
v1.0.7
Published
A robust, lightweight string case transformation library with support for Sentence case, Capitalize case, and more.
Maintainers
Readme
✨ caseflip
A robust, lightweight, and modern string case transformation library with first-class TypeScript support.
caseflip is a refined string processing utility designed for developers who demand both simplicity and robustness. It handles complex punctuation and whitespace with ease.
🚀 Features
- 🎯 Sentence Case: Perfectly capitalizes sentences, recognizing
.,!, and?. - 🔡 Lowercase: Ultra-lean wrapper for consistent lowercasing.
- 🔠 Uppercase: Ultra-lean wrapper for consistent uppercasing.
- ✨ Capitalize Case: Formats text into clean Title Case, ignoring extra whitespace.
- 🎢 Alternating Case: Generates
aLtErNaTiNgtext for creative UIs. - 📘 TypeScript Ready: Built-in
.d.tsdefinitions for full type safety. - ⚡ Zero Dependencies: Exceptionally small bundle size.
- 📦 Dual Module Support: Works seamlessly in ESM and CJS environments.
📦 Installation
npm install caseflip🛠️ Usage
ES Modules (ESM)
import {
toSentenceCase,
toCapitalizeCase,
toAlternatingCase,
toLowerCase,
toUpperCase,
} from "caseflip";
// 📝 Sentence Case (Handles multiple sentences)
toSentenceCase("hello world! how are you?");
// Result: "Hello world! How are you?"
// ✨ Capitalize Case (Cleans extra spaces)
toCapitalizeCase("string with spaces");
// Result: "String With Spaces"
// 🎢 Alternating Case
toAlternatingCase("vibe check");
// Result: "vIbE ChEcK"
// 🔡 Lowercase
toLowerCase("HELLO WORLD"); //built-in string methods in JavaScript
// Result: "hello world"
// 🔠 Uppercase
toUpperCase("hello world"); //built-in string methods in JavaScript
// Result: "HELLO WORLD"TypeScript Support
caseflip comes bundled with type definitions:
import { toSentenceCase } from "caseflip";
const result: string = toSentenceCase("hello world.");