-
Notifications
You must be signed in to change notification settings - Fork 21
/
jssm.js
142 lines (84 loc) · 2.6 KB
/
jssm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// @flow
import type { JssmMachine, JssmConfig, JssmTransitions } from './jssm-types';
const version = null; // replaced from package.js in build
const new_machine = (props:mixed) : JssmMachine => {
return {state:'1', transitions: []}; // whargarbl this should not work
};
class machine {
constructor({ transitions } : JssmConfig) {
transitions.map(tr => {
console.log(`hook up ${JSON.stringify(tr)}`);
});
}
state() : string {
return ''; // todo whargarbl
}
machine_state() : mixed {
return {}; // todo whargarbl
}
nodes() : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
transitions() : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
named_transitions() : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
actions() : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
transitions_for(whichNode : string) : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
entrances_for(whichNode : string) : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
exits_for(whichNode : string) : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
actions_for(whichNode : string) : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
action_entrances_for(whichNode : string) : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
action_exits_for(whichNode : string) : Array<mixed> { // todo whargarbl
return []; // todo whargarbl
}
is_unenterable(whichNode : string) : boolean {
return this.entrances_for(whichNode).length === 0;
}
has_unenterables() : boolean {
return this.nodes.some(this.is_unenterable);
}
is_terminal(whichNode : string) : boolean {
return this.exits_for(whichNode).length === 0;
}
has_terminals() : boolean {
return this.nodes.some(this.is_terminal);
}
action(name : string, new_data? : mixed) : boolean {
return false; // todo whargarbl
}
transition(newNode : string, new_data? : mixed) : boolean {
return false; // todo whargarbl
}
force_transition(newNode : string, new_data? : mixed) : boolean {
return false; // todo whargarbl
}
valid_action(action : string, new_data : mixed) : boolean {
return false; // todo whargarbl
}
valid_transition(newNode : string, new_data : mixed) : boolean {
return false; // todo whargarbl
}
valid_force_transition(newNode : string, new_data : mixed) : boolean {
return false; // todo whargarbl
}
}
export {
machine,
new_machine,
version
};