UNPKG

jssm

Version:

A Javascript state machine with a simple API. Well tested, and typed with Flowtype. MIT License.

117 lines (115 loc) 4.87 kB
- [x] specifying the initial edges as 1-dir node edges, - [x] names, - [x] action names (edge names are unique, action names are unique-to-source,) - [x] the probability of an edge, - [ ] being the most probable edge, - [x] following one edge probabilistically, - [x] random walks - [x] which states are "complete" (that is, that an input sequence can be considered satisfactorily terminal), - [x] whether a machine is - [x] complete, - [x] final (not is_changing, complete, and terminal), - [ ] edges as force-only (eg to "off" in the traffic light) - [ ] actions as force-only (also eg to "off") - [ ] the ability to list - [x] a node's edges (in/out/both,) - [ ] a node's actions (in/out/both,) - [x] whether a node is terminal, - [x] whether the machine is at a terminal node, - [ ] to specify for a graph - [ ] edge count, - [ ] min, - [ ] max, - [ ] whether to selectively allow change by - [ ] action, - [ ] transition, - [ ] forced transition, - [ ] whether to tolerate islands, - [ ] whether to links should be 1d/2d/either, - [ ] ~~whether the state machine is fixed (not implementing for now,)~~ - [ ] ~~whether forcing (making a change outside the edge graph) is permitted (not implementing for now,)~~ - [ ] whether names are `allowed|disallowed|optional`, - [ ] whether action names are `allowed|disallowed|optional`, - [ ] whether states may be in more than one group, - [ ] to enforce for a graph - [ ] edge count, - [ ] min, - [ ] max, - [ ] change allowed by - [ ] action, - [ ] transition, - [ ] forced transition, - [ ] island tolerance, - [ ] link 1d/2d tolerance, - [ ] ~~state machine fixedness (not implementing for now,)~~ - [ ] ~~forcing permission (not implementing for now,)~~ - [ ] names `allowed|disallowed`ness, - [ ] action names `allowed|disallowed`ness, - [ ] edges multiple group tolerance, - [ ] ~~for non-fixed machines, (not implementing for now,)~~ - [ ] ~~to add edges~~, - [ ] ~~to remove edges~~, - [ ] ~~to remove nodes (and thus all the related edges,)~~ - [ ] ~~to have a sane way to validate afterwards~~ - [ ] attached data, - [ ] which is transactionally applied, - [ ] which is available to all validation hooks, - [ ] validation hooks on - [ ] walking an edge, - [ ] entering/exiting a node, - [ ] changing data (which can happen with or distinctly from a transition, but always atomically w/ validation), - [ ] notification hooks on - [ ] any change, - [ ] enter/exit a node, - [ ] walk an edge, - [ ] execute a named action, - [ ] data change, - [ ] init, - [ ] non-matching event - [ ] timers (todo needs fleshing out) - [ ] language support? - [ ] promise support? - [ ] generator support? - [ ] observable support? - [ ] async await support? - [x] the ability to generate - [x] flowchart representations - [x] as DOT strings - [ ] prolly using viz.js (graphviz emscriptened to yerbaschmidt)? - [ ] uml statechart representations? - [ ] sdl representations? - [ ] nfa representations? (see comments below, thanks @patater) - [ ] drakon representations? - [ ] from within gviz/viz.js? - [ ] harel statecharts? - [ ] the ability to - [x] save a state machine state, - [ ] load/create from a state machine state, - [ ] validate an abstract state machine state, - [ ] keep and rewind a state history (thanks @kz), - [ ] autocreate an api (that is, action "melt" on machine auto-gets api method equiv `.melt()`) - [ ] with optional prefixes - [ ] consume `.dfa` files? - [ ] compare two state machines? - [ ] check `is_changing` - [ ] describe edges as members of groups - [ ] improved nature of states (all thanks burny who isn't on gh zomg) - [ ] states as objects rather than strings - [ ] makes inheritance easier - [ ] makes heirarachy easier - [ ] makes state-associated data easier (eg walking state now has frame#) - [ ] makes underlying impl much harder - [ ] state subtypes - [ ] heirarchal states - [ ] triggered by subordinate on transfer callback to superior - [ ] "or polling" - [ ] multiple concurrent states (keanu mind blown.gif) - [ ] for convenience, - [ ] a fluent api for creation - [ ] a DOT-like string api for creation, - [ ] in background, - [ ] transition probability long-term measurement - [ ] state probability long-term measurement - [ ] sanity checks - [ ] `initial_state` must be a valid `state` difference between event and action: if action isn't handled, it's an error; if event, meh