@plutoxyz/frame-js
Version:
SDK for integrating with Pluto Frame
42 lines (41 loc) • 1.3 kB
TypeScript
/**
* Utility functions for the Frame SDK
*/
/**
* Generate a unique ID
* @returns A unique string ID
*/
export declare function generateId(): string;
/**
* Safely parse JSON
* @param data The data to parse
* @param fallback Fallback value if parsing fails
* @returns Parsed JSON or fallback
*/
export declare function safeJsonParse<T>(data: string, fallback: T): T;
/**
* Validate an origin against a pattern (supports wildcards)
* @param origin The origin to validate
* @param pattern The pattern to validate against (can include wildcards)
* @returns Whether the origin matches the pattern
*/
export declare function validateOrigin(origin: string, pattern: string): boolean;
/**
* Debounce a function
* @param fn The function to debounce
* @param delay The delay in milliseconds
* @returns A debounced function
*/
export declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
/**
* Check if an object is empty
* @param obj The object to check
* @returns Whether the object is empty
*/
export declare function isEmptyObject(obj: Record<string, any>): boolean;
/**
* Deep clone an object
* @param obj The object to clone
* @returns A deep clone of the object
*/
export declare function deepClone<T>(obj: T): T;