Case conversion, slugify, word/char counting, reverse, and more text utilities.
import { text } from 'toolmetry';| Function | Parameters | Returns | Description |
|---|---|---|---|
toCamelCase | input: string | string | Convert to camelCase |
toPascalCase | input: string | string | Convert to PascalCase |
toSnakeCase | input: string | string | Convert to snake_case |
toKebabCase | input: string | string | Convert to kebab-case |
toConstantCase | input: string | string | Convert to CONSTANT_CASE |
slugify | input: string | string | Generate a URL-safe slug |
wordCount | input: string | number | Count words in a string |
charCount | input: string, includeSpaces?: boolean | number | Count characters |
reverse | input: string | string | Reverse a string |
truncate | input: string, maxLength: number, suffix?: string | string | Truncate with ellipsis |
removeExtraWhitespace | input: string | string | Collapse multiple spaces |
removeLineBreaks | input: string | string | Remove all line breaks |
escapeRegex | input: string | string | Escape for use in regex |
import { toCamelCase, toPascalCase, toSnakeCase, toKebabCase, toConstantCase } from 'toolmetry';
toCamelCase('hello world example'); // "helloWorldExample"
toPascalCase('hello world example'); // "HelloWorldExample"
toSnakeCase('helloWorldExample'); // "hello_world_example"
toKebabCase('helloWorldExample'); // "hello-world-example"
toConstantCase('hello world'); // "HELLO_WORLD"import { slugify } from 'toolmetry';
slugify('My Blog Post Title!');
// "my-blog-post-title"import { wordCount, charCount, truncate } from 'toolmetry';
wordCount('Hello world example'); // 3
charCount('Hello'); // 5
truncate('A very long string here', 10); // "A ver..."