scmJS docs

api.storage

StorageApi

A small key-value store of the plugin's own, kept in the browser's local storage under the plugin's id and listed with everything else in Preferences ▸ Browser storage.

Members

get

get<T>(key: string, fallback: T): T;

Read a value, or fallback when the key was never set.

const options = api.storage.get("options", { showGrid: true });
const kept = api.storage.set("options", { ...options, showGrid: false });
if (!kept) api.ui.toast({ kind: "error", title: "Could not save the options", detail: "The browser's storage is full." });
Try it

set

set(key: string, value: unknown): boolean;

Store a value. False when the browser refused the write — its storage quota is a few megabytes for the whole editor — so a plugin keeping something the user made can say so instead of losing it silently.

remove

remove(key: string): void;

Seen in

scmJS 0.7.3 + main@e2d8ba5 · Generated from the repository. The source is under the MIT license, which does not cover what ATTRIBUTION.md lists. StarCraft and Brood War are trademarks of Blizzard Entertainment; this project ships none of their data.