@binarydreams88/string-utils
v4.4.0
Published
A collection of useful string manipulation utilities
Maintainers
Readme
@binarydreams88/string-utils
A collection of useful string manipulation utilities for JavaScript/TypeScript projects.
Installation
npm install @binarydreams88/string-utilsUsage
import {
truncate,
toTitleCase,
removeWhitespace,
toKebabCase,
isValidEmail,
generateRandomString
} from '@binarydreams88/string-utils';
// Truncate a string
truncate('Hello World', 5); // Returns: 'Hello...'
// Convert to title case
toTitleCase('hello world'); // Returns: 'Hello World'
// Remove whitespace
removeWhitespace('hello world'); // Returns: 'helloworld'
// Convert to kebab case
toKebabCase('helloWorld'); // Returns: 'hello-world'
// Validate email
isValidEmail('[email protected]'); // Returns: true
// Generate random string
generateRandomString(10); // Returns: random 10-character stringAPI
truncate(str: string, length: number): string
Truncates a string to a specified length and adds an ellipsis if truncated.
toTitleCase(str: string): string
Converts a string to title case (e.g., "hello world" → "Hello World").
removeWhitespace(str: string): string
Removes all whitespace from a string.
toKebabCase(str: string): string
Converts a string to kebab case (e.g., "helloWorld" → "hello-world").
isValidEmail(email: string): boolean
Checks if a string is a valid email address.
generateRandomString(length: number): string
Generates a random string of specified length.
License
MIT
