require

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidModuleError     = errors.New("Invalid module")
	IllegalModuleNameError = errors.New("Illegal module name")
)

Functions

func RegisterNativeModule

func RegisterNativeModule(name string, loader ModuleLoader)

func Require

func Require(runtime *js.Runtime, name string) js.Value

Types

type ModuleLoader

type ModuleLoader func(*js.Runtime, *js.Object)

type Registry

type Registry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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 (r *Registry) Enable(runtime *js.Runtime) *RequireModule

Enable adds the require() function to the specified runtime.

type RequireModule

type RequireModule struct {
	// contains filtered or unexported fields
}

func (*RequireModule) Require

func (r *RequireModule) Require(p string) (ret js.Value, err error)

Require can be used to import modules from Go source (similar to JS require() function).

type SourceLoader

type SourceLoader func(path string) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL