UNPKG

webext-storage

Version:

A more usable typed storage API for Web Extensions

24 lines (23 loc) 1.09 kB
export type StorageItemMapOptions<T> = { area?: chrome.storage.AreaName; defaultValue?: T; }; export declare class StorageItemMap< /** Only specify this if you don't have a default value */ Base, /** The return type will be undefined unless you provide a default value */ Return = Base | undefined> { readonly prefix: `${string}:::`; readonly areaName: chrome.storage.AreaName; readonly defaultValue?: Return; constructor(key: string, { area, defaultValue, }?: StorageItemMapOptions<Exclude<Return, undefined>>); has: (secondaryKey: string) => Promise<boolean>; get: (secondaryKey: string) => Promise<Return>; set: (secondaryKey: string, value: Exclude<Return, undefined>) => Promise<void>; remove: (secondaryKey: string) => Promise<void>; /** @deprecated Only here to match the Map API; use `remove` instead */ delete: (secondaryKey: string) => Promise<void>; onChanged(callback: (key: string, value: Exclude<Return, undefined>) => void, signal?: AbortSignal): void; private getRawStorageKey; private getSecondaryStorageKey; }