import { LoggerOptions, GenerateIdOptions, FormatNumberOptions, WhereOptions } from './types.mjs'; export { LogLevel, ThousandsGroupStyle } from './types.mjs'; /** * Creates a logger instance with configurable logging levels, formatting, and output options. * * @param options - Logger configuration options object * @param options.level - Minimum log level to output: 'debug', 'info', 'warn', or 'error' (default: "info") * @param options.enabled - Whether logging is enabled (default: true) * @param options.prefix - Optional prefix/scope to include in log messages * @param options.json - Whether to output logs as JSON format (default: false) * @returns A logger object with debug, info, warn, error, and json methods */ declare function createLogger(options?: LoggerOptions): { debug: (message: string, data?: unknown) => void; info: (message: string, data?: unknown) => void; warn: (message: string, data?: unknown) => void; error: (message: string, data?: unknown) => void; json: (message: string, data?: unknown) => void; }; /** * Generates a unique ID with customizable options for prefix, length, alphabet, and format. * * @param options - ID generation options object * @param options.prefix - Optional prefix to prepend to the generated ID (default: "") * @param options.length - Length of the ID when format is "plain" (default: 8) * @param options.alphabet - Characters to use for ID generation (default: alphanumeric) * @param options.uppercase - Whether to convert the ID to uppercase (default: false) * @param options.secure - Whether to use cryptographically secure random generation (default: true) * @param options.seed - Optional seed for deterministic ID generation * @param options.format - Output format: "plain" or "uuid" (default: "uuid") * @returns A generated unique ID string */ declare function generateId(options?: GenerateIdOptions): string; /** * Formats a number with customizable decimal places, separators, and grouping styles. * * @param options - Formatting options object * @param options.value - The number or string to format * @param options.allowNegative - Whether to allow negative numbers (default: true) * @param options.decimalScale - Maximum number of decimal places (default: Infinity) * @param options.decimalSeparator - Character to use as decimal separator (default: ".") * @param options.fixedDecimalScale - Whether to always show the specified decimal places (default: false) * @param options.thousandSeparator - Character(s) to use as thousand separator, or false to disable (default: ",") * @param options.thousandsGroupStyle - Grouping style: 'none', 'thousand', 'lakh', or 'wan' (default: "thousand") * @returns The formatted number as a string */ declare function formatNumber({ value, allowNegative, decimalScale, decimalSeparator, fixedDecimalScale, thousandSeparator, thousandsGroupStyle, }: FormatNumberOptions): string; /** * Filters an array of objects by a given key, with optional value matching. * * @param options - Filter options object * @param options.data - The array to filter * @param options.key - The object property to filter by * @param options.value - Optional value to match against the key * * @returns A filtered array of matching items */ declare function where(options: WhereOptions): T[]; /** * Get a unique array of items. * * @param array - The array to get a unique items from * @returns A unique array of items */ declare function unique(array: T[]): T[]; /** * Get a random item from an array. * * @param array - The array to get a random item from * @returns A random item from the array */ declare function randomFromArray(array: T[]): T | undefined; /** * Truncate a string and append "..." if it exceeds the given length. * * @param text - The text to truncate * @param maxLength - Maximum allowed length * @param append - The text to append if the string exceeds the maximum length * @returns The truncated text */ declare function truncate(text: string, maxLength: number, append?: string): string; /** * Capitalize the first letter of a string. * * @param str - The string to capitalize * @returns The capitalized string */ declare function capitalize(str: string): string; /** * Convert a string to uppercase. * * @param str - The string to convert to uppercase * @returns The uppercase string */ declare function uppercase(str: string): string; /** * Convert a string to a slug. * * @param text - The text to convert to a slug * @returns The slugified string */ declare function slugify(text: string): string; /** * Format a duration in seconds to a human-readable string. * * @param seconds - The duration in seconds * @returns The formatted duration (e.g. "1h 30m 0s") */ declare function formatDuration(seconds: number): string; /** * Format a date to a human-readable string. * * @param date - The date to format * @returns The formatted date (e.g. "1h 30m 0s ago") */ declare function timeAgo(date: string | Date): string; /** * Sleep for a given number of milliseconds. * * @param ms - The number of milliseconds to sleep * @returns A promise that resolves after the given number of milliseconds */ declare const sleep: (ms: number) => Promise; /** * Try to execute a function and catch any errors. * * @param fn - The function to execute * @returns A promise that resolves to an array with the error (if any) and the result (if any) */ declare function tryCatch(fn: () => Promise): Promise<[Error | null, T | null]>; export { FormatNumberOptions, GenerateIdOptions, LoggerOptions, WhereOptions, capitalize, createLogger, formatDuration, formatNumber, generateId, randomFromArray, sleep, slugify, timeAgo, truncate, tryCatch, unique, uppercase, where };