diff --git a/CHANGELOG.long.md b/CHANGELOG.long.md index 6bcbc939..445c3d47 100644 --- a/CHANGELOG.long.md +++ b/CHANGELOG.long.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -1030 merges; 5 releases +1032 merges; 5 releases @@ -18,6 +18,36 @@ Published tags: +  + +  + +## [Untagged] - 9/1/2022 6:08:10 PM + +Commit [1f69c53f4d3851f205896c446c65e9ecdbf26bbc](https://github.com/StoneCypher/jssm/commit/1f69c53f4d3851f205896c446c65e9ecdbf26bbc) + +Author: `Vat Raghavan ` + + * all example links are inline-d + + + + +  + +  + +## [Untagged] - 9/1/2022 6:04:35 PM + +Commit [a307163e979abf8af53e4936f972c017f91198ba](https://github.com/StoneCypher/jssm/commit/a307163e979abf8af53e4936f972c017f91198ba) + +Author: `John Haugeland ` + + * add spurious single type return to theme getter to agree with the setter type, fixes StoneCypher/fsl#1189 + + + +     diff --git a/CHANGELOG.md b/CHANGELOG.md index 2384621b..14e73fd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -1030 merges; 5 releases; Changlogging the last 10 commits; Full changelog at [CHANGELOG.long.md](CHANGELOG.long.md) +1032 merges; 5 releases; Changlogging the last 10 commits; Full changelog at [CHANGELOG.long.md](CHANGELOG.long.md) @@ -18,6 +18,36 @@ Published tags: +  + +  + +## [Untagged] - 9/1/2022 6:08:10 PM + +Commit [1f69c53f4d3851f205896c446c65e9ecdbf26bbc](https://github.com/StoneCypher/jssm/commit/1f69c53f4d3851f205896c446c65e9ecdbf26bbc) + +Author: `Vat Raghavan ` + + * all example links are inline-d + + + + +  + +  + +## [Untagged] - 9/1/2022 6:04:35 PM + +Commit [a307163e979abf8af53e4936f972c017f91198ba](https://github.com/StoneCypher/jssm/commit/a307163e979abf8af53e4936f972c017f91198ba) + +Author: `John Haugeland ` + + * add spurious single type return to theme getter to agree with the setter type, fixes StoneCypher/fsl#1189 + + + +     @@ -142,34 +172,4 @@ Author: `Vat Raghavan ` Merges [9e18022, 7e48176] - * WIP on feature/new-readme: 9e18022 more-readable README - - - - -  - -  - -## [Untagged] - 9/1/2022 4:37:55 PM - -Commit [7e481765d45ab7950adabfc11d98b866baa71ec5](https://github.com/StoneCypher/jssm/commit/7e481765d45ab7950adabfc11d98b866baa71ec5) - -Author: `Vat Raghavan ` - - * index on feature/new-readme: 9e18022 more-readable README - - - - -  - -  - -## [Untagged] - 9/1/2022 4:17:04 PM - -Commit [da69e65ee5a1567825b011d3e17655c2dbd6261d](https://github.com/StoneCypher/jssm/commit/da69e65ee5a1567825b011d3e17655c2dbd6261d) - -Author: `John Haugeland ` - - * re-enable stoch testing, fixes StoneCypher/fsl#1187; replace .replaceAll with .replace, fixes StoneCypher/fsl#1188 \ No newline at end of file + * WIP on feature/new-readme: 9e18022 more-readable README \ No newline at end of file diff --git a/README.md b/README.md index 35aaee2d..658a409d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Please edit the file it's derived from, instead: `./src/md/readme_base.md` -* Generated for version 5.82.5 at 9/1/2022, 6:07:12 PM +* Generated for version 5.82.5 at 9/1/2022, 6:40:00 PM --> # jssm diff --git a/dist/es6/jssm.d.ts b/dist/es6/jssm.d.ts index 8e47f317..2c7589cf 100644 --- a/dist/es6/jssm.d.ts +++ b/dist/es6/jssm.d.ts @@ -626,7 +626,7 @@ declare class Machine { list_named_transitions(): Map; list_actions(): Array; all_themes(): FslTheme[]; - get themes(): FslTheme[]; + get themes(): FslTheme | FslTheme[]; set themes(to: FslTheme | FslTheme[]); flow(): FslDirection; get_transition_by_state_names(from: StateType, to: StateType): number; diff --git a/dist/es6/jssm.js b/dist/es6/jssm.js index 26c9453f..3631daa0 100644 --- a/dist/es6/jssm.js +++ b/dist/es6/jssm.js @@ -1393,6 +1393,9 @@ class Machine { all_themes() { return [...theme_mapping.keys()]; // constructor sets this to "default" otherwise } + // This will always return an array of FSL themes; the reason we spuriously + // add the single type is that the setter and getter need matching accept/return + // types, and the setter can take both as a convenience get themes() { return this._themes; // constructor sets this to "default" otherwise } diff --git a/dist/jssm.es5.cjs.nonmin.js b/dist/jssm.es5.cjs.nonmin.js index 85f7da65..ed792b5a 100644 --- a/dist/jssm.es5.cjs.nonmin.js +++ b/dist/jssm.es5.cjs.nonmin.js @@ -20616,6 +20616,9 @@ class Machine { all_themes() { return [...theme_mapping.keys()]; // constructor sets this to "default" otherwise } + // This will always return an array of FSL themes; the reason we spuriously + // add the single type is that the setter and getter need matching accept/return + // types, and the setter can take both as a convenience get themes() { return this._themes; // constructor sets this to "default" otherwise } diff --git a/dist/jssm.es5.iife.nonmin.js b/dist/jssm.es5.iife.nonmin.js index c5fd48d0..ab606005 100644 --- a/dist/jssm.es5.iife.nonmin.js +++ b/dist/jssm.es5.iife.nonmin.js @@ -20615,6 +20615,9 @@ var jssm = (function (exports) { all_themes() { return [...theme_mapping.keys()]; // constructor sets this to "default" otherwise } + // This will always return an array of FSL themes; the reason we spuriously + // add the single type is that the setter and getter need matching accept/return + // types, and the setter can take both as a convenience get themes() { return this._themes; // constructor sets this to "default" otherwise } diff --git a/docs/docs/classes/jssm.Machine.html b/docs/docs/classes/jssm.Machine.html index ee6ae84b..79ff2cb4 100644 --- a/docs/docs/classes/jssm.Machine.html +++ b/docs/docs/classes/jssm.Machine.html @@ -1,10 +1,10 @@ -Machine | JSSM, a JavaScript state machine - the FSM for FSL
Options
All
  • Public
  • Public/Protected
  • All
Menu

Type Parameters

  • mDT

Hierarchy

  • Machine

Index

Constructors

Properties

Accessors

Methods

Constructors

Properties

_actions: Map<string, Map<string, number>>
_active_state_style: Partial<JssmStateDeclaration>
_any_action_hook: HookHandler<mDT>
_any_transition_hook: HookHandler<mDT>
_arrange_declaration: string[][]
_arrange_end_declaration: string[][]
_arrange_start_declaration: string[][]
_data?: mDT
_default_properties: Map<string, any>
_dot_preamble: string
_edge_map: Map<string, Map<string, number>>
_edges: JssmTransition<mDT>[]
_end_state_style: Partial<JssmStateDeclaration>
_end_states: Set<string>
_entry_hooks: Map<string, HookHandler<mDT>>
_exit_hooks: Map<string, HookHandler<mDT>>
_flow: "up" | "right" | "down" | "left"
_forced_transition_hook: HookHandler<mDT>
_fsl_version?: string
_global_action_hooks: Map<string, HookHandler<mDT>>
_graph_layout: JssmLayout
_has_basic_hooks: boolean
_has_entry_hooks: boolean
_has_exit_hooks: boolean
_has_global_action_hooks: boolean
_has_hooks: boolean
_has_named_hooks: boolean
_has_post_basic_hooks: boolean
_has_post_entry_hooks: boolean
_has_post_exit_hooks: boolean
_has_post_global_action_hooks: boolean
_has_post_hooks: boolean
_has_post_named_hooks: boolean
_has_post_transition_hooks: boolean
_has_transition_hooks: boolean
_history: JssmHistory<mDT>
_history_length: number
_hooked_state_style: Partial<JssmStateDeclaration>
_hooks: Map<string, HookHandler<mDT>>
_instance_name: string
_machine_author?: string[]
_machine_comment?: string
_machine_contributor?: string[]
_machine_definition?: string
_machine_language?: string
_machine_license?: string
_machine_name?: string
_machine_version?: string
_main_transition_hook: HookHandler<mDT>
_named_hooks: Map<string, HookHandler<mDT>>
_named_transitions: Map<string, number>
_post_any_action_hook: HookHandler<mDT>
_post_any_transition_hook: HookHandler<mDT>
_post_entry_hooks: Map<string, HookHandler<mDT>>
_post_exit_hooks: Map<string, HookHandler<mDT>>
_post_forced_transition_hook: HookHandler<mDT>
_post_global_action_hooks: Map<string, HookHandler<mDT>>
_post_hooks: Map<string, HookHandler<mDT>>
_post_main_transition_hook: HookHandler<mDT>
_post_named_hooks: Map<string, HookHandler<mDT>>
_post_standard_transition_hook: HookHandler<mDT>
_property_keys: Set<string>
_raw_state_declaration?: <internal>.Object[]
_required_properties: Set<string>
_reverse_action_targets: Map<string, Map<string, number>>
_reverse_actions: Map<string, Map<string, number>>
_standard_transition_hook: HookHandler<mDT>
_start_state_style: Partial<JssmStateDeclaration>
_start_states: Set<string>
_state: string
_state_declarations: Map<string, JssmStateDeclaration>
_state_labels: Map<string, string>
_state_properties: Map<string, any>
_states: Map<string, JssmGenericState>
_terminal_state_style: Partial<JssmStateDeclaration>
_themes: ("default" | "modern" | "ocean" | "plain")[]

Accessors

  • actions(whichState?: string): string[]

Returns boolean

  • actions(whichState?: string): string[]
  • List all actions available from this state. Please note that the order of the actions is not guaranteed.

    import { sm } from 'jssm';

    const machine = sm`
    red 'next' -> green 'next' -> yellow 'next' -> red;
    [red yellow green] 'shutdown' ~> off 'start' -> red;
    `;

    console.log( machine.state() ); // logs 'red'
    console.log( machine.actions() ); // logs ['next', 'shutdown']

    machine.action('next'); // true
    console.log( machine.state() ); // logs 'green'
    console.log( machine.actions() ); // logs ['next', 'shutdown']

    machine.action('shutdown'); // true
    console.log( machine.state() ); // logs 'off'
    console.log( machine.actions() ); // logs ['start']

    machine.action('start'); // true
    console.log( machine.state() ); // logs 'red'
    console.log( machine.actions() ); // logs ['next', 'shutdown']

    Parameters

    • whichState: string = ...

      The state whose actions to have listed

      -

    Returns string[]

  • all_themes(): ("default" | "modern" | "ocean" | "plain")[]
  • current_action_for(action: string): number
  • data(): mDT

Returns string[]

  • all_themes(): ("default" | "modern" | "ocean" | "plain")[]
  • current_action_for(action: string): number
  • data(): mDT
  • Get the current data of a machine.

    import * as jssm from 'jssm';

    const lswitch = jssm.from('on <=> off;', {data: 1});
    console.log( lswitch.data() ); // 1
    -

    Returns mDT

  • do(actionName: string, newData?: mDT): boolean
  • do(actionName: string, newData?: mDT): boolean
  • Instruct the machine to complete an action. Synonym for action.

    const light = sm`
    off 'start' -> red;
    red 'next' -> green 'next' -> yellow 'next' -> red;
    [red yellow green] 'shutdown' ~> off;
    `;

    light.state(); // 'off'
    light.do('start'); // true
    light.state(); // 'red'
    light.do('next'); // true
    light.state(); // 'green'
    light.do('next'); // true
    light.state(); // 'yellow'
    light.do('dance'); // !! false - no such action
    light.state(); // 'yellow'
    light.do('start'); // !! false - yellow does not have the action start
    light.state(); // 'yellow'
    @@ -108,7 +108,7 @@

    The action to engage

  • Optional newData: mDT

    The data change to insert during the action

    -

Returns boolean

  • dot_preamble(): string
  • flow(): "up" | "right" | "down" | "left"
  • force_transition(newState: string, newData?: mDT): boolean

Returns boolean

  • dot_preamble(): string
  • flow(): "up" | "right" | "down" | "left"
  • force_transition(newState: string, newData?: mDT): boolean
  • Instruct the machine to complete a forced transition (which will reject if called with a normal transition call.)

    const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;

    light.state(); // 'red'
    light.transition('off'); // false
    light.state(); // 'red'
    light.force_transition('off'); // true
    light.state(); // 'off' @@ -117,7 +117,7 @@

    The state to switch to

  • Optional newData: mDT

    The data change to insert during the transition

    -

Returns boolean

  • fsl_version(): string
  • get_transition_by_state_names(from: string, to: string): number
  • go(newState: string, newData?: mDT): boolean

Returns boolean

  • fsl_version(): string
  • get_transition_by_state_names(from: string, to: string): number
  • go(newState: string, newData?: mDT): boolean
  • Instruct the machine to complete a transition. Synonym for transition.

    const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;

    light.state(); // 'red'
    light.go('green'); // true
    light.state(); // 'green'
    @@ -125,73 +125,73 @@

    The state to switch to

  • Optional newData: mDT

    The data change to insert during the transition

    -

Returns boolean

  • graph_layout(): string
  • has_completes(): boolean
  • has_state(whichState: string): boolean

Returns boolean

  • graph_layout(): string
  • has_completes(): boolean
  • has_state(whichState: string): boolean
  • Check whether the machine knows a given state.

    import * as jssm from 'jssm';

    const lswitch = jssm.from('on <=> off;');

    console.log( lswitch.has_state('off') ); // true
    console.log( lswitch.has_state('dance') ); // false

    Parameters

    • whichState: string

      The state to be checked for extance

      -

    Returns boolean

  • has_terminals(): boolean
  • has_unenterables(): boolean
  • hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>
  • instance_name(): string
  • is_complete(): boolean
  • is_end_state(whichState: string): boolean

Returns boolean

  • has_terminals(): boolean
  • has_unenterables(): boolean
  • hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>
  • instance_name(): string
  • is_complete(): boolean
  • is_end_state(whichState: string): boolean
  • Check whether a given state is a valid start state (either because it was explicitly named as such, or because it was the first mentioned state.)

    import { sm, is_end_state } from 'jssm';

    const example = sm`a -> b;`;

    console.log( final_test.is_start_state('a') ); // false
    console.log( final_test.is_start_state('b') ); // true

    const example = sm`end_states: [a b]; a -> b;`;

    console.log( final_test.is_start_state('a') ); // true
    console.log( final_test.is_start_state('b') ); // true

    Parameters

    • whichState: string

      The name of the state to check

      -

    Returns boolean

  • is_final(): boolean

Returns boolean

  • is_final(): boolean
  • Check whether the current state is final (either has no exits or is marked complete.)

    import { sm, is_final } from 'jssm';

    const final_test = sm`first -> second;`;

    console.log( final_test.is_final() ); // false
    state.transition('second');
    console.log( final_test.is_final() ); // true
    -

    Returns boolean

  • is_start_state(whichState: string): boolean
  • is_start_state(whichState: string): boolean
  • Check whether a given state is a valid start state (either because it was explicitly named as such, or because it was the first mentioned state.)

    import { sm, is_start_state } from 'jssm';

    const example = sm`a -> b;`;

    console.log( final_test.is_start_state('a') ); // true
    console.log( final_test.is_start_state('b') ); // false

    const example = sm`start_states: [a b]; a -> b;`;

    console.log( final_test.is_start_state('a') ); // true
    console.log( final_test.is_start_state('b') ); // true

    Parameters

    • whichState: string

      The name of the state to check

      -

    Returns boolean

  • is_terminal(): boolean
  • is_unenterable(whichState: string): boolean
  • known_prop(prop_name: string): boolean

Returns boolean

  • is_terminal(): boolean
  • is_unenterable(whichState: string): boolean
  • known_prop(prop_name: string): boolean
  • Check whether a given string is a known property's name.

    const example = sm`property foo default 1; a->b;`;

    example.known_prop('foo'); // true
    example.known_prop('bar'); // false

    Parameters

    • prop_name: string

      The relevant property name to look up

      -

    Returns boolean

  • known_props(): string[]

Returns boolean

  • known_props(): string[]
  • List all known property names. If you'd also like values, use props instead. The order of the properties is not defined, and the properties generally will not be sorted.

    
     
    -

    Returns string[]

  • label_for(state: string): string
  • label_for(state: string): string
  • Get the label for a given state, if any; return undefined otherwise.

    import * as jssm from 'jssm';

    const lswitch = jssm.from('a -> b; state a: { label: "Foo!"; };');
    console.log( lswitch.label_for('a') ); // 'Foo!'
    -

    Parameters

    • state: string

    Returns string

  • list_actions(): string[]
  • list_actions(): string[]
  • Lists all edges of a machine.

    import { sm } from 'jssm';

    const lswitch = sm`on 'toggle' <=> 'toggle' off;`;

    lswitch.list_edges();
    [
    {
    from: 'on',
    to: 'off',
    kind: 'main',
    forced_only: false,
    main_path: true,
    action: 'toggle'
    },
    {
    from: 'off',
    to: 'on',
    kind: 'main',
    forced_only: false,
    main_path: true,
    action: 'toggle'
    }
    ]
    -

    Returns JssmTransition<mDT>[]

  • list_entrances(whichState?: string): string[]
  • list_entrances(whichState?: string): string[]
  • List all entrances attached to the current state. Please note that the order of the list is not defined.

    import { sm } from 'jssm';

    const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;

    light.state(); // 'red'
    light.list_entrances(); // [ 'yellow', 'off' ]

    Parameters

    • whichState: string = ...

      The state whose entrances to have listed

      -

    Returns string[]

  • list_exit_actions(whichState?: string): string[]
  • list_exits(whichState?: string): string[]

Returns string[]

  • list_exit_actions(whichState?: string): string[]
  • list_exits(whichState?: string): string[]
  • List all exits attached to the current state. Please note that the order of the list is not defined.

    import { sm } from 'jssm';

    const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;

    light.state(); // 'red'
    light.list_exits(); // [ 'green', 'off' ]

    Parameters

    • whichState: string = ...

      The state whose exits to have listed

      -

    Returns string[]

  • list_named_transitions(): Map<string, number>
  • list_states_having_action(whichState: string): string[]

Returns string[]

  • list_named_transitions(): Map<string, number>
  • list_states_having_action(whichState: string): string[]
  • List all states that have a specific action attached. Please note that the order of the states is not guaranteed.

    import { sm } from 'jssm';

    const machine = sm`
    red 'next' -> green 'next' -> yellow 'next' -> red;
    [red yellow green] 'shutdown' ~> off 'start' -> red;
    `;

    console.log( machine.list_states_having_action('next') ); // ['red', 'green', 'yellow']
    console.log( machine.list_states_having_action('start') ); // ['off']

    Parameters

    • whichState: string

      The action to be checked for associated states

      -

    Returns string[]

Returns string[]

  • List all transitions attached to the current state, sorted by entrance and exit. The order of each sublist is not defined. A node could appear in both lists.

    @@ -199,7 +199,7 @@

    Parameters

    • whichState: string = ...

      The state whose transitions to have listed

      -

    Returns JssmTransitionList

  • machine_author(): string[]
  • machine_comment(): string
  • machine_contributor(): string[]
  • machine_definition(): string
  • machine_language(): string
  • machine_license(): string
  • machine_name(): string
  • machine_version(): string
  • post_hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>
  • probabilistic_histo_walk(n: number): Map<string, number>
  • probabilistic_transition(): boolean
  • probabilistic_walk(n: number): string[]
  • probable_action_exits(whichState?: string): any[]
  • prop(name: string): any

Returns JssmTransitionList

  • machine_author(): string[]
  • machine_comment(): string
  • machine_contributor(): string[]
  • machine_definition(): string
  • machine_language(): string
  • machine_license(): string
  • machine_name(): string
  • machine_version(): string
  • post_hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>
  • probabilistic_histo_walk(n: number): Map<string, number>
  • probabilistic_transition(): boolean
  • probabilistic_walk(n: number): string[]
  • probable_action_exits(whichState?: string): any[]
  • prop(name: string): any
  • Get the current value of a given property name.

    
     
    @@ -207,35 +207,35 @@

    The relevant property name to look up

Returns any

The value behind the prop name. Because functional props are evaluated as getters, this can be anything.

-
  • props(): object
  • props(): object
  • Get the current value of every prop, as an object. If no current definition exists for a prop - that is, if the prop was defined without a default and the current state also doesn't define the prop - then that prop will be listed in the returned object with a value of undefined.

    const traffic_light = sm`

    property can_go default true;
    property hesitate default true;
    property stop_first default false;

    Off -> Red => Green => Yellow => Red;
    [Red Yellow Green] ~> [Off FlashingRed];
    FlashingRed -> Red;

    state Red: { property stop_first true; property can_go false; };
    state Off: { property stop_first true; };
    state FlashingRed: { property stop_first true; };
    state Green: { property hesitate false; };

    `;

    traffic_light.state(); // Off
    traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true; }

    traffic_light.go('Red');
    traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true; }

    traffic_light.go('Green');
    traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false; }
    -

    Returns object

  • Serialize the current machine, including all defining state but not the machine string, to a structure. This means you will need the machine string to recreate (to not waste repeated space;) if you want the machine string embedded, call {@link serialize_with_string} instead.

    -

    Parameters

    • Optional comment: string

    Returns JssmSerialization<mDT>

  • state(): string
  • state(): string
  • Get the current state of a machine.

    import * as jssm from 'jssm';

    const lswitch = jssm.from('on <=> off;');
    console.log( lswitch.state() ); // 'on'

    lswitch.transition('off');
    console.log( lswitch.state() ); // 'off'
    -

    Returns string

  • state_is_complete(whichState: string): boolean
  • state_is_final(whichState: string): boolean
  • state_is_complete(whichState: string): boolean
  • state_is_final(whichState: string): boolean
  • Check whether a given state is final (either has no exits or is marked complete.)

    import { sm, state_is_final } from 'jssm';

    const final_test = sm`first -> second;`;

    console.log( final_test.state_is_final('first') ); // false
    console.log( final_test.state_is_final('second') ); // true

    Parameters

    • whichState: string

      The name of the state to check for finality

      -

    Returns boolean

  • state_is_terminal(whichState: string): boolean
  • states(): string[]

Returns boolean

  • state_is_terminal(whichState: string): boolean
  • states(): string[]
  • List all the states known by the machine. Please note that the order of these states is not guaranteed.

    import * as jssm from 'jssm';

    const lswitch = jssm.from('on <=> off;');
    console.log( lswitch.states() ); // ['on', 'off']
    -

    Returns string[]

  • strict_prop(name: string): any
  • strict_prop(name: string): any
  • Get the current value of a given property name. If missing on the state and without a global default, throw, unlike prop, which would return undefined instead.

    @@ -245,7 +245,7 @@

    The relevant property name to look up

Returns any

The value behind the prop name. Because functional props are evaluated as getters, this can be anything.

-
  • Gets the composite style for a specific node by individually imposing the style layers on a given object, after determining which layers are appropriate.

    @@ -256,7 +256,7 @@ terminal styles; then the start styles; then the end styles; finally, the active styles. Remember, last wins.

    The base state style must exist. All other styles are optional.

    -

    Parameters

    • state: string

    Returns Partial<JssmStateDeclaration>

  • transition(newState: string, newData?: mDT): boolean
  • transition(newState: string, newData?: mDT): boolean
  • Instruct the machine to complete a transition. Synonym for go.

    const light = sm`
    off 'start' -> red;
    red 'next' -> green 'next' -> yellow 'next' -> red;
    [red yellow green] 'shutdown' ~> off;
    `;

    light.state(); // 'off'
    light.go('red'); // true
    light.state(); // 'red'
    light.go('green'); // true
    light.state(); // 'green'
    light.go('blue'); // !! false - no such state
    light.state(); // 'green'
    light.go('red'); // !! false - green may not go directly to red, only to yellow
    light.state(); // 'green'
    @@ -264,4 +264,4 @@

    The state to switch to

  • Optional newData: mDT

    The data change to insert during the transition

    -

Returns boolean

  • transition_impl(newStateOrAction: string, newData: mDT, wasForced: boolean, wasAction: boolean): boolean
  • Parameters

    • newStateOrAction: string
    • newData: mDT
    • wasForced: boolean
    • wasAction: boolean

    Returns boolean

  • valid_action(action: string, _newData?: mDT): boolean
  • valid_force_transition(newState: string, _newData?: mDT): boolean
  • valid_transition(newState: string, _newData?: mDT): boolean

Legend

  • Namespace
  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Class
  • Class with type parameter
  • Property
  • Method
  • Accessor

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +

Returns boolean

  • transition_impl(newStateOrAction: string, newData: mDT, wasForced: boolean, wasAction: boolean): boolean
  • Parameters

    • newStateOrAction: string
    • newData: mDT
    • wasForced: boolean
    • wasAction: boolean

    Returns boolean

  • valid_action(action: string, _newData?: mDT): boolean
  • valid_force_transition(newState: string, _newData?: mDT): boolean
  • valid_transition(newState: string, _newData?: mDT): boolean

Legend

  • Namespace
  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Class
  • Class with type parameter
  • Property
  • Method
  • Accessor

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/docs/classes/jssm_error.JssmError.html b/docs/docs/classes/jssm_error.JssmError.html index d1b85b91..e8181df2 100644 --- a/docs/docs/classes/jssm_error.JssmError.html +++ b/docs/docs/classes/jssm_error.JssmError.html @@ -1,4 +1,4 @@ -JssmError | JSSM, a JavaScript state machine - the FSM for FSL
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

Properties

base_message: string
message: string
name: string
requested_state: string
stack?: string
prepareStackTrace?: ((err: <internal>.Error, stackTraces: CallSite[]) => any)

Type declaration

  • Compile a machine's JSON intermediate representation to a config object. If you're using this (probably don't,) you're probably also using parse to get the IR, and the object constructor @@ -43,7 +43,7 @@

    Hey!

    The type of the machine data member; usually omitted

Parameters

  • tree: JssmParseTree

    The parse tree to be boiled down into a machine config

    -

Returns JssmGenericConfig<mDT>

Returns JssmGenericConfig<mDT>

  • Create a state machine from an implementation string. This is one of the two main paths for working with JSSM, alongside sm.

    Use this method when you want to conveniently pull a state machine from a @@ -57,7 +57,7 @@

    Hey!

    The FSL code to evaluate

  • Optional ExtraConstructorFields: Partial<JssmGenericConfig<mDT>>

    Extra non-code configuration to pass at creation time

    -

Returns Machine<mDT>

  • is_hook_rejection<mDT>(hr: HookResult<mDT>): boolean

Returns Machine<mDT>

  • is_hook_rejection<mDT>(hr: HookResult<mDT>): boolean
  • An internal convenience wrapper for parsing then compiling a machine string. Not generally meant for external use. Please see compile or sm.

    @@ -65,7 +65,7 @@

    Hey!

    The type of the machine data member; usually omitted

Parameters

  • plan: string

    The FSL code to be evaluated and built into a machine config

    -

Returns JssmGenericConfig<mDT>

Returns JssmGenericConfig<mDT>

  • This method wraps the parser call that comes from the peg grammar, parse. Generally neither this nor that should be used directly unless you mean to develop plugins or extensions for the machine.

    @@ -96,7 +96,7 @@

    Hey!

    The FSL code to be evaluated

  • Optional options: <internal>.Object

    Things to control about the instance

    -

Returns any

Returns any

  • Create a state machine from a template string. This is one of the two main paths for working with JSSM, alongside from.

    Use this method when you want to work directly and conveniently with a @@ -110,7 +110,7 @@

    Hey!

    The assembled code

  • Rest ...remainder: any[]

    The mechanic for template argument insertion

    -

Returns Machine<mDT>

Returns Machine<mDT>