Skip to content

Commit

Permalink
flip spread with new obj to throw on list_exit_actions and probable_a…
Browse files Browse the repository at this point in the history
…ction_exits
  • Loading branch information
StoneCypher committed Jul 5, 2017
1 parent 9b30e34 commit e8b68ad
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
18 changes: 13 additions & 5 deletions dist/jssm.es5.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/lib/index.html
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset='utf-8' />
<title>jssm 3.1.6 | Documentation</title>
<title>jssm 3.1.7 | Documentation</title>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' type='text/css' rel='stylesheet' />
<link href='assets/style.css' type='text/css' rel='stylesheet' />
Expand All @@ -14,7 +14,7 @@
<div class='fixed xs-hide fix-3 overflow-auto max-height-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>jssm</h3>
<div class='mb1'><code>3.1.6</code></div>
<div class='mb1'><code>3.1.7</code></div>
<input
placeholder='Filter'
id='filter-input'
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "jssm",
"version": "3.1.6",
"version": "3.1.7",
"engines": {
"node": ">=6.0.0"
},
Expand Down
10 changes: 8 additions & 2 deletions src/js/jssm.js
Expand Up @@ -314,14 +314,20 @@ class machine<mNT, mDT> {
}
*/
list_exit_actions(whichState : mNT = this.state() ) : Array<any> { // these are mNT
return [... (this._reverse_actions.get(whichState) || new Map()).values()] // wasteful, should throw instead
const ra_base = this._reverse_actions.get(whichState);
if (!(ra_base)) { throw new Error(`No such state ${JSON.stringify(whichState)}`); }

return [... ra_base.values()]
.map ( (edgeId:number) => this._edges[edgeId] )
.filter ( (o:JssmTransition<mNT, mDT>) => o.from === whichState )
.map ( filtered => filtered.action );
}

probable_action_exits(whichState : mNT = this.state() ) : Array<any> { // these are mNT
return [... (this._reverse_actions.get(whichState) || new Map()).values()] // wasteful, should throw instead
const ra_base = this._reverse_actions.get(whichState);
if (!(ra_base)) { throw new Error(`No such state ${JSON.stringify(whichState)}`); }

return [... ra_base.values()]
.map ( (edgeId:number) => this._edges[edgeId] )
.filter ( (o:JssmTransition<mNT, mDT>) => o.from === whichState )
.map ( filtered => ( { action : filtered.action,
Expand Down
2 changes: 1 addition & 1 deletion src/js/tests/general.js
Expand Up @@ -736,7 +736,7 @@ describe('Illegal machines', async it => {
]
});

machine.actions('no such action');
machine.list_states_having_action('no such action');

}, Error));

Expand Down

0 comments on commit e8b68ad

Please sign in to comment.