What Are Utility Functions?
Utility functions provide ready-to-use solutions for common programming tasks. These helper functions help reduce boilerplate code and improve development efficiency.
๐
Data Formatting
๐งช
Validation
๐ข
Math Operations
๐งฉ
String Manipulation
Available Utilities
Data Formatting
Convert, format, and transform data between different representations.
const formatted = formatCurrency(1234.56, 'USD'); // $1,234.56
const isoDate = formatDate('2025-01-01', { timeZone: 'UTC' });
Validation Tools
Verify data integrity with robust type and format validation functions.
if (isEmail('test@example.com')) {
// Process valid email
}
if (validateSchema(data, userSchema)) {
// Proceed with valid data
}
String Manipulation
Process and transform strings with powerful utility functions.
const slug = toSlug('My Page Title'); // my-page-title
const initials = extractInitials('John Doe'); // JD
Array Operations
Perform advanced array manipulations and transformations.
const unique = distinct([1, 2, 2, 3]); // [1, 2, 3]
const grouped = groupBy(users, 'department');
Code Examples
Data Transformation
const users = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' }
];
// Transform to map
const userMap = toMap(users, 'id');
// Result: { 1: { id: 1, name: 'Alice' }, 2: { id: 2, name: 'Bob' } }
Validation Example
const schema = {
type: 'object',
properties: {
email: { type: 'string', format: 'email' },
age: { type: 'integer', minimum: 18 }
},
required: ['email', 'age']
};
if (validate(data, schema)) {
// Process valid data
}
Explore Related APIs
Type Definitions
TypeScript type information and interface definitions for all utilities.
View Types โ