Text
String manipulation: case conversion, extraction, cleanup, and analysis.
Install the SDK
npm install @toolpouch/sdkView on npm →Import from this module
import { functionName } from '@toolpouch/sdk/text'toCamelCase
Signature
toCamelCase(text: string): stringConvert text to camelCase format.
Example
import { toCamelCase }from '@toolpouch/sdk/text' ;const camel = toCamelCase('hello world' );// 'helloWorld'
Returns
camelCase string
toSnakeCase
Signature
toSnakeCase(text: string): stringConvert text to snake_case format.
Example
import { toSnakeCase }from '@toolpouch/sdk/text' ;const snake = toSnakeCase('HelloWorld' );// 'hello_world'
Returns
snake_case string
toKebabCase
Signature
toKebabCase(text: string): stringConvert text to kebab-case format.
Example
import { toKebabCase }from '@toolpouch/sdk/text' ;const kebab = toKebabCase('HelloWorld' );// 'hello-world'
Returns
kebab-case string
toPascalCase
Signature
toPascalCase(text: string): stringConvert text to PascalCase format.
Example
import { toPascalCase }from '@toolpouch/sdk/text' ;const pascal = toPascalCase('hello world' );// 'HelloWorld'
Returns
PascalCase string
toSlug
Signature
toSlug(text: string): stringConvert text to URL-safe slug format.
Example
import { toSlug }from '@toolpouch/sdk/text' ;const slug = toSlug('Hello World!' );// 'hello-world'
Returns
URL-safe slug string
removeExtraSpaces
Signature
removeExtraSpaces(text: string): stringRemove extra spaces and trim whitespace.
Example
import { removeExtraSpaces }from '@toolpouch/sdk/text' ;const clean = removeExtraSpaces('hello world ' );// 'hello world'
Returns
String with normalized spacing
extractUrls
Signature
extractUrls(text: string): string[]Extract all URLs from text.
Example
import { extractUrls }from '@toolpouch/sdk/text' ;const urls = extractUrls('Visit https: );//example.com today' // [ 'https://example.com' ]
Returns
Array of URL strings
extractEmails
Signature
extractEmails(text: string): string[]Extract all email addresses from text.
Example
import { extractEmails }from '@toolpouch/sdk/text' ;const emails = extractEmails('Contact: [email protected]' );// [ '[email protected]' ]
Returns
Array of email strings
extractNumbers
Signature
extractNumbers(text: string): number[]Extract all numbers from text.
Example
import { extractNumbers }from '@toolpouch/sdk/text' ;const nums = extractNumbers('The answer is );42 or3.14 '// [ 42 ,3.14 ]
Returns
Array of numbers
sortLines
Signature
sortLines(text: string, mode?: 'asc' | 'desc'): stringSort text lines alphabetically in ascending or descending order.
Example
import { sortLines }from '@toolpouch/sdk/text' ;const sorted = sortLines('zebra\napple\nbanana' ,'asc' );// 'apple\nbanana\nzebra'
Returns
String with sorted lines
removeDuplicateLines
Signature
removeDuplicateLines(text: string): stringRemove duplicate lines from text.
Example
import { removeDuplicateLines }from '@toolpouch/sdk/text' ;const unique = removeDuplicateLines('apple\nbanana\napple' );// 'apple\nbanana'
Returns
String with unique lines only
reverseText
Signature
reverseText(text: string): stringReverse the order of characters in text.
Example
import { reverseText }from '@toolpouch/sdk/text' ;const reversed = reverseText('hello' );// 'olleh'
Returns
Reversed string
wordCount
Signature
wordCount(text: string): { words: number; characters: number; lines: number }Count words, characters, and lines in text.
Example
import { wordCount }from '@toolpouch/sdk/text' ;const stats = wordCount('Hello world' );// { words: 2 , characters:11 , lines:1 }
Returns
Object with words, characters, and lines count
morseEncode
Signature
morseEncode(text: string): stringEncode text as Morse code.
Example
import { morseEncode }from '@toolpouch/sdk/text' ;const morse = morseEncode('SOS' );// '... --- ...'
Returns
Morse code string
morseDecode
Signature
morseDecode(morse: string): stringDecode Morse code to text.
Example
import { morseDecode }from '@toolpouch/sdk/text' ;const text = morseDecode('... --- ...' );// 'SOS'
Returns
Decoded text