UNPKG

@tdb/util

Version:
25 lines (24 loc) 896 B
export interface ILocalStorageOptions { default?: any; } export declare type StorageValueType = 'string' | 'bool' | 'number' | 'date' | 'object' | 'null'; export interface ILocalStorageValue { type: StorageValueType; value: any; } export interface ILocalStorage { getItem(key: string): Promise<any>; setItem(key: string, value: any): Promise<void>; removeItem(key: string): Promise<void>; } export interface ILocalStorageChangedEvent { key: string; value: any; type: StorageValueType; } export declare type LocalStoragePropertyFunc<T> = (value?: T | null, options?: ILocalStorageOptions) => Promise<T | undefined>; export declare type LocalStorageProp<T> = LocalStoragePropertyFunc<T> & { key: string; isProp: boolean; }; export declare type LocalStoragePropertyFactory = <T>(key: string, defaultOptions?: ILocalStorageOptions) => LocalStorageProp<T>;