string-utility-toolkit
v1.0.1
Published
A collection of useful string manipulation utilities
Downloads
9
Maintainers
Readme
String Toolkit
A collection of useful string manipulation utilities for JavaScript projects.
Installation
npm install string-toolkitUsage
const strUtils = require("string-toolkit");
// Case utilities
strUtils.toKebabCase("Hello World"); // 'hello-world'
strUtils.toSnakeCase("Hello World"); // 'hello_world'
strUtils.toCamelCase("Hello World"); // 'helloWorld'
strUtils.toPascalCase("hello world"); // 'HelloWorld'
// Format utilities
strUtils.truncate("This is a long sentence", 10); // 'This is...'
strUtils.capitalize("hello world"); // 'Hello World'
strUtils.reverse("hello"); // 'olleh'
strUtils.formatNumber(1000000); // '1,000,000'
// Validation utilities
strUtils.isValidEmail("[email protected]"); // true
strUtils.isValidUrl("https://example.com"); // true
strUtils.isAlphanumeric("abc123"); // true
strUtils.isValidHexColor("#FFFFFF"); // trueAPI Reference
Case Utilities
- toKebabCase(str) - Converts string to kebab-case
- toSnakeCase(str) - Converts string to snake_case
- toCamelCase(str) - Converts string to camelCase
- toPascalCase(str) - Converts string to PascalCase
Format Utilities
- truncate(str, maxLength) - Truncates string to specified length with ellipsis
- capitalize(str) - Capitalizes first letter of each word
- reverse(str) - Reverses a string
- formatNumber(num, separator) - Formats number with thousand separators
Validation Utilities
- isValidEmail(email) - Checks if string is valid email
- isValidUrl(url) - Checks if string is valid URL
- isAlphanumeric(str) - Checks if string contains only alphanumeric characters
- isValidHexColor(color) - Checks if string is valid hex color code
License
MIT
