id-scanner-lib
Version:
Browser-based ID card, QR code, and face recognition scanner with liveness detection
82 lines (81 loc) • 1.89 kB
TypeScript
/**
* @file 性能优化工具
* @description 提供性能优化相关的工具函数
* @module utils/performance
*/
/**
* LRU缓存实现
*/
export declare class LRUCache<K, V> {
private capacity;
private cache;
/**
* 构造函数
* @param capacity 缓存容量
*/
constructor(capacity?: number);
/**
* 获取缓存项
* @param key 键
* @returns 值,如果不存在则返回undefined
*/
get(key: K): V | undefined;
/**
* 设置缓存项
* @param key 键
* @param value 值
*/
set(key: K, value: V): void;
/**
* 检查键是否存在
* @param key 键
* @returns 是否存在
*/
has(key: K): boolean;
/**
* 删除缓存项
* @param key 键
* @returns 是否成功删除
*/
delete(key: K): boolean;
/**
* 清空缓存
*/
clear(): void;
/**
* 获取缓存大小
*/
get size(): number;
/**
* 获取所有键
*/
keys(): IterableIterator<K>;
/**
* 获取所有值
*/
values(): IterableIterator<V>;
/**
* 获取所有项
*/
entries(): IterableIterator<[K, V]>;
}
/**
* 计算图像指纹
* @param imageData 图像数据
* @returns 图像指纹
*/
export declare function calculateImageFingerprint(imageData: ImageData): string;
/**
* 防抖函数
* @param func 要执行的函数
* @param wait 等待时间(毫秒)
* @returns 防抖处理后的函数
*/
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* 节流函数
* @param func 要执行的函数
* @param limit 时间限制(毫秒)
* @returns 节流处理后的函数
*/
export declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): (...args: Parameters<T>) => void;