jssm 5.65.8 → 5.65.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ import { version } from './version';
9
9
  * Return the direction of an arrow - `right`, `left`, or `both`.
10
10
  *
11
11
  * ```typescript
12
- * import { arrow_direction } from './jssm';
12
+ * import { arrow_direction } from 'jssm';
13
13
  *
14
14
  * arrow_direction('->'); // 'right'
15
15
  * arrow_direction('<~=>'); // 'both'
@@ -22,7 +22,7 @@ declare function arrow_direction(arrow: JssmArrow): JssmArrowDirection;
22
22
  * Return the direction of an arrow - `right`, `left`, or `both`.
23
23
  *
24
24
  * ```typescript
25
- * import { arrow_left_kind } from './jssm';
25
+ * import { arrow_left_kind } from 'jssm';
26
26
  *
27
27
  * arrow_left_kind('<-'); // 'legal'
28
28
  * arrow_left_kind('<='); // 'main'
@@ -38,7 +38,7 @@ declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
38
38
  * Return the direction of an arrow - `right`, `left`, or `both`.
39
39
  *
40
40
  * ```typescript
41
- * import { arrow_left_kind } from './jssm';
41
+ * import { arrow_left_kind } from 'jssm';
42
42
  *
43
43
  * arrow_left_kind('->'); // 'legal'
44
44
  * arrow_left_kind('=>'); // 'main'
@@ -60,7 +60,7 @@ declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
60
60
  * probably also using {@link compile} and {@link Machine.constructor}.
61
61
  *
62
62
  * ```typescript
63
- * import { parse, compile, Machine } from './jssm';
63
+ * import { parse, compile, Machine } from 'jssm';
64
64
  *
65
65
  * const intermediate = wrap_parse('a -> b;', {});
66
66
  * // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
@@ -85,7 +85,7 @@ declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
85
85
  * Operator {@link sm}:
86
86
  *
87
87
  * ```typescript
88
- * import { sm } from './jssm';
88
+ * import { sm } from 'jssm';
89
89
  *
90
90
  * const switch = sm`on <=> off;`;
91
91
  * ```
@@ -93,7 +93,7 @@ declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
93
93
  * Method {@link from}:
94
94
  *
95
95
  * ```typescript
96
- * import * as jssm from './jssm';
96
+ * import * as jssm from 'jssm';
97
97
  *
98
98
  * const toggle = jssm.from('up <=> down;');
99
99
  * ```
@@ -111,7 +111,7 @@ declare function wrap_parse(input: string, options?: Object): any;
111
111
  * {@link Machine.construct} to turn the config object into a workable machine.
112
112
  *
113
113
  * ```typescript
114
- * import { parse, compile, Machine } from './jssm';
114
+ * import { parse, compile, Machine } from 'jssm';
115
115
  *
116
116
  * const intermediate = parse('a -> b;');
117
117
  * // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
@@ -136,7 +136,7 @@ declare function wrap_parse(input: string, options?: Object): any;
136
136
  * Operator {@link sm}:
137
137
  *
138
138
  * ```typescript
139
- * import { sm } from './jssm';
139
+ * import { sm } from 'jssm';
140
140
  *
141
141
  * const switch = sm`on <=> off;`;
142
142
  * ```
@@ -144,7 +144,7 @@ declare function wrap_parse(input: string, options?: Object): any;
144
144
  * Method {@link from}:
145
145
  *
146
146
  * ```typescript
147
- * import * as jssm from './jssm';
147
+ * import * as jssm from 'jssm';
148
148
  *
149
149
  * const toggle = jssm.from('up <=> down;');
150
150
  * ```
@@ -213,13 +213,18 @@ declare class Machine<mDT> {
213
213
  _forced_transition_hook: HookHandler | undefined;
214
214
  _any_transition_hook: HookHandler | undefined;
215
215
  constructor({ start_states, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name }: JssmGenericConfig<mDT>);
216
+ /********
217
+ *
218
+ * Internal method for fabricating states. Not meant for external use.
219
+ *
220
+ */
216
221
  _new_state(state_config: JssmGenericState): StateType;
217
222
  /*********
218
223
  *
219
224
  * Get the current state of a machine.
220
225
  *
221
226
  * ```typescript
222
- * import * as jssm from './jssm';
227
+ * import * as jssm from 'jssm';
223
228
  *
224
229
  * const switch = jssm.from('on <=> off;');
225
230
  * console.log( switch.state() ); // 'on'
@@ -230,7 +235,38 @@ declare class Machine<mDT> {
230
235
  *
231
236
  */
232
237
  state(): StateType;
238
+ /********
239
+ *
240
+ * Check whether a given state is final (either has no exits or is marked
241
+ * `complete`.)
242
+ *
243
+ * ```typescript
244
+ * import { sm, state_is_final } from 'jssm';
245
+ *
246
+ * const final_test = sm`first -> second;`;
247
+ *
248
+ * console.log( final_test.state_is_final('first') ); // false
249
+ * console.log( final_test.state_is_final('second') ); // true
250
+ * ```
251
+ *
252
+ */
233
253
  state_is_final(whichState: StateType): boolean;
254
+ /********
255
+ *
256
+ * Check whether the current state is final (either has no exits or is marked
257
+ * `complete`.)
258
+ *
259
+ * ```typescript
260
+ * import { sm, state_is_final } from 'jssm';
261
+ *
262
+ * const final_test = sm`first -> second;`;
263
+ *
264
+ * console.log( final_test.is_final() ); // false
265
+ * state.transition('second');
266
+ * console.log( final_test.is_final() ); // true
267
+ * ```
268
+ *
269
+ */
234
270
  is_final(): boolean;
235
271
  graph_layout(): string;
236
272
  dot_preamble(): string;
@@ -253,7 +289,7 @@ declare class Machine<mDT> {
253
289
  * these states is not guaranteed.
254
290
  *
255
291
  * ```typescript
256
- * import * as jssm from './jssm';
292
+ * import * as jssm from 'jssm';
257
293
  *
258
294
  * const switch = jssm.from('on <=> off;');
259
295
  * console.log( switch.states() ); // ['on', 'off']
@@ -267,16 +303,45 @@ declare class Machine<mDT> {
267
303
  * Check whether the machine knows a given state.
268
304
  *
269
305
  * ```typescript
270
- * import * as jssm from './jssm';
306
+ * import * as jssm from 'jssm';
271
307
  *
272
308
  * const switch = jssm.from('on <=> off;');
273
-
309
+ *
274
310
  * console.log( switch.has_state('off') ); // true
275
311
  * console.log( switch.has_state('dance') ); // false
276
312
  * ```
277
313
  *
278
314
  */
279
315
  has_state(whichState: StateType): boolean;
316
+ /*********
317
+ *
318
+ * Lists all edges of a machine.
319
+ *
320
+ * ```typescript
321
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
322
+ *
323
+ * lswitch.list_edges();
324
+ * [
325
+ * {
326
+ * from: 'on',
327
+ * to: 'off',
328
+ * kind: 'main',
329
+ * forced_only: false,
330
+ * main_path: true,
331
+ * action: 'toggle'
332
+ * },
333
+ * {
334
+ * from: 'off',
335
+ * to: 'on',
336
+ * kind: 'main',
337
+ * forced_only: false,
338
+ * main_path: true,
339
+ * action: 'toggle'
340
+ * }
341
+ * ]
342
+ * ```
343
+ *
344
+ */
280
345
  list_edges(): Array<JssmTransition<mDT>>;
281
346
  list_named_transitions(): Map<StateType, number>;
282
347
  list_actions(): Array<StateType>;
@@ -284,14 +349,99 @@ declare class Machine<mDT> {
284
349
  flow(): FslDirection;
285
350
  get_transition_by_state_names(from: StateType, to: StateType): number;
286
351
  lookup_transition_for(from: StateType, to: StateType): JssmTransition<mDT>;
352
+ /********
353
+ *
354
+ * List all transitions attached to the current state, sorted by entrance and
355
+ * exit. The order of each sublist is not defined. A node could appear in
356
+ * both lists.
357
+ *
358
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
359
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
360
+ *
361
+ * light.state(); // 'red'
362
+ * light.list_transitions(); // { entrances: [ 'yellow', 'off' ], exits: [ 'green', 'off' ] }
363
+ *
364
+ */
287
365
  list_transitions(whichState?: StateType): JssmTransitionList;
366
+ /********
367
+ *
368
+ * List all entrances attached to the current state. Please note that the
369
+ * order of the list is not defined.
370
+ *
371
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
372
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
373
+ *
374
+ * light.state(); // 'red'
375
+ * light.list_entrances(); // [ 'yellow', 'off' ]
376
+ *
377
+ */
288
378
  list_entrances(whichState?: StateType): Array<StateType>;
379
+ /********
380
+ *
381
+ * List all exits attached to the current state. Please note that the order
382
+ * of the list is not defined.
383
+ *
384
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
385
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
386
+ *
387
+ * light.state(); // 'red'
388
+ * light.list_exits(); // [ 'green', 'off' ]
389
+ *
390
+ */
289
391
  list_exits(whichState?: StateType): Array<StateType>;
290
392
  probable_exits_for(whichState: StateType): Array<JssmTransition<mDT>>;
291
393
  probabilistic_transition(): boolean;
292
394
  probabilistic_walk(n: number): Array<StateType>;
293
395
  probabilistic_histo_walk(n: number): Map<StateType, number>;
396
+ /********
397
+ *
398
+ * List all actions available from this state. Please note that the order of
399
+ * the actions is not guaranteed.
400
+ *
401
+ * ```typescript
402
+ * import { sm } from 'jssm';
403
+ *
404
+ * const machine = sm`
405
+ * red 'next' -> green 'next' -> yellow 'next' -> red;
406
+ * [red yellow green] 'shutdown' ~> off 'start' -> red;
407
+ * `;
408
+ *
409
+ * console.log( machine.state() ); // logs 'red'
410
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
411
+ *
412
+ * machine.action('next'); // true
413
+ * console.log( machine.state() ); // logs 'green'
414
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
415
+ *
416
+ * machine.action('shutdown'); // true
417
+ * console.log( machine.state() ); // logs 'off'
418
+ * console.log( machine.actions() ); // logs ['start']
419
+ *
420
+ * machine.action('start'); // true
421
+ * console.log( machine.state() ); // logs 'red'
422
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
423
+ * ```
424
+ *
425
+ */
294
426
  actions(whichState?: StateType): Array<StateType>;
427
+ /********
428
+ *
429
+ * List all states that have a specific action attached. Please note that
430
+ * the order of the states is not guaranteed.
431
+ *
432
+ * ```typescript
433
+ * import { sm } from 'jssm';
434
+ *
435
+ * const machine = sm`
436
+ * red 'next' -> green 'next' -> yellow 'next' -> red;
437
+ * [red yellow green] 'shutdown' ~> off 'start' -> red;
438
+ * `;
439
+ *
440
+ * console.log( machine.list_states_having_action('next') ); // ['red', 'green', 'yellow']
441
+ * console.log( machine.list_states_having_action('start') ); // ['off']
442
+ * ```
443
+ *
444
+ */
295
445
  list_states_having_action(whichState: StateType): Array<StateType>;
296
446
  list_exit_actions(whichState?: StateType): Array<StateType>;
297
447
  probable_action_exits(whichState?: StateType): Array<any>;
@@ -338,7 +488,7 @@ declare class Machine<mDT> {
338
488
  *
339
489
  *
340
490
  * ```typescript
341
- * import * as jssm from './jssm';
491
+ * import * as jssm from 'jssm';
342
492
  *
343
493
  * const switch = jssm.from('on <=> off;');
344
494
  * ```
@@ -355,7 +505,7 @@ declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: a
355
505
  * template expression.
356
506
  *
357
507
  * ```typescript
358
- * import * as jssm from './jssm';
508
+ * import * as jssm from 'jssm';
359
509
  *
360
510
  * const switch = jssm.from('on <=> off;');
361
511
  * ```
package/dist/es6/jssm.js CHANGED
@@ -11,7 +11,7 @@ import { JssmError } from './jssm_error';
11
11
  * Return the direction of an arrow - `right`, `left`, or `both`.
12
12
  *
13
13
  * ```typescript
14
- * import { arrow_direction } from './jssm';
14
+ * import { arrow_direction } from 'jssm';
15
15
  *
16
16
  * arrow_direction('->'); // 'right'
17
17
  * arrow_direction('<~=>'); // 'both'
@@ -76,7 +76,7 @@ function arrow_direction(arrow) {
76
76
  * Return the direction of an arrow - `right`, `left`, or `both`.
77
77
  *
78
78
  * ```typescript
79
- * import { arrow_left_kind } from './jssm';
79
+ * import { arrow_left_kind } from 'jssm';
80
80
  *
81
81
  * arrow_left_kind('<-'); // 'legal'
82
82
  * arrow_left_kind('<='); // 'main'
@@ -133,7 +133,7 @@ function arrow_left_kind(arrow) {
133
133
  * Return the direction of an arrow - `right`, `left`, or `both`.
134
134
  *
135
135
  * ```typescript
136
- * import { arrow_left_kind } from './jssm';
136
+ * import { arrow_left_kind } from 'jssm';
137
137
  *
138
138
  * arrow_left_kind('->'); // 'legal'
139
139
  * arrow_left_kind('=>'); // 'main'
@@ -231,7 +231,7 @@ function makeTransition(this_se, from, to, isRight, _wasList, _wasIndex) {
231
231
  * probably also using {@link compile} and {@link Machine.constructor}.
232
232
  *
233
233
  * ```typescript
234
- * import { parse, compile, Machine } from './jssm';
234
+ * import { parse, compile, Machine } from 'jssm';
235
235
  *
236
236
  * const intermediate = wrap_parse('a -> b;', {});
237
237
  * // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
@@ -256,7 +256,7 @@ function makeTransition(this_se, from, to, isRight, _wasList, _wasIndex) {
256
256
  * Operator {@link sm}:
257
257
  *
258
258
  * ```typescript
259
- * import { sm } from './jssm';
259
+ * import { sm } from 'jssm';
260
260
  *
261
261
  * const switch = sm`on <=> off;`;
262
262
  * ```
@@ -264,7 +264,7 @@ function makeTransition(this_se, from, to, isRight, _wasList, _wasIndex) {
264
264
  * Method {@link from}:
265
265
  *
266
266
  * ```typescript
267
- * import * as jssm from './jssm';
267
+ * import * as jssm from 'jssm';
268
268
  *
269
269
  * const toggle = jssm.from('up <=> down;');
270
270
  * ```
@@ -356,7 +356,7 @@ function compile_rule_handler(rule) {
356
356
  * {@link Machine.construct} to turn the config object into a workable machine.
357
357
  *
358
358
  * ```typescript
359
- * import { parse, compile, Machine } from './jssm';
359
+ * import { parse, compile, Machine } from 'jssm';
360
360
  *
361
361
  * const intermediate = parse('a -> b;');
362
362
  * // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
@@ -381,7 +381,7 @@ function compile_rule_handler(rule) {
381
381
  * Operator {@link sm}:
382
382
  *
383
383
  * ```typescript
384
- * import { sm } from './jssm';
384
+ * import { sm } from 'jssm';
385
385
  *
386
386
  * const switch = sm`on <=> off;`;
387
387
  * ```
@@ -389,7 +389,7 @@ function compile_rule_handler(rule) {
389
389
  * Method {@link from}:
390
390
  *
391
391
  * ```typescript
392
- * import * as jssm from './jssm';
392
+ * import * as jssm from 'jssm';
393
393
  *
394
394
  * const toggle = jssm.from('up <=> down;');
395
395
  * ```
@@ -643,6 +643,11 @@ class Machine {
643
643
  }
644
644
  });
645
645
  }
646
+ /********
647
+ *
648
+ * Internal method for fabricating states. Not meant for external use.
649
+ *
650
+ */
646
651
  _new_state(state_config) {
647
652
  if (this._states.has(state_config.name)) {
648
653
  throw new JssmError(this, `state ${JSON.stringify(state_config.name)} already exists`);
@@ -655,7 +660,7 @@ class Machine {
655
660
  * Get the current state of a machine.
656
661
  *
657
662
  * ```typescript
658
- * import * as jssm from './jssm';
663
+ * import * as jssm from 'jssm';
659
664
  *
660
665
  * const switch = jssm.from('on <=> off;');
661
666
  * console.log( switch.state() ); // 'on'
@@ -675,9 +680,40 @@ class Machine {
675
680
  return true; // todo whargarbl
676
681
  }
677
682
  */
683
+ /********
684
+ *
685
+ * Check whether a given state is final (either has no exits or is marked
686
+ * `complete`.)
687
+ *
688
+ * ```typescript
689
+ * import { sm, state_is_final } from 'jssm';
690
+ *
691
+ * const final_test = sm`first -> second;`;
692
+ *
693
+ * console.log( final_test.state_is_final('first') ); // false
694
+ * console.log( final_test.state_is_final('second') ); // true
695
+ * ```
696
+ *
697
+ */
678
698
  state_is_final(whichState) {
679
699
  return ((this.state_is_terminal(whichState)) && (this.state_is_complete(whichState)));
680
700
  }
701
+ /********
702
+ *
703
+ * Check whether the current state is final (either has no exits or is marked
704
+ * `complete`.)
705
+ *
706
+ * ```typescript
707
+ * import { sm, state_is_final } from 'jssm';
708
+ *
709
+ * const final_test = sm`first -> second;`;
710
+ *
711
+ * console.log( final_test.is_final() ); // false
712
+ * state.transition('second');
713
+ * console.log( final_test.is_final() ); // true
714
+ * ```
715
+ *
716
+ */
681
717
  is_final() {
682
718
  // return ((!this.is_changing()) && this.state_is_final(this.state()));
683
719
  return this.state_is_final(this.state());
@@ -748,7 +784,7 @@ class Machine {
748
784
  * these states is not guaranteed.
749
785
  *
750
786
  * ```typescript
751
- * import * as jssm from './jssm';
787
+ * import * as jssm from 'jssm';
752
788
  *
753
789
  * const switch = jssm.from('on <=> off;');
754
790
  * console.log( switch.states() ); // ['on', 'off']
@@ -772,10 +808,10 @@ class Machine {
772
808
  * Check whether the machine knows a given state.
773
809
  *
774
810
  * ```typescript
775
- * import * as jssm from './jssm';
811
+ * import * as jssm from 'jssm';
776
812
  *
777
813
  * const switch = jssm.from('on <=> off;');
778
-
814
+ *
779
815
  * console.log( switch.has_state('off') ); // true
780
816
  * console.log( switch.has_state('dance') ); // false
781
817
  * ```
@@ -784,6 +820,35 @@ class Machine {
784
820
  has_state(whichState) {
785
821
  return this._states.get(whichState) !== undefined;
786
822
  }
823
+ /*********
824
+ *
825
+ * Lists all edges of a machine.
826
+ *
827
+ * ```typescript
828
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
829
+ *
830
+ * lswitch.list_edges();
831
+ * [
832
+ * {
833
+ * from: 'on',
834
+ * to: 'off',
835
+ * kind: 'main',
836
+ * forced_only: false,
837
+ * main_path: true,
838
+ * action: 'toggle'
839
+ * },
840
+ * {
841
+ * from: 'off',
842
+ * to: 'on',
843
+ * kind: 'main',
844
+ * forced_only: false,
845
+ * main_path: true,
846
+ * action: 'toggle'
847
+ * }
848
+ * ]
849
+ * ```
850
+ *
851
+ */
787
852
  list_edges() {
788
853
  return this._edges;
789
854
  }
@@ -812,14 +877,51 @@ class Machine {
812
877
  const id = this.get_transition_by_state_names(from, to);
813
878
  return ((id === undefined) || (id === null)) ? undefined : this._edges[id];
814
879
  }
880
+ /********
881
+ *
882
+ * List all transitions attached to the current state, sorted by entrance and
883
+ * exit. The order of each sublist is not defined. A node could appear in
884
+ * both lists.
885
+ *
886
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
887
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
888
+ *
889
+ * light.state(); // 'red'
890
+ * light.list_transitions(); // { entrances: [ 'yellow', 'off' ], exits: [ 'green', 'off' ] }
891
+ *
892
+ */
815
893
  list_transitions(whichState = this.state()) {
816
894
  return { entrances: this.list_entrances(whichState), exits: this.list_exits(whichState) };
817
895
  }
896
+ /********
897
+ *
898
+ * List all entrances attached to the current state. Please note that the
899
+ * order of the list is not defined.
900
+ *
901
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
902
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
903
+ *
904
+ * light.state(); // 'red'
905
+ * light.list_entrances(); // [ 'yellow', 'off' ]
906
+ *
907
+ */
818
908
  list_entrances(whichState = this.state()) {
819
909
  return (this._states.get(whichState)
820
910
  || { from: undefined }).from
821
911
  || [];
822
912
  }
913
+ /********
914
+ *
915
+ * List all exits attached to the current state. Please note that the order
916
+ * of the list is not defined.
917
+ *
918
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
919
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
920
+ *
921
+ * light.state(); // 'red'
922
+ * light.list_exits(); // [ 'green', 'off' ]
923
+ *
924
+ */
823
925
  list_exits(whichState = this.state()) {
824
926
  return (this._states.get(whichState)
825
927
  || { to: undefined }).to
@@ -851,6 +953,36 @@ class Machine {
851
953
  probabilistic_histo_walk(n) {
852
954
  return histograph(this.probabilistic_walk(n));
853
955
  }
956
+ /********
957
+ *
958
+ * List all actions available from this state. Please note that the order of
959
+ * the actions is not guaranteed.
960
+ *
961
+ * ```typescript
962
+ * import { sm } from 'jssm';
963
+ *
964
+ * const machine = sm`
965
+ * red 'next' -> green 'next' -> yellow 'next' -> red;
966
+ * [red yellow green] 'shutdown' ~> off 'start' -> red;
967
+ * `;
968
+ *
969
+ * console.log( machine.state() ); // logs 'red'
970
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
971
+ *
972
+ * machine.action('next'); // true
973
+ * console.log( machine.state() ); // logs 'green'
974
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
975
+ *
976
+ * machine.action('shutdown'); // true
977
+ * console.log( machine.state() ); // logs 'off'
978
+ * console.log( machine.actions() ); // logs ['start']
979
+ *
980
+ * machine.action('start'); // true
981
+ * console.log( machine.state() ); // logs 'red'
982
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
983
+ * ```
984
+ *
985
+ */
854
986
  actions(whichState = this.state()) {
855
987
  const wstate = this._reverse_actions.get(whichState);
856
988
  if (wstate) {
@@ -860,6 +992,24 @@ class Machine {
860
992
  throw new JssmError(this, `No such state ${JSON.stringify(whichState)}`);
861
993
  }
862
994
  }
995
+ /********
996
+ *
997
+ * List all states that have a specific action attached. Please note that
998
+ * the order of the states is not guaranteed.
999
+ *
1000
+ * ```typescript
1001
+ * import { sm } from 'jssm';
1002
+ *
1003
+ * const machine = sm`
1004
+ * red 'next' -> green 'next' -> yellow 'next' -> red;
1005
+ * [red yellow green] 'shutdown' ~> off 'start' -> red;
1006
+ * `;
1007
+ *
1008
+ * console.log( machine.list_states_having_action('next') ); // ['red', 'green', 'yellow']
1009
+ * console.log( machine.list_states_having_action('start') ); // ['off']
1010
+ * ```
1011
+ *
1012
+ */
863
1013
  list_states_having_action(whichState) {
864
1014
  const wstate = this._actions.get(whichState);
865
1015
  if (wstate) {
@@ -1252,7 +1402,7 @@ class Machine {
1252
1402
  *
1253
1403
  *
1254
1404
  * ```typescript
1255
- * import * as jssm from './jssm';
1405
+ * import * as jssm from 'jssm';
1256
1406
  *
1257
1407
  * const switch = jssm.from('on <=> off;');
1258
1408
  * ```
@@ -1281,7 +1431,7 @@ function sm(template_strings, ...remainder /* , arguments */) {
1281
1431
  * template expression.
1282
1432
  *
1283
1433
  * ```typescript
1284
- * import * as jssm from './jssm';
1434
+ * import * as jssm from 'jssm';
1285
1435
  *
1286
1436
  * const switch = jssm.from('on <=> off;');
1287
1437
  * ```
@@ -1,2 +1,2 @@
1
- const version = "5.65.8";
1
+ const version = "5.65.11";
2
2
  export { version };