app-local-store
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

app-local-store

Easily persist app data.

What is it good for?

CLI apps! This package makes persisting data scoped to your app a breeze.

Installation

npm i --save app-local-store

Usage

import { anAppDataStore } from 'app-local-store';

/* 
The store data will be initialized with this data only on the first time a store is created.
You can also not provide this value and set it yourself using the store "write" method.
*/
const dataShape = {
  preference: {
    user: {...},
    system: {...}
  },
  scopes: ...
  ...
};

const appName = 'app'
const store = await anAppDataStore(appName, {initialData:dataShape});
const newUserPreference = {...}
await store.set("preference", {...initialData.preference, user: newUserPreference})

// On some other run of your app when getting the user preference it will be equal to "newUserPreference"
const { user } = await store.get("preference");

// Dump the entire app data to an object
const myAppData = await store.read();

Package Sidebar

Install

npm i app-local-store

Weekly Downloads

6

Version

1.0.6

License

ISC

Unpacked Size

10.3 kB

Total Files

11

Last publish

Collaborators

  • galelmalah