# @svackages/persistent-store

> ![svackages logo](https://raw.githubusercontent.com/svackages/persistent-store/main/logo.png) # persistent typed store This package allows you to persist your store through localstorage.

Latest version **1.0.3** (published 2021-11-25) · 0 weekly downloads

## Install

```sh
npm install @svackages/persistent-store
pnpm add @svackages/persistent-store
yarn add @svackages/persistent-store
bun add @svackages/persistent-store
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-11-25 |
| First published | 2021-11-25 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | d.reitzner |

## Links

- npm: https://www.npmjs.com/package/@svackages/persistent-store
- Repository: https://github.com/svackages/persistent-store
- Homepage: https://github.com/svackages/persistent-store#readme
- Issues: https://github.com/svackages/persistent-store/issues
- npm.io page: https://npm.io/package/@svackages/persistent-store

## Recent versions

- 1.0.3 (latest) — 2021-11-25
- 1.0.2 — 2021-11-25

## README

![svackages logo](https://raw.githubusercontent.com/svackages/persistent-store/main/logo.png)
# persistent typed store
This package allows you to persist your store through localstorage.

## basic usage
Typescript
```typescript
const myPersistentStore = persistentStore<SomeType>({
    key: 'fancyKey',
    initValue: null,
});
```

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

## clear out localstorage
```javascript
// 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.
```typescript
readHook?: (storage?: string) => T,
writeHook?: (storeValue: T) => string
```

---
_Source: https://npm.io/package/@svackages/persistent-store · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
