Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

References

Re-exports FslDirections
Re-exports build_time
Renames and re-exports jssm_constants
Re-exports find_repeated
Re-exports histograph
Re-exports seq
Re-exports unique
Re-exports version
Re-exports weighted_histo_key
Re-exports weighted_rand_select
Re-exports weighted_sample_select

Variables

gviz_shapes: string[]
named_colors: string[]
shapes: string[]

Functions

  • Return the direction of an arrow - right, left, or both.

    import { arrow_direction } from 'jssm';

    arrow_direction('->'); // 'right'
    arrow_direction('<~=>'); // 'both'

    Parameters

    Returns JssmArrowDirection

  • Return the direction of an arrow - right, left, or both.

    import { arrow_left_kind } from 'jssm';

    arrow_left_kind('<-'); // 'legal'
    arrow_left_kind('<='); // 'main'
    arrow_left_kind('<~'); // 'forced'
    arrow_left_kind('<->'); // 'legal'
    arrow_left_kind('->'); // 'none'

    Parameters

    Returns JssmArrowKind

  • Return the direction of an arrow - right, left, or both.

    import { arrow_left_kind } from 'jssm';

    arrow_left_kind('->'); // 'legal'
    arrow_left_kind('=>'); // 'main'
    arrow_left_kind('~>'); // 'forced'
    arrow_left_kind('<->'); // 'legal'
    arrow_left_kind('<-'); // 'none'

    Parameters

    Returns JssmArrowKind

  • 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 {@link Machine.construct} to turn the config object into a workable machine.

    import { parse, compile, Machine } from 'jssm';

    const intermediate = parse('a -> b;');
    // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]

    const cfg = compile(intermediate);
    // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }

    const machine = new Machine(cfg);
    // Machine { _instance_name: undefined, _state: 'a', ...

    This method is mostly for plugin and intermediate tool authors, or people who need to work with the machine's intermediate representation.

    Hey!

    Most people looking at this want either the sm operator or method from, which perform all the steps in the chain. The library's author mostly uses operator sm, and mostly falls back to .from when needing to parse strings dynamically instead of from template literals.

    Operator sm:

    import { sm } from 'jssm';

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

    Method from:

    import * as jssm from 'jssm';

    const toggle = jssm.from('up <=> down;');

    Type Parameters

    • StateType

    • mDT

      The type of the machine data member; usually omitted

    Parameters

    • tree: JssmParseTree<StateType, mDT>

      The parse tree to be boiled down into a machine config

    Returns JssmGenericConfig<StateType, 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 string dynamically. Use operator sm when you just want to work with a template expression.

    import * as jssm from 'jssm';

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

    Type Parameters

    • mDT

      The type of the machine data member; usually omitted

    Parameters

    • MachineAsString: string

      The FSL code to evaluate

    • Optional ExtraConstructorFields: Partial<JssmGenericConfig<string, mDT>>

      Extra non-code configuration to pass at creation time

    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.

    Type Parameters

    • StateType

    • mDT

      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<StateType, 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.

    Parses the intermediate representation of a compiled string down to a machine configuration object. If you're using this (probably don't,) you're probably also using compile and Machine.constructor.

    import { parse, compile, Machine } from 'jssm';

    const intermediate = wrap_parse('a -> b;', {});
    // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]

    const cfg = compile(intermediate);
    // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }

    const machine = new Machine(cfg);
    // Machine { _instance_name: undefined, _state: 'a', ...

    This method is mostly for plugin and intermediate tool authors, or people who need to work with the machine's intermediate representation.

    Hey!

    Most people looking at this want either the sm operator or method from, which perform all the steps in the chain. The library's author mostly uses operator sm, and mostly falls back to .from when needing to parse strings dynamically instead of from template literals.

    Operator sm:

    import { sm } from 'jssm';

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

    Method from:

    import * as jssm from 'jssm';

    const toggle = jssm.from('up <=> down;');

    wrap_parse itself is an internal convenience method for alting out an object as the options call. Not generally meant for external use.

    Parameters

    • input: string

      The FSL code to be evaluated

    • Optional options: <internal>.Object

      Things to control about the instance

    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 constant template expression. Use .from when you want to pull from dynamic strings.

    import * as jssm from 'jssm';

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

    Type Parameters

    • mDT

      The type of the machine data member; usually omitted

    Parameters

    • template_strings: TemplateStringsArray

      The assembled code

    • Rest ...remainder: any[]

      The mechanic for template argument insertion

    Returns Machine<mDT>

  • An internal method meant to take a series of declarations and fold them into a single multi-faceted declaration, in the process of building a state. Not generally meant for external use.

    internal

    Parameters

    Returns JssmStateDeclaration

Generated using TypeDoc