UNPKG

@aivron/sync-storage

Version:

A universal, synchronous storage solution for React (web & desktop) with support for core operations, bulk actions, JSON, TTL, and React hooks. For React Native, use @aivron/async-storage.

19 lines (18 loc) 975 B
export type StorageType = { getItem(key: string): string | null; setItem(key: string, value: string): void; removeItem(key: string): void; key(index: number): string | null; readonly length: number; }; /** * Returns the default storage instance. * In browser/desktop (Electron) environments, this is typically localStorage. */ export declare function getDefaultStorage(): StorageType; export declare function getStorageKeys(storage?: StorageType): string[]; export declare function hasStorageItem(key: string, storage?: StorageType): boolean; export declare function getStorageItem(key: string, storage?: StorageType): string | null; export declare function setStorageItem(key: string, value: string, storage?: StorageType): void; export declare function updateStorageItem(key: string, updateFn: (currentValue: string | null) => string, storage?: StorageType): void; export declare function removeStorageItem(key: string, storage?: StorageType): void;