# @naporin0624/simple-store

> A simple store using map

Latest version **0.1.4** (published 2022-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @naporin0624/simple-store
pnpm add @naporin0624/simple-store
yarn add @naporin0624/simple-store
bun add @naporin0624/simple-store
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2022-07-25 |
| First published | 2021-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | naporin0624 |
| Maintainers | naporin0624 |
| Keywords | store |

## Links

- npm: https://www.npmjs.com/package/@naporin0624/simple-store
- Homepage: https://github.com/naporin0624/packages/tree/main/packages/simple-store#simple-store
- npm.io page: https://npm.io/package/@naporin0624/simple-store

## Recent versions

- 0.1.4 (latest) — 2022-07-25
- 0.1.3 — 2022-07-14
- 0.1.2 — 2022-04-10
- 0.1.1 — 2022-02-19
- 0.1.0 — 2022-01-22
- 0.0.7 — 2022-01-22
- 0.0.6 — 2021-12-07
- 0.0.5 — 2021-12-01
- 0.0.4 — 2021-11-30
- 0.0.3 — 2021-11-29
- 0.0.2 — 2021-11-29
- 0.0.1 — 2021-11-29

## README

# `simple-store`

Simple state management using Set objects.

[![Image from Gyazo](https://i.gyazo.com/8601ece7cc54d0439551cd306e586a0f.gif)](https://gyazo.com/8601ece7cc54d0439551cd306e586a0f)

## Usage

```typescript
import { createStore } from "@naporin0624/simple-store";

const store = createStore<string, number>();
const counter = document.createElement("p");
counter.innerText = `count: ${0}`;

store.subscribe(() => {
  const count = store.get("count") ?? 0;
  counter.innerText = `count: ${count}`;
});

const increment = document.createElement("button");
increment.onclick = () => {
  const count = store.get("count") ?? 0;
  store.set("count", count + 1);
};
increment.innerText = "increment";

const decrement = document.createElement("button");
decrement.onclick = () => {
  const count = store.get("count") ?? 0;
  store.set("count", count - 1);
};
decrement.innerText = "decrement";

const app = document.getElementById("app");
if (!app) throw new Error();

app.innerHTML = `
  <h1>Hello Simple Store</h1>
`;
app.appendChild(counter);
app.appendChild(increment);
app.appendChild(decrement);
```

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