# stachine

> A TypeScript state machine with events and effects

Latest version **1.1.1** (published 2023-03-05) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install stachine
pnpm add stachine
yarn add stachine
bun add stachine
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2023-03-05 |
| First published | 2020-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 23.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Etienne Dldc |
| Maintainers | etienne-dldc |
| Keywords | state-machine, typescript |

## Links

- npm: https://www.npmjs.com/package/stachine
- Repository: https://github.com/etienne-dldc/stachine
- Homepage: https://github.com/etienne-dldc/stachine#readme
- Issues: https://github.com/etienne-dldc/stachine/issues
- npm.io page: https://npm.io/package/stachine

## Dependencies (1)

- [suub](https://npm.io/package/suub.md) ^3.3.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2023-03-05
- 2.0.0-1 (next) — 2023-06-12
- 2.0.0-0 — 2023-03-25
- 1.1.0 — 2023-02-26
- 1.0.11 — 2023-02-25
- 1.0.10 — 2023-02-24
- 1.0.9 — 2023-01-09
- 1.0.8 — 2023-01-08
- 1.0.7 — 2023-01-08
- 1.0.6 — 2023-01-08
- 1.0.5 — 2023-01-08
- 1.0.4 — 2022-12-22
- 1.0.3 — 2022-08-11
- 1.0.2 — 2022-08-11
- 1.0.1 — 2022-08-11
- … 23 more at https://npm.io/package/stachine/versions

## README

# Stachine

> A TypeScript state machine with events and effects

## Gist

```ts
import { Stachine } from 'stachine';

type State = { state: 'Home' } | { state: 'Bed' } | { state: 'Work' } | { state: 'Error' };
type Action = { action: 'Commute' } | { action: 'Wake' } | { action: 'Sleep' } | { action: 'Error' };

const machine = Stachine<State, Action>({
  initialState: { state: 'Home' },
  createErrorAction: () => ({ action: 'Error' }),
  createErrorState: () => ({ state: 'Error' }),
  states: {
    Home: {
      actions: {
        Commute: () => ({ state: 'Work' }),
        Sleep: () => ({ state: 'Bed' }),
      },
    },
    Work: {
      actions: {
        Commute: () => ({ state: 'Home' }),
      },
    },
    Bed: {
      actions: {
        Wake: () => ({ state: 'Home' }),
      },
    },
    Error: {},
  },
});
```

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