webext-typed-storage
v0.1.0
Published
Better WebExtension storage API
Downloads
4
Readme
WebExt Typed Storage
Tiny wrapper around the WebExtension storage API that provides type safety.
Example
import { storage } from "webext-typed-storage";
declare module "webext-typed-storage" {
interface SyncStorage {
name: string;
}
interface SessionStorage {
/* ... */
}
interface LocalStorage {
/* ... */
}
}
await storage.sync.set({ name: "Alice" });
console.log(await storage.sync.get("name")); // { name: "Alice" }
storage.sync.addListener((changes) => {
console.log(changes.name);
});
await storage.sync.remove("name");
await storage.sync.clear();