UNPKG

@dima_aryze/reforge

Version:

TypeScript/JavaScript SDK for Reforge - Cross-chain token operations

63 lines 2.15 kB
/** * Utility functions and helpers for the Reforge SDK */ import { ReforgeError } from '../errors'; export { createLogger, Logger, silentLogger } from './logger'; export type { LoggerConfig } from './logger'; /** * Check if an error is a Reforge SDK error */ export declare function isReforgeError(error: unknown): error is ReforgeError; /** * Sleep for specified milliseconds */ export declare function sleep(ms: number): Promise<void>; /** * Create a delay with exponential backoff and jitter */ export declare function exponentialBackoff(attempt: number, baseDelay: number, maxDelay: number, multiplier?: number): number; /** * Validate required fields in an object */ export declare function validateRequired(obj: Record<string, any>, fields: string[]): void; /** * Deep merge objects with proper type safety */ export declare function deepMerge<T extends Record<string, any>>(target: T, ...sources: Partial<T>[]): T; /** * Sanitize URL by removing trailing slashes and ensuring proper format */ export declare function sanitizeUrl(url: string): string; /** * Build URL with query parameters */ export declare function buildUrl(baseUrl: string, path: string, params?: Record<string, any>): string; /** * Format error for consistent logging */ export declare function formatError(error: unknown): string; /** * Check if running in browser environment */ export declare function isBrowser(): boolean; /** * Check if running in Node.js environment */ export declare function isNode(): boolean; /** * Generate a unique request ID for tracking */ export declare function generateRequestId(): string; /** * Debounce function calls */ export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (..._args: Parameters<T>) => void; /** * Throttle function calls */ export declare function throttle<T extends (...args: any[]) => any>(func: T, wait: number): (..._args: Parameters<T>) => void; /** * Retry a function with exponential backoff */ export declare function retry<T>(fn: () => Promise<T>, maxAttempts?: number, baseDelay?: number): Promise<T>; //# sourceMappingURL=index.d.ts.map