@baiwusanyu/utils-com
Version:
56 lines (53 loc) • 1.61 kB
TypeScript
/**
* 根据下载链接下载文件
* @param url
*/
declare const downloadFile: (url: string) => void;
/**
* 防抖函数
* @param func
* @param wait
*/
declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* 节流函数
* @param func
* @param wait
*/
declare function throttle<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* 基于 hash sum 生成一个随机哈希
* @param id 生成hash的id
* @param prefix 自定义前缀
* @param suffix 自定义后缀
*/
declare const createHash: (id?: string | number, prefix?: string, suffix?: string) => string;
/**
* 将字符串复制到粘贴板
* 原生 Api 无需单测
* @param content 复制内容
* @param resolve 调用成功回调
* @param err 调用错误回调
*/
declare const copyText: (content: string, resolve?: () => void, err?: ((err: any) => void) | undefined) => void;
/**
* 基于 sessionStorage 的缓存函数
*/
declare const sessionCache: {
set(key: string, value: string): void;
get(key: string): string | null;
setJSON(key: string, jsonValue: any): void;
getJSON(key: string): any;
remove(key: string): void;
};
/**
* 基于 localStorage 的缓存函数
*/
declare const localCache: {
set(key: string, value: string): void;
get(key: string): string | null;
setJSON(key: string, jsonValue: any): void;
getJSON(key: string): any;
remove(key: string): void;
};
export { copyText, createHash, debounce, downloadFile, localCache, sessionCache, throttle };