Skip to content

@yantrix/automata v0.0.1Docs


Yantrix API / @yantrix/automata / IAutomataFunctionRegistry

Interface: IAutomataFunctionRegistry

Interface for any data structure capable of storing and returning automata functions.

Properties

call()

ts
call: (functionKey, ...args) => unknown;

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

unknown

result of calling the function

Throw

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).


get()

ts
get: (functionKey) => TAutomataFunction;

Get function from registry.

Parameters

functionKey: string

name of the function

Returns

TAutomataFunction

function to invoke

Throw

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


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


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>

Throw

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.