@ts-utilkit/string
v0.2.0
Published
String manipulation utilities for formatting, transformation, and text processing
Maintainers
Readme
@ts-utilkit/string
string Functions - TypeScript utility functions for string operations.
Installation
npm install @ts-utilkit/stringFeatures
- 🚀 TypeScript-first with complete type definitions
- ✅ Comprehensive test coverage (>95%)
- 📦 Tree-shakeable ESM and CommonJS support
- 🔒 Type-safe with strict TypeScript configuration
- 📖 Extensive JSDoc documentation
Available Functions (51)
areAnagrams- Check if two strings are anagramscapitalizeEachWord- Capitalize first letter of each wordcapitalizeFirstLetter- Capitalize first letter of stringcapitalizeNthLetter- Capitalize specific letter at index ncountCharacterOccurrences- Count occurrences of a charactercountConsonants- Count consonants in stringcountSubstring- Count substring occurrencescountVowels- Count vowels in stringcountWords- Count words in stringendsWith- Check if string ends with substringescapeRegex- Escape special regex charactersextractSubstring- Extract substring by indicesfindLongestWord- Find longest word in stringfirstNonRepeatingCharacter- Find first non-repeating charactergenerateRandomAlphanumeric- Generate random alphanumeric stringgenerateRandomString- Generate random stringgetFileExtension- Get file extension from filenamehasLowercase- Check if string has lowercase lettershasUppercase- Check if string has uppercase lettersindexOfSubstring- Find index of substringisAlpha- Check if string contains only lettersisAlphanumeric- Check if string is alphanumericisNumeric- Check if string is numericisPalindrome- Check if string is palindromeisValidEmail- Validate email formatisWhitespace- Check if string is whitespace onlylastIndexOfSubstring- Find last index of substringpadString- Pad string to specified lengthremoveWhitespace- Remove all whitespacerepeatString- Repeat string n timesrepeatUntilLength- Repeat string until reaches lengthreplaceFirst- Replace first occurrencereplaceMultiple- Replace multiple substrings at oncereplaceSubstring- Replace substring with anotherreverseString- Reverse stringreverseWords- Reverse word orderslugify- Convert string to URL-friendly slugsplitString- Split string by delimiterstartsWith- Check if string starts with substringstringToBoolean- Convert string to booleanstringToNumber- Convert string to numberstringToWords- Split string into words arraystripHtmlTags- Remove HTML tags from stringtoKebabCase- Convert to kebab-casetoLowerCase- Convert to lowercasetoSnakeCase- Convert to snake_casetoUpperCase- Convert to uppercasetrimWhitespace- Trim leading/trailing whitespacetruncateString- Truncate string to max lengthuniqueCharacters- Get unique characters as arraywordsToSentence- Join words into sentence
Quick Example
import {
slugify,
capitalizeFirstLetter,
isPalindrome,
truncate,
} from '@ts-utilkit/string';
slugify('Hello World!'); // 'hello-world'
capitalizeFirstLetter('hello'); // 'Hello'
isPalindrome('racecar'); // true
truncate('Long text...', 10); // 'Long text...'License
MIT © Mykyta Forofontov
Contributing
Contributions are welcome! Please see the main repository for contribution guidelines.
