Documentation
¶
Index ¶
Constants ¶
View Source
const NAME = "require"
Variables ¶
View Source
var ( InvalidModuleError = errors.New("Invalid module") IllegalModuleNameError = errors.New("Illegal module name") )
Functions ¶
func GetModuleInfo ¶
func GetModuleInfo(name, contextId string) (*commons.ModuleInfo, bool)
func RegisterNativeModule ¶
func RegisterNativeModule(name string, info *commons.ModuleInfo)
Types ¶
type Registry ¶
Registry contains a cache of compiled modules which can be used by multiple Runtimes
func NewRegistryWithLoader ¶
func NewRegistryWithLoader(srcLoader SourceLoader) *Registry
func (*Registry) Enable ¶
func (instance *Registry) Enable(ctx *commons.RuntimeContext) *RequireModule
Enable adds the require() function to the specified runtime.
type RequireModule ¶
type RequireModule struct {
// contains filtered or unexported fields
}
func NewRequireModule ¶
func NewRequireModule(ctx *commons.RuntimeContext, registry *Registry) *RequireModule
func (*RequireModule) GoRequire ¶
func (instance *RequireModule) GoRequire(p string) (ret js.Value, err error)
Require can be used to import modules from Go source (similar to JS require() function).
func (*RequireModule) JsRequire ¶
func (instance *RequireModule) JsRequire(call js.FunctionCall) js.Value
type SourceLoader ¶
Click to show internal directories.
Click to hide internal directories.