Store/README.md
2024-10-18 18:47:47 -06:00

993 B

BearMetalStore

A no-dep, lightweight, synchronous store for storing data in a JSON file.

Usage

import { BearMetalStore } from "@bearmetal/store";

const store = new BearMetalStore();

store.set("key", "value");

console.log(store.get("key"));

store.close();

API

new BearMetalStore(storePath?: string)

Creates a new store.

Parameters

  • storePath?: string

    The path to the store file.

Environment Variables

  • BEAR_METAL_STORE_PATH

    The path to the store file. Can be used instead of the storePath parameter. If neither is provided, the store will be stored in ./BearMetal/store.json.

Events

The store will dispatch a custom event with the name "bm:refresh-store" + storePath when the store is updated. This can be used to trigger a refresh of the store in other parts of the application.

Permisions

Read and write access to the store file is required. Environment access to the "BEAR_METAL_STORE_PATH" variable is required.