modules

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package modules the JS module

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidModule module is invalid
	ErrInvalidModule = errors.New("invalid module")
	// ErrIllegalModuleName module name is illegal
	ErrIllegalModuleName = errors.New("illegal module name")

	// ErrModuleFileDoesNotExist module not exist
	ErrModuleFileDoesNotExist = errors.New("module file does not exist")
)

Functions

func EnableRequire

func EnableRequire(vm *goja.Runtime, path ...string)

EnableRequire set runtime require module

func InitGlobalModule

func InitGlobalModule(vm *goja.Runtime)

InitGlobalModule init all global modules

func Register

func Register(name string, mod Module)

Register the given mod as an external JavaScript module that can be imported by name.

Types

type Global

type Global interface {
	Module
	Global() // is it a global module
}

Global is it a global module

type Module

type Module interface {
	Exports() any // module instance
}

Module is what a module needs to return

Directories

Path Synopsis
Package cache the cache JS implementation
Package cache the cache JS implementation
Package cookie the cookie JS implementation
Package cookie the cookie JS implementation
Package crypto the crypto JS implementation
Package crypto the crypto JS implementation
Package encoding the encoding JS implementation
Package encoding the encoding JS implementation
Package http the http JS implementation
Package http the http JS implementation

Jump to

Keyboard shortcuts

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