Overview
Sorionlib provides a collection of utility functions to simplify common programming tasks. Import them from theutils module.
String utilities
slugify(text)
Converts a string to a URL-friendly slug.
Returns:
string - The slugified text.
capitalize(text)
Capitalizes the first letter of a string.
Returns:
string - The capitalized text.
truncate(text, length)
Truncates a string to a specified length.
Returns:
string - The truncated text with ellipsis if needed.
Array utilities
unique(array)
Removes duplicate values from an array.
Returns:
array - Array with unique values.
chunk(array, size)
Splits an array into chunks of a specified size.
Returns:
array - Array of chunks.
shuffle(array)
Randomly shuffles an array.
Returns:
array - The shuffled array.
Object utilities
deepClone(object)
Creates a deep copy of an object.
Returns:
object - The cloned object.
merge(target, source)
Deep merges two objects.
Returns:
object - The merged object.
Date utilities
formatDate(date, format)
Formats a date according to a pattern.
Returns:
string - The formatted date.
timeAgo(date)
Returns a human-readable relative time string.
Returns:
string - Relative time string.