UNPKG

localmemory

Version:
44 lines (43 loc) 989 B
interface IMemory { name: string; value: any; expired?: string | number; } /** * sessionStorage 和 localStorage 的2此封装 * @param {string} type 存储方式:sessionStorage、localStorage * @returns {function} storage * @author Barry */ declare class Storage { private memory; constructor(type: any); /** * 设置缓存 * @param {object} params * name: 键、value: 值、expired: 过期时间 * @author Barry */ setItem(params: IMemory): boolean; /** * 取值 * @param {string} name 键 * @author Barry */ getItem<T>(name: string): T; /** * 移除缓存 * @param {string} name 键 * @author Barry */ removeItem(name: string): boolean; /** * 移除全部缓存 * @param {string} name 键 * @author Barry */ clear(): boolean; } declare const localMemory: Storage; declare const sessionMemory: Storage; export { localMemory, sessionMemory };