# @protocoldesigner-dev/protocol-executor

> Protocol executor for TypeScript

Latest version **0.1.1** (published 2024-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @protocoldesigner-dev/protocol-executor
pnpm add @protocoldesigner-dev/protocol-executor
yarn add @protocoldesigner-dev/protocol-executor
bun add @protocoldesigner-dev/protocol-executor
```

Provides the command `WizardGenerator`.

## 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.1 |
| Published | 2024-04-30 |
| First published | 2024-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 68.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ProtocolDesigner Team |
| Maintainers | bhansom |
| Keywords | state-machine, protocol, fsm, typescript |

## Links

- npm: https://www.npmjs.com/package/@protocoldesigner-dev/protocol-executor
- Repository: https://github.com/protocoldesigner-dev/protocolexecutor-ts
- Homepage: https://github.com/protocoldesigner-dev/protocolexecutor-ts#readme
- Issues: https://github.com/protocoldesigner-dev/protocolexecutor-ts/issues
- npm.io page: https://npm.io/package/@protocoldesigner-dev/protocol-executor

## 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

- 0.1.1 (latest) — 2024-04-30
- 0.1.0 — 2024-03-11

## README

# ProtocolExecutor TS

Typescript Executor for [ProtocolDesigner](https://protocoldesigner.dev)  

- Multiple stateful nodes
- Graphical edition
- Easy api

## Installation & Usage

Install in your project:

```bash
$ npm install -D @protocoldesigner-dev/protocol-executor
```

Usge:

1.build and verify your protocol in the [editor](https://protocoldesigner.dev/editor).

A traffic cross example:

![landing](https://protocoldesigner.dev/landing.png)

2.initialize the protocol exported in json format:
```typescript
const exec = new ProtocolExecutor(m);
```

3.register hook:
```typescript
// do stop road H
function stopH(e :DefaultEvent, from :string, to :string){
  console.log("stop road h");
  console.log(e, from, to);
}
exec.registerHook({
  node: 'H',
  action: 'HS Stop'
}, stopH)
```

4.start the execution:
```typescript
//You can also register hooks at INIT and START phases.  
exec.init();
exec.start();
const events = [
  {node: 'Traffic cross', action: 'VS Start'},
  {node: 'Traffic cross', action: 'HL Start'},
  {node: 'Traffic cross', action: 'VL Start'},
  {node: 'Traffic cross', action: 'HS Start'},
]
//periodically issue events to simulate the traffic cross
var i=0;
setInterval(function(){
    const t = exec.issueEvent(events[i++ % 4])
    //wait for accepted or completed status.
    t.accpeted().then((result)=>{...})
    t.finished().then((result)=>{...})
}, 1000)

```



## License

MIT.

## TODO

1. assertions.
2. test specs.

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