Documentation
¶
Overview ¶
Package js is a thin wrapper around Goja runtime.
Because Goja itself doesn't support most of modern JS features, the source code is transpiled by Babel before executing it, so we can actually write state migrations in ES5.1+.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func NewRuntime ¶
func NewRuntime() *Runtime
NewRuntime creates a new JavaScript runtime. The runtime is set up to uncapitalize struct fields and methods passed into runtime as objects.
type Script ¶
type Script struct { Name string Source string Args []interface{} // contains filtered or unexported fields }
func (*Script) Run ¶
func (s *Script) Run(opts ...ScriptOption) (interface{}, error)
Run runs a script, and then invokes the function exported by the script ("export default function") with the script's arguments.
type ScriptOption ¶
func TranspileToES5 ¶
func TranspileToES5(val bool) ScriptOption
TranspileToES5 transforms the script source code to ES5.1 using Babel
Click to show internal directories.
Click to hide internal directories.