Skip to content

@yantrix/automata v0.5.2 • Docs


Yantrix API / @yantrix/automata / FunctionDictionary

Class: FunctionDictionary ​

Implementation of IAutomataFunctionRegistry, where functions are stored in a map.

Has strict requirements for registering new functions, overwrites are not possible.

Extends ​

  • AbstractBaseClass

Implements ​

Methods ​

call() ​

ts
call(functionKey, ...args): any

Retrieve function from the registry and immediately call it, returning the result to the consumer.

Should return an error if the arguments for a specific function are incorrect.

Parameters ​

• functionKey: string

name of the function to call

• ...args: any[]

arguments necessary for the function

Returns ​

any

result of calling the function

Throws ​

Will throw an error if:

1). Function is not found by the specified key.

2). Arguments for the function are incorrect(as specified in their implementation).

Throws ​

Will throw an error if:

1). Function is not found by the specified key.

2). Arguments for the function are incorrect(as specified in their implementation).

Implementation of ​

IAutomataFunctionRegistry.call


get() ​

ts
get(functionKey): TAutomataFunction

Get function from registry.

Parameters ​

• functionKey: string

name of the function

Returns ​

TAutomataFunction

function to invoke

Throws ​

Will throw an error if the function is not found by the specified key.

Throws ​

Will throw an error if the function is not found by the specified key.

Implementation of ​

IAutomataFunctionRegistry.get


has() ​

ts
has(functionKey): boolean

Check if a function exists in the registry.

Parameters ​

• functionKey: string

name of the function to check

Returns ​

boolean

true if the function exists, false otherwise

Implementation of ​

IAutomataFunctionRegistry.has


register() ​

ts
register(f, callback?): Record<string, TAutomataFunction>

Register function under a specific name in the registry.

Parameters ​

• f: string | Record<string, TAutomataFunction>

function to register, either as just a name(string) or a name-function record

• callback?: TAutomataFunction

function to invoke, required if the first argument is a string

Returns ​

Record<string, TAutomataFunction>

Throws ​

Will throw an error if:

1). Name is not valid (valid name starts with a letter, has length 1-255 and does not contain any special symbols).

2). Name is already taken. Function cannot be registered under an already existing name to prevent overwriting of the basic built-in functions.

Throws ​

Will throw an error if:

1). Name is not valid (valid name starts with a letter, has length 1-255 and does not contain any special symbols).

2). Name is already taken. Function cannot be registered under an already existing name to prevent overwriting of the basic built-in functions.

Implementation of ​

IAutomataFunctionRegistry.register