diff --git a/package.json b/package.json index 6cd733dd..37268881 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jssm", - "version": "0.17.1", + "version": "0.18.0", "description": "A Javascript state machine with a simple API. Well tested, and typed with Flowtype. MIT License.", "main": "dist/jssm.es5.browserified.js", "scripts": { @@ -26,9 +26,11 @@ }, "keywords": [ "state", + "state machine", "state-machine", "machine", "finite-state-machine", + "finite state machine", "fsm", "fsm-library", "js", diff --git a/src/js/jssm-types.js b/src/js/jssm-types.js index cf3402f4..8b85871e 100644 --- a/src/js/jssm-types.js +++ b/src/js/jssm-types.js @@ -80,7 +80,7 @@ type JssmTransition = { from : NT, to : NT, name? : string, - action? : string, + action? : NT, check? : JssmTransitionPermitterMaybeArray, // validate this edge's transition; usually about data probability? : number, // for stoch modelling, would like to constrain to [0..1], dunno how usual? : '' // most common exit, for graphing; likelihood overrides diff --git a/src/js/jssm.js b/src/js/jssm.js index 82c3dbc7..9aa98d1d 100644 --- a/src/js/jssm.js +++ b/src/js/jssm.js @@ -265,9 +265,18 @@ todo comeback action_exits_at(whichState : mNT) : Array { return [... (this._reverse_actions.get(whichState) || new Map()).values()] // wasteful - .map( (edgeId:number) => this._edges[edgeId] ) // whargarbl burn out any - .filter( o => o.from === whichState) - .map( filtered => filtered.to ); + .map ( (edgeId:number) => this._edges[edgeId] ) + .filter ( (o:JssmTransition) => o.from === whichState ) + .map ( filtered => filtered.action ); + } + + probable_action_exits_at(whichState : mNT) : Array { + return [... (this._reverse_actions.get(whichState) || new Map()).values()] // wasteful + .map ( (edgeId:number) => this._edges[edgeId] ) + .filter ( (o:JssmTransition) => o.from === whichState ) + .map ( filtered => ( { action : filtered.action, + probability : filtered.probability } ) + ); }