UNPKG

recent-searches

Version:

A JavaScript module to help anyone easily build recent searches functionality into their search.

23 lines (22 loc) 866 B
import MemoryStorage from "./MemoryStorage"; export declare const DEFAULT_STORAGE_KEY = "__RECENT_SEARCHES__"; export declare const isLocalStorageSupported: () => boolean; export declare const safeDataParse: <T>(data: string | null, defaultValue: T) => T; export interface ISafeLocalStorageConfig<T> { defaultValue: T; key?: string; limit?: number; } export interface ISafeLocalStorage<T> { getItem: () => T; setItem: (item: T) => boolean; } export declare class SafeLocalStorage<T> implements ISafeLocalStorage<T> { private readonly KEY; private readonly DEFAULT_VALUE; constructor(config: ISafeLocalStorageConfig<T>); getItem: () => T; setItem: (items: T) => boolean; } declare const NewSafeLocalStorage: <T>(config: ISafeLocalStorageConfig<T>) => SafeLocalStorage<T> | MemoryStorage<T>; export default NewSafeLocalStorage;