Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.34 KB

README.md

File metadata and controls

55 lines (40 loc) · 1.34 KB

@jsheaven/store

A reactive, observed and auto-persisted object store

User Stories

  1. As a developer, I want to have an object store simply persisted
  2. As a developer, I want to hook into changes at every depth reactively

Features

  • ✅ Offers the @jsheaven/observed reactive object API
  • ✅ Integrates with simply-persist to save on any change
  • ✅ Middleware function API allows to hook what is read and written (e.g. for encryption)
  • ✅ Available as a simple API
  • ✅ Just 387 byte nano sized (ESM, gizpped)
  • ✅ Tree-shakable and side-effect free
  • ✅ Runs on Windows, Mac, Linux, CI tested
  • ✅ First class TypeScript support
  • ✅ 100% Unit Test coverage

Example usage

Setup

  • yarn: yarn add @jsheaven/store
  • npm: npm install @jsheaven/store

ESM

import { store } from '@jsheaven/store'

export interface MyStore {
  a: boolean
  b: number
  c: {
    foo: string
  }
}

const myStore = await store<MyStore>({
  name: 'myStore',
  initialValue: { a: true, b: 1, c: { foo: 'nice!' }} },
  provider: 'session' // from `simply-persist`; persists to SessionStorage
})

CommonJS

const { store } = require('@jsheaven/store')

// same API like ESM variant