# @nylestroke/store

> Simple, light-way state library for JS/TS

Latest version **0.2.1** (published 2023-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nylestroke/store
pnpm add @nylestroke/store
yarn add @nylestroke/store
bun add @nylestroke/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.2.1 |
| Published | 2023-09-26 |
| First published | 2023-09-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 67.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vladyslav Potapenko |
| Maintainers | nylestroke |
| Keywords | store, state, js, ts, subscription, reducer |

## Links

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

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.1 (latest) — 2023-09-26
- 0.1.3 — 2023-09-25
- 0.1.2 — 2023-09-25
- 0.1.1 — 2023-09-25
- 0.1.0 — 2023-09-25

## README

## @nylestroke/store

@nylestroke/store is a simple state container for JavaScript apps.

It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test.

## Installation

```
npm install @nylestroke/store
```

For more details, see [the NPM page](https://npmjs.com/package/@nylestroke/store).

## Basic Example

```js
import { Store } from '@nylestroke/store';

const store = new Store();

const firstCallback = state => {
  console.log('first callback ', state); // callback function
};
const firstConfig = state => { // there you can state, as you want
  return state;
};

const secondCallback = state => {
  console.log('second callback ', state);
};
const secondConfig = state => {
  return [state];
};

store.subscribe(firstCallback, firstConfig); // call subscription with callback and configuration
store.subscribe(secondCallback, secondConfig);

store.setState({ a: 1 }); // add value to state (not set)
store.clearState(); // clear the state
store.setState({ a: 2 });
store.setState({ b: 1 });
store.cutState('b'); // delete key from a state
store.setState({ b: 2 });
```

## License

[MIT](https://github.com/nylestroke/store/blob/master/LICENSE)

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