@svackages/persistent-store

1.0.3 • Public • Published

svackages logo

persistent typed store

This package allows you to persist your store through localstorage.

basic usage

Typescript

const myPersistentStore = persistentStore<SomeType>({
    key: 'fancyKey',
    initValue: null,
});

JavaScript

const myPersistentStore = persistentStore({
    key: 'fancyKey',
    initValue: null,
});

clear out localstorage

// in .svelte
$myPersistentStore = null; // undefined will work as well

// in .ts/.js
myPersistentStore.set(null); // undefined will work as well

optional params

you can hook into the read and write cycle to transform values.

readHook?: (storage?: string) => T,
writeHook?: (storeValue: T) => string

Readme

Keywords

none

Package Sidebar

Install

npm i @svackages/persistent-store

Weekly Downloads

0

Version

1.0.3

License

none

Unpacked Size

4.17 kB

Total Files

5

Last publish

Collaborators

  • d.reitzner