Formatters
formatCurrency
Formats a number as currency with proper localization.Parameters
number
required
The amount to format
CurrencyFormatOptions
Formatting options
Return Value
string
Formatted currency string
Example
formatDate
Formats a date according to specified format and locale.Parameters
Date | string | number
required
The date to format (Date object, ISO string, or timestamp)
DateFormat
default:"'medium'"
Format preset: ‘short’, ‘medium’, ‘long’, ‘full’, or custom format string
DateFormatOptions
Additional formatting options
Return Value
string
Formatted date string
Example
formatFileSize
Formats bytes into human-readable file size.Parameters
number
required
Number of bytes
number
default:"2"
Number of decimal places
Return Value
string
Formatted file size (e.g., “1.5 MB”)
Example
formatPhoneNumber
Formats a phone number string according to regional standards.Parameters
string
required
Phone number string (digits only or with formatting)
string
default:"'US'"
ISO 3166-1 alpha-2 country code
Return Value
string
Formatted phone number
Example
Validators
validateEmail
Validates an email address format.Parameters
string
required
Email address to validate
Return Value
boolean
Whether the email is valid
Example
validatePassword
Validates password strength against configurable rules.Parameters
string
required
Password to validate
PasswordRequirements
Password strength requirements
Return Value
ValidationResult
Validation result object
Example
validateURL
Validates a URL format.Parameters
string
required
URL to validate
URLValidationOptions
Validation options
Return Value
boolean
Whether the URL is valid
Example
Data Manipulation
debounce
Creates a debounced function that delays execution.Parameters
Function
required
The function to debounce
number
required
Delay in milliseconds
Return Value
Function & { cancel: () => void }
Debounced function with a cancel method
Example
throttle
Creates a throttled function that executes at most once per interval.Parameters
Function
required
The function to throttle
number
required
Interval in milliseconds
Return Value
Function
Throttled function
Example
deepClone
Creates a deep copy of an object or array.Parameters
T
required
Value to clone
Return Value
T
Deep cloned copy of the value
Example
groupBy
Groups array items by a specified key or function.Parameters
T[]
required
Array to group
keyof T | ((item: T) => string)
required
Property key or function to group by
Return Value
Record<string, T[]>
Object with grouped items
Example
sortBy
Sorts array by specified key or comparator function.Parameters
T[]
required
Array to sort
keyof T | ((item: T) => any)
required
Property key or comparator function
'asc' | 'desc'
default:"'asc'"
Sort order
Return Value
T[]
New sorted array (original unchanged)
Example
String Utilities
truncate
Truncates a string to a maximum length.Parameters
string
required
String to truncate
number
required
Maximum length
string
default:"'...'"
Suffix to append when truncated
Return Value
string
Truncated string
Example
capitalize
Capitalizes the first letter of a string.Parameters
string
required
String to capitalize
Return Value
string
Capitalized string
Example
slugify
Converts a string to a URL-friendly slug.Parameters
string
required
String to slugify
Return Value
string
URL-friendly slug