# README
ECMAScript
This core.Interpreter
is based on
Goja, which executes Ecmascript
5.1.
Unlike the demo goja
interpreter (interpreters/goja
), this
interpreter doesn't support libraries. If you want to use this
interpreter but also want to use libraries, then you should implement
a preprocessing step that generates source that has the libraries
embedded in that source.
Eventually deprecate interpreters/goja
in favor of this interpreter.
Environment
The base runtime environment includes a binding for the variable _
:
-
_.bindings
: The current set of machine bindings. -
_.params
: The current parameters for the machine execution. These parameters are provided by the application that uses the Machinescore
. In the examplemservice
process, these parameters includemid
: The id of the current machinecid
: The id of the machine's crew
-
_.props
:core.StepProps
(if any). -
_.out(X)
: "Emits" the given message.
If the interpreter's Extended
flag is true
, then _
has these
additional properties:
-
_.genstr()
: Generates a random 32-char string -
_.cronNext(CRONEXPR)
→TIMESTAMP
:cronNext
attempts to parse its argument as a cron expression. If successful, returns the next time in Go RFC3339Nano format.Example:
({next: _.cronNext("* 0 * * *")});
-
_.match(PATTERN, MESSAGE)
: Invokes pattern matching.
If the interpreter's Test
flag is true
, then _
has these
additional properties:
-
_.sleep(MS)
: Sleeps for the given number of milliseconds. -
_.exit(N)
: Terminates the process (!) with the given exit code.