Skip to content

Commit 0800aed

Browse files
author
b
committed
chore(refactor): simplified history maps
1 parent 16aedfe commit 0800aed

File tree

4 files changed

+18
-27
lines changed

4 files changed

+18
-27
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "kingly",
33
"sideEffects": false,
4-
"version": "0.24.0",
4+
"version": "0.24.1",
55
"description": "Extended Hierarchical State Transducer library",
66
"repository": {
77
"type": "git",

src/helpers.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export function computeHistoryMaps(control_states) {
376376
const {getLabel, isLeafLabel} = objectTreeLenses;
377377
const traverse = {
378378
strategy: PRE_ORDER,
379-
seed: {stateList: [], stateAncestors: {[DEEP]: {}, [SHALLOW]: {}}},
379+
seed: {stateList: [], stateAncestors: {}},
380380
visit: (acc, traversalState, tree) => {
381381
const treeLabel = getLabel(tree);
382382
const controlState = Object.keys(treeLabel)[0];
@@ -393,7 +393,7 @@ export function computeHistoryMaps(control_states) {
393393
}
394394
else {
395395
const parentControlState = traversalState.get(JSON.stringify(parentPath));
396-
acc.stateAncestors[SHALLOW][controlState] = [parentControlState];
396+
acc.stateAncestors[controlState] = [parentControlState];
397397

398398
const {ancestors} = path.reduce((acc, _) => {
399399
const parentPath = acc.path.slice(0, -1);
@@ -405,7 +405,7 @@ export function computeHistoryMaps(control_states) {
405405

406406
return acc
407407
}, {ancestors: [], path});
408-
acc.stateAncestors[DEEP][controlState] = ancestors;
408+
acc.stateAncestors[controlState] = ancestors;
409409
}
410410

411411
return acc
@@ -554,7 +554,7 @@ export function updateHistory(history, stateAncestors, state_from_name) {
554554
}
555555
else {
556556
// ancestors for the state which is exited
557-
const ancestors = stateAncestors[DEEP][state_from_name] || [];
557+
const ancestors = stateAncestors[state_from_name] || [];
558558
ancestors.reduce((oldAncestor, newAncestor) => {
559559
// set the exited state in the history of all ancestors
560560
history[DEEP][newAncestor] = state_from_name;

test/index.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// import './no-hierarchy.specs'
2-
// import './no-hierarchy-with-init-control-state-specs'
3-
// import "./convert-to-plantuml.specs"
4-
// import "./online_visualizer_translation.specs"
5-
// import "./fsm_trace.specs"
6-
// import "./utils.specs"
7-
// import './hierarchy.specs'
8-
// import './debug-settings-specs'
9-
// import './contracts.specs'
10-
// import './entry-actions.specs'
11-
// import './errors-specs'
12-
// import './contracts.ad-hoc.specs'
13-
// import './issue-4.specs'
1+
import './no-hierarchy.specs'
2+
import './no-hierarchy-with-init-control-state-specs'
3+
import "./convert-to-plantuml.specs"
4+
import "./online_visualizer_translation.specs"
5+
import "./fsm_trace.specs"
6+
import "./utils.specs"
7+
import './hierarchy.specs'
8+
import './debug-settings-specs'
9+
import './contracts.specs'
10+
import './entry-actions.specs'
11+
import './errors-specs'
12+
import './contracts.ad-hoc.specs'
13+
import './issue-4.specs'
1414
import './issue-5.specs'
1515
QUnit.dump.maxDepth = 50;

test/utils.specs.js

-9
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ QUnit.test("states with hierarchy", function exec_test(assert) {
277277
const history = computeHistoryMaps(states);
278278
assert.deepEqual(history, {
279279
"stateAncestors": {
280-
"deep": {
281280
"INNER": [
282281
"OUTER"
283282
],
@@ -295,14 +294,6 @@ QUnit.test("states with hierarchy", function exec_test(assert) {
295294
"outer_b": [
296295
"OUTER"
297296
]
298-
},
299-
"shallow": {
300-
"INNER": ["OUTER"],
301-
"inner_s": ["INNER"],
302-
"inner_t": ["INNER"],
303-
"outer_a": ["OUTER"],
304-
"outer_b": ["OUTER"]
305-
}
306297
},
307298
"stateList": [
308299
"OUTER",

0 commit comments

Comments
 (0)