0.1.0 • Published 1 month ago

webext-typed-storage v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

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();
0.1.0

1 month ago