frontend-hamroun
Version:
A lightweight frontend JavaScript framework with React-like syntax
47 lines • 1.6 kB
TypeScript
/**
* Common utility functions for the framework
*/
export interface DebouncedFunction<T extends (...args: any[]) => any> {
(...args: Parameters<T>): void;
cancel: () => void;
}
/**
* Creates a debounced function that delays invoking the provided function
* until after the specified wait time has elapsed since the last time it was invoked.
*/
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): DebouncedFunction<T>;
export interface ThrottledFunction<T extends (...args: any[]) => any> {
(...args: Parameters<T>): void;
cancel: () => void;
}
/**
* Creates a throttled function that only invokes the provided function
* at most once per every wait milliseconds.
*/
export declare function throttle<T extends (...args: any[]) => any>(func: T, wait: number): ThrottledFunction<T>;
/**
* Deep clones an object by using JSON serialization
*/
export declare function deepClone<T>(obj: T): T;
/**
* Creates a memoized version of a function that caches results based on arguments
*/
export declare function memoize<T extends (...args: any[]) => any>(func: T): T;
/**
* Creates a UUID v4 string
*/
export declare function uuid(): string;
/**
* Formats a date according to the specified format
*/
export declare function formatDate(date: Date, format: string): string;
declare const _default: {
debounce: typeof debounce;
throttle: typeof throttle;
deepClone: typeof deepClone;
memoize: typeof memoize;
uuid: typeof uuid;
formatDate: typeof formatDate;
};
export default _default;
//# sourceMappingURL=utils.d.ts.map