jssm 5.65.11 → 5.65.12

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.
@@ -318,28 +318,30 @@ declare class Machine<mDT> {
318
318
  * Lists all edges of a machine.
319
319
  *
320
320
  * ```typescript
321
+ * import { sm } from 'jssm';
322
+ *
321
323
  * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
322
324
  *
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
- * ```
325
+ * lswitch.list_edges();
326
+ * [
327
+ * {
328
+ * from: 'on',
329
+ * to: 'off',
330
+ * kind: 'main',
331
+ * forced_only: false,
332
+ * main_path: true,
333
+ * action: 'toggle'
334
+ * },
335
+ * {
336
+ * from: 'off',
337
+ * to: 'on',
338
+ * kind: 'main',
339
+ * forced_only: false,
340
+ * main_path: true,
341
+ * action: 'toggle'
342
+ * }
343
+ * ]
344
+ * ```
343
345
  *
344
346
  */
345
347
  list_edges(): Array<JssmTransition<mDT>>;
@@ -355,11 +357,14 @@ declare class Machine<mDT> {
355
357
  * exit. The order of each sublist is not defined. A node could appear in
356
358
  * both lists.
357
359
  *
358
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
360
+ * ```typescript
361
+ * import { sm } from 'jssm';
362
+ *
359
363
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
360
364
  *
361
365
  * light.state(); // 'red'
362
366
  * light.list_transitions(); // { entrances: [ 'yellow', 'off' ], exits: [ 'green', 'off' ] }
367
+ * ```
363
368
  *
364
369
  */
365
370
  list_transitions(whichState?: StateType): JssmTransitionList;
@@ -368,11 +373,14 @@ declare class Machine<mDT> {
368
373
  * List all entrances attached to the current state. Please note that the
369
374
  * order of the list is not defined.
370
375
  *
371
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
376
+ * ```typescript
377
+ * import { sm } from 'jssm';
378
+ *
372
379
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
373
380
  *
374
381
  * light.state(); // 'red'
375
382
  * light.list_entrances(); // [ 'yellow', 'off' ]
383
+ * ```
376
384
  *
377
385
  */
378
386
  list_entrances(whichState?: StateType): Array<StateType>;
@@ -381,11 +389,14 @@ declare class Machine<mDT> {
381
389
  * List all exits attached to the current state. Please note that the order
382
390
  * of the list is not defined.
383
391
  *
384
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
392
+ * ```typescript
393
+ * import { sm } from 'jssm';
394
+ *
385
395
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
386
396
  *
387
397
  * light.state(); // 'red'
388
398
  * light.list_exits(); // [ 'green', 'off' ]
399
+ * ```
389
400
  *
390
401
  */
391
402
  list_exits(whichState?: StateType): Array<StateType>;
@@ -466,8 +477,50 @@ declare class Machine<mDT> {
466
477
  hook_exit(from: string, handler: HookHandler): Machine<mDT>;
467
478
  edges_between(from: string, to: string): JssmTransition<mDT>[];
468
479
  transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
480
+ /********
481
+ *
482
+ * Instruct the machine to complete an action.
483
+ *
484
+ * ```typescript
485
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
486
+ *
487
+ * light.state(); // 'red'
488
+ * light.action('next'); // true
489
+ * light.state(); // 'green'
490
+ * ```
491
+ *
492
+ */
469
493
  action(actionName: StateType, newData?: mDT): boolean;
494
+ /********
495
+ *
496
+ * Instruct the machine to complete a transition.
497
+ *
498
+ * ```typescript
499
+ * const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
500
+ *
501
+ * light.state(); // 'red'
502
+ * light.transition('green'); // true
503
+ * light.state(); // 'green'
504
+ * ```
505
+ *
506
+ */
470
507
  transition(newState: StateType, newData?: mDT): boolean;
508
+ /********
509
+ *
510
+ * Instruct the machine to complete a forced transition (which will reject if
511
+ * called with a normal {@link transition} call.)
512
+ *
513
+ * ```typescript
514
+ * const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
515
+ *
516
+ * light.state(); // 'red'
517
+ * light.transition('off'); // false
518
+ * light.state(); // 'red'
519
+ * light.force_transition('off'); // true
520
+ * light.state(); // 'off'
521
+ * ```
522
+ *
523
+ */
471
524
  force_transition(newState: StateType, newData?: mDT): boolean;
472
525
  current_action_for(action: StateType): number;
473
526
  current_action_edge_for(action: StateType): JssmTransition<mDT>;
package/dist/es6/jssm.js CHANGED
@@ -825,28 +825,30 @@ class Machine {
825
825
  * Lists all edges of a machine.
826
826
  *
827
827
  * ```typescript
828
+ * import { sm } from 'jssm';
829
+ *
828
830
  * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
829
831
  *
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
- * ```
832
+ * lswitch.list_edges();
833
+ * [
834
+ * {
835
+ * from: 'on',
836
+ * to: 'off',
837
+ * kind: 'main',
838
+ * forced_only: false,
839
+ * main_path: true,
840
+ * action: 'toggle'
841
+ * },
842
+ * {
843
+ * from: 'off',
844
+ * to: 'on',
845
+ * kind: 'main',
846
+ * forced_only: false,
847
+ * main_path: true,
848
+ * action: 'toggle'
849
+ * }
850
+ * ]
851
+ * ```
850
852
  *
851
853
  */
852
854
  list_edges() {
@@ -883,11 +885,14 @@ class Machine {
883
885
  * exit. The order of each sublist is not defined. A node could appear in
884
886
  * both lists.
885
887
  *
886
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
888
+ * ```typescript
889
+ * import { sm } from 'jssm';
890
+ *
887
891
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
888
892
  *
889
893
  * light.state(); // 'red'
890
894
  * light.list_transitions(); // { entrances: [ 'yellow', 'off' ], exits: [ 'green', 'off' ] }
895
+ * ```
891
896
  *
892
897
  */
893
898
  list_transitions(whichState = this.state()) {
@@ -898,11 +903,14 @@ class Machine {
898
903
  * List all entrances attached to the current state. Please note that the
899
904
  * order of the list is not defined.
900
905
  *
901
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
906
+ * ```typescript
907
+ * import { sm } from 'jssm';
908
+ *
902
909
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
903
910
  *
904
911
  * light.state(); // 'red'
905
912
  * light.list_entrances(); // [ 'yellow', 'off' ]
913
+ * ```
906
914
  *
907
915
  */
908
916
  list_entrances(whichState = this.state()) {
@@ -915,11 +923,14 @@ class Machine {
915
923
  * List all exits attached to the current state. Please note that the order
916
924
  * of the list is not defined.
917
925
  *
918
- * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
926
+ * ```typescript
927
+ * import { sm } from 'jssm';
928
+ *
919
929
  * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
920
930
  *
921
931
  * light.state(); // 'red'
922
932
  * light.list_exits(); // [ 'green', 'off' ]
933
+ * ```
923
934
  *
924
935
  */
925
936
  list_exits(whichState = this.state()) {
@@ -1337,13 +1348,54 @@ class Machine {
1337
1348
  return false;
1338
1349
  }
1339
1350
  }
1351
+ /********
1352
+ *
1353
+ * Instruct the machine to complete an action.
1354
+ *
1355
+ * ```typescript
1356
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1357
+ *
1358
+ * light.state(); // 'red'
1359
+ * light.action('next'); // true
1360
+ * light.state(); // 'green'
1361
+ * ```
1362
+ *
1363
+ */
1340
1364
  action(actionName, newData) {
1341
1365
  return this.transition_impl(actionName, newData, false, true);
1342
1366
  }
1367
+ /********
1368
+ *
1369
+ * Instruct the machine to complete a transition.
1370
+ *
1371
+ * ```typescript
1372
+ * const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1373
+ *
1374
+ * light.state(); // 'red'
1375
+ * light.transition('green'); // true
1376
+ * light.state(); // 'green'
1377
+ * ```
1378
+ *
1379
+ */
1343
1380
  transition(newState, newData) {
1344
1381
  return this.transition_impl(newState, newData, false, false);
1345
1382
  }
1346
- // can leave machine in inconsistent state. generally do not use
1383
+ /********
1384
+ *
1385
+ * Instruct the machine to complete a forced transition (which will reject if
1386
+ * called with a normal {@link transition} call.)
1387
+ *
1388
+ * ```typescript
1389
+ * const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1390
+ *
1391
+ * light.state(); // 'red'
1392
+ * light.transition('off'); // false
1393
+ * light.state(); // 'red'
1394
+ * light.force_transition('off'); // true
1395
+ * light.state(); // 'off'
1396
+ * ```
1397
+ *
1398
+ */
1347
1399
  force_transition(newState, newData) {
1348
1400
  return this.transition_impl(newState, newData, true, false);
1349
1401
  }
@@ -1,2 +1,2 @@
1
- const version = "5.65.11";
1
+ const version = "5.65.12";
2
2
  export { version };