Comparing version 1.5.2 to 1.7.0
{ | ||
"name": "jssm", | ||
"version": "1.5.2", | ||
"version": "1.7.0", | ||
"engines": { | ||
@@ -13,3 +13,3 @@ "node": ">=6.0.0" | ||
"test-verbose": "ava src/js/jssm*-tests.js -v", | ||
"clean": "rimraf build -f && rimraf dist -f", | ||
"clean": "rimraf build -f && rimraf dist -f && rm -f src/js/jssm-dot.js && mkdir build && mkdir dist", | ||
"babel": "babel src/js -d build/", | ||
@@ -19,4 +19,5 @@ "setver": "node ./set_version.js", | ||
"pack": "browserify -r ./build/jssm.es5.js:jssm -o build/jssm.es5.cjs.js", | ||
"make": "npm run clean && npm run babel && npm run rename && npm run setver && npm run pack", | ||
"make": "npm run clean && npm run peg && npm run babel && npm run rename && npm run setver && npm run pack", | ||
"flow": "flow", | ||
"peg": "rm -f src/js/jssm-dot.js && pegjs src/js/jssm-dot.peg && cp src/js/jssm-dot.js build/", | ||
"eslint": "eslint src/js/jssm.js", | ||
@@ -27,3 +28,4 @@ "nyc-html": "nyc ava report --reporter=html", | ||
"audit": "echo \\\"major\\\" remaining. . : `grep major src/js/jssm*.js | wc -l`\\\\n\\\"wasteful\\\" remaining : `grep wasteful src/js/jssm*.js | wc -l`\\\\n\\\"any\\\" remaining. . . : `grep any src/js/jssm*.js | wc -l`\\\\n\\\"mixed\\\" remaining. . : `grep mixed src/js/jssm*.js | wc -l`\\\\n\\\"todo\\\" remaining . . : `grep todo src/js/jssm*.js | wc -l`\\\\n\\\"nextdo\\\" remaining . : `grep nextdo src/js/jssm*.js | wc -l`\\\\n\\\"whargarbl\\\" remaining: `grep whargarbl src/js/jssm*.js | wc -l`\\\\n\\\"comeback\\\" remaining : `grep comeback src/js/jssm*.js | wc -l`\\\\n\\\"fixme\\\" remaining. . : `grep fixme src/js/jssm*.js | wc -l`\\\\n\\\"stochable\\\" remaining: `grep stochable src/js/jssm*.js | wc -l`\\\\n\\\"checkme\\\" remaining. : `grep checkme src/js/jssm*.js | wc -l`", | ||
"build": "npm run vet && npm run make && npm run test-verbose && npm run audit", | ||
"build": "npm run make && npm run vet && npm run test-verbose && npm run audit", | ||
"nyc-build": "npm run vet && npm run make && npm run test-verbose && npm run audit && npm run nyc-test", | ||
"postinstall": "npm run build", | ||
@@ -88,2 +90,3 @@ "prepublish": "npm run build", | ||
"nyc": "^10.3.2", | ||
"pegjs": "^0.10.0", | ||
"rimraf": "^2.6.1", | ||
@@ -90,0 +93,0 @@ "viz.js": "^1.7.1" |
// whargarbl lots of these return arrays could/should be sets | ||
// @flow | ||
@@ -19,2 +21,3 @@ | ||
const parse = require('./jssm-dot.js').parse; | ||
@@ -33,3 +36,3 @@ | ||
_reverse_actions : Map<mNT, Map<mNT, number>>; | ||
//_reverse_action_targets : Map<string, Map<string, mixed>>; // todo // remove mixed todo whargarbl | ||
_reverse_action_targets : Map<string, Map<string, number>>; | ||
@@ -50,3 +53,3 @@ _viz_colors : mixed; | ||
this._reverse_actions = new Map(); | ||
// this._reverse_action_targets = new Map(); // todo | ||
this._reverse_action_targets = new Map(); // todo | ||
@@ -131,4 +134,3 @@ transitions.map( (tr:any) => { // whargarbl burn out any | ||
} | ||
/* | ||
todo comeback | ||
// reverse mapping first by state target name | ||
@@ -139,2 +141,4 @@ if (!(this._reverse_action_targets.has(tr.to))) { | ||
/* todo comeback | ||
fundamental problem is roActionMap needs to be a multimap | ||
const roActionMap = this._reverse_action_targets.get(tr.to); // wasteful - already did has - refactor | ||
@@ -150,4 +154,4 @@ if (roActionMap) { | ||
*/ | ||
} | ||
} | ||
}); | ||
@@ -245,14 +249,16 @@ | ||
list_transitions_for(whichState : mNT) : JssmTransitionList<mNT> { | ||
return {entrances: this.list_entrances_for(whichState), exits: this.list_exits_for(whichState)}; | ||
list_transitions(whichState : mNT = this.state()) : JssmTransitionList<mNT> { | ||
return {entrances: this.list_entrances(whichState), exits: this.list_exits(whichState)}; | ||
} | ||
list_entrances_for(whichState : mNT) : Array<mNT> { | ||
list_entrances(whichState : mNT = this.state()) : Array<mNT> { | ||
return (this._states.get(whichState) || {}).from; // return undefined if it doesn't exist by asking for a member of an empty obj | ||
} | ||
list_exits_for(whichState : mNT) : Array<mNT> { | ||
list_exits(whichState : mNT = this.state()) : Array<mNT> { | ||
return (this._states.get(whichState) || {}).to; | ||
} | ||
probable_exits_for(whichState : mNT) : Array< JssmTransition<mNT, mDT> > { | ||
@@ -265,5 +271,2 @@ | ||
// const wstate_a = ((this._states.get(whichState) || {to: []}).to).map(ws => this.lookup_transition_for(this.state(), ws)); | ||
// if (wstate_a) { return wstate_a.map(ex => this.lookup_transition_for(this.state(), ex) ); } | ||
} | ||
@@ -292,5 +295,5 @@ | ||
actions_for(whichState : mNT) : Array<mNT> { | ||
actions(whichState : mNT = this.state() ) : Array<mNT> { | ||
const wstate = this._reverse_actions.get(whichState); | ||
if (wstate) { return [... (wstate || new Map()).keys()]; } | ||
if (wstate) { return [... wstate.keys()]; } | ||
else { throw new Error(`No such state ${JSON.stringify(whichState)}`); } | ||
@@ -300,7 +303,10 @@ } | ||
list_states_having_action(whichState : mNT) : Array<mNT> { | ||
return [... ((this._actions.get(whichState) || new Map()).keys() || [])]; // wasteful | ||
const wstate = this._actions.get(whichState); | ||
if (wstate) { return [... wstate.keys()]; } | ||
else { throw new Error(`No such state ${JSON.stringify(whichState)}`); } | ||
} | ||
// comeback | ||
/* | ||
todo comeback | ||
action_entrances_at(whichState : string) : Array<mixed> { // whargarbl remove mixed | ||
list_entrance_actions(whichState : mNT = this.state() ) : Array<mNT> { | ||
return [... (this._reverse_action_targets.get(whichState) || new Map()).values()] // wasteful | ||
@@ -312,5 +318,4 @@ .map( (edgeId:any) => (this._edges[edgeId] : any)) // whargarbl burn out any | ||
*/ | ||
list_exit_actions(whichState : mNT = this.state() ) : Array<mNT> { | ||
return [... (this._reverse_actions.get(whichState) || new Map()).values()] // wasteful | ||
return [... (this._reverse_actions.get(whichState) || new Map()).values()] // wasteful, should throw instead | ||
.map ( (edgeId:number) => this._edges[edgeId] ) | ||
@@ -321,4 +326,4 @@ .filter ( (o:JssmTransition<mNT, mDT>) => o.from === whichState ) | ||
probable_action_exits_for(whichState : mNT) : Array<mNT> { | ||
return [... (this._reverse_actions.get(whichState) || new Map()).values()] // wasteful | ||
probable_action_exits(whichState : mNT = this.state() ) : Array<mNT> { | ||
return [... (this._reverse_actions.get(whichState) || new Map()).values()] // wasteful, should throw instead | ||
.map ( (edgeId:number) => this._edges[edgeId] ) | ||
@@ -334,3 +339,3 @@ .filter ( (o:JssmTransition<mNT, mDT>) => o.from === whichState ) | ||
is_unenterable(whichState : mNT) : boolean { | ||
return this.list_entrances_for(whichState).length === 0; | ||
return this.list_entrances(whichState).length === 0; | ||
} | ||
@@ -349,3 +354,3 @@ | ||
state_is_terminal(whichState : mNT) : boolean { | ||
return this.list_exits_for(whichState).length === 0; | ||
return this.list_exits(whichState).length === 0; | ||
} | ||
@@ -352,0 +357,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129641
718
18