///
The `@aruuri/utils` package is a collection of shared, pure utility functions designed for common tasks across the Aruuri platform. It provides helpers for currency manipulation, date formatting, and
79 views
~79 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
The @aruuri/utils package is a collection of shared, pure utility functions designed for common tasks across the Aruuri platform. It provides helpers for currency manipulation, date formatting, and various string and number formatting operations. This package promotes code reusability and consistency, making it a foundational part of the [Aruuri Monorepo Architecture].
Functions for converting between major and minor currency units, and formatting currency values.
formatCurrency(amountMinor: bigint | number, currencyCode: string, locale?: string): string // Format an amount in minor units to a localized currency string.getCurrencySymbol(currencyCode: string, locale?: string): string // Get the currency symbol for a given currency code and locale.majorToMinor(amountMajor: number, decimalPlaces?: number): bigint // Convert major units (e.g., dollars, pounds) to minor units (e.g., cents, pence).minorToMajor(amountMinor: bigint | number, decimalPlaces?: number): number // Convert minor units (e.g., cents, pence) to major units (e.g., dollars, pounds).Functions for formatting dates in various ways, including relative time, and checking date properties.
formatLongDate(date: Date, locale?: string): string // Format a date to long format with full month name.formatRelativeTime(date: Date, locale?: string): string // Format a date to relative time (e.g., "2 days ago", "in 3 hours").formatShortDate(date: Date, locale?: string): string // Format a date to short format with abbreviated month.isFuture(date: Date): boolean // Check if a date is in the future.isPast(date: Date): boolean // Check if a date is in the past.General utility functions for number, percentage, and string formatting.
formatNumber(num: bigint | number, locale?: string): string // Format a number with locale-specific thousand separators.formatPercent(value: number, decimals?: number, locale?: string): string // Format a decimal value as a percentage.slugify(text: string): string // Convert a string to a URL-friendly slug.truncate(text: string, maxLength: number): string // Truncate text to a maximum length and add ellipsis if needed.