playwords
v1.0.0
Published
Lightweight TypeScript string utility functions — slugify, capitalize, truncate, camelCase and more.
Maintainers
Readme
playwords
Lightweight, zero-dependency TypeScript string utilities. Fully typed.
Install
npm install playwordsUsage
import { capitalize, slugify, truncate, toCamelCase, toTitleCase, countWords, reverse, isPalindrome } from "playwords";
capitalize("hello world") // → "Hello world"
slugify("Hello World!") // → "hello-world"
truncate("Hello World", 7) // → "Hell..."
toCamelCase("hello world") // → "helloWorld"
toTitleCase("hello world") // → "Hello World"
countWords("hello world") // → 2
reverse("hello") // → "olleh"
isPalindrome("racecar") // → trueAPI
| Function | Signature | Description |
|---|---|---|
| capitalize | (str: string) => string | Uppercases the first letter |
| slugify | (str: string) => string | URL-friendly slug |
| truncate | (str: string, max: number, suffix?: string) => string | Cuts string to max length |
| toCamelCase | (str: string) => string | Converts to camelCase |
| toTitleCase | (str: string) => string | Converts to Title Case |
| countWords | (str: string) => number | Counts words |
| reverse | (str: string) => string | Reverses the string |
| isPalindrome | (str: string) => boolean | Checks if palindrome |
License
MIT
