1.0.6 • Published 2 years ago

app-local-store v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

2 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago