jssm 5.65.10 → 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.
@@ -313,6 +313,35 @@ declare class Machine<mDT> {
313
313
  *
314
314
  */
315
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
+ */
316
345
  list_edges(): Array<JssmTransition<mDT>>;
317
346
  list_named_transitions(): Map<StateType, number>;
318
347
  list_actions(): Array<StateType>;
@@ -320,8 +349,45 @@ declare class Machine<mDT> {
320
349
  flow(): FslDirection;
321
350
  get_transition_by_state_names(from: StateType, to: StateType): number;
322
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
+ */
323
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
+ */
324
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
+ */
325
391
  list_exits(whichState?: StateType): Array<StateType>;
326
392
  probable_exits_for(whichState: StateType): Array<JssmTransition<mDT>>;
327
393
  probabilistic_transition(): boolean;
package/dist/es6/jssm.js CHANGED
@@ -820,6 +820,35 @@ class Machine {
820
820
  has_state(whichState) {
821
821
  return this._states.get(whichState) !== undefined;
822
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
+ */
823
852
  list_edges() {
824
853
  return this._edges;
825
854
  }
@@ -848,14 +877,51 @@ class Machine {
848
877
  const id = this.get_transition_by_state_names(from, to);
849
878
  return ((id === undefined) || (id === null)) ? undefined : this._edges[id];
850
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
+ */
851
893
  list_transitions(whichState = this.state()) {
852
894
  return { entrances: this.list_entrances(whichState), exits: this.list_exits(whichState) };
853
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
+ */
854
908
  list_entrances(whichState = this.state()) {
855
909
  return (this._states.get(whichState)
856
910
  || { from: undefined }).from
857
911
  || [];
858
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
+ */
859
925
  list_exits(whichState = this.state()) {
860
926
  return (this._states.get(whichState)
861
927
  || { to: undefined }).to
@@ -1,2 +1,2 @@
1
- const version = "5.65.10";
1
+ const version = "5.65.11";
2
2
  export { version };