capstring is a lightweight JavaScript library for text capitalization and transformation. Zero dependencies, 24+ styles.
import capstring from 'capstring';
capstring('hello world', 'title'); // 'Hello World'
capstring('hello world', 'camel'); // 'helloWorld'
capstring('hello world', 'kebab'); // 'hello-world'
capstring('hello world', 'constant'); // 'HELLO_WORLD'capstring(str, style)str- String to transformstyle- Style name (default: 'same')- Returns: Transformed string, or
falseif input invalid
import { getStyles, isValidStyle, STYLES } from 'capstring';
getStyles(); // ['same', 'none', 'proper', ...]
isValidStyle('kebab'); // true
STYLES; // Frozen array of all style names| Category | Styles |
|---|---|
| Case | same, none, proper, title, sentence, upper, lower, swap |
| Code | camel, pascal, snake, kebab, slug, constant, python, dot, path |
| Fun | leet, reverse, sponge, mock, alternate, crazy, random |
npm test # Run tests
npm run lint # Run linter
npm run test:coverage # Coverage report- cAPIta - REST API for capstring (https://github.com/brianfunk/cAPIta)