jsenv

package
v0.0.0-...-2873e01 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// limiting the support for loaders and targets
	LoaderJS  TransformLoader = TransformLoader(api.LoaderJS)
	LoaderJSX TransformLoader = TransformLoader(api.LoaderJSX)
	LoaderTS  TransformLoader = TransformLoader(api.LoaderTS)

	TargetNoop   TransformTarget = 0
	TargetES5    TransformTarget = TransformTarget(api.ES5)
	TargetES2016 TransformTarget = TransformTarget(api.ES2016)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Fn

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

func (Fn) Exec

func (f Fn) Exec(i ...goja.Value) (interface{}, error)

type TransformLoader

type TransformLoader uint8

type TransformTarget

type TransformTarget uint8

type Transformer

type Transformer interface {
	Transform(string) ([]byte, error)
}

func NewTransformer

func NewTransformer(loader TransformLoader, target TransformTarget) Transformer

type Vm

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

func New

func New(t Transformer) Vm

func (Vm) Compile

func (ss Vm) Compile(p string) (err error)

Compile is used only when parsing the input evaluation without actually running it

func (Vm) Eval

func (ss Vm) Eval(p string) (err error)

Eval transforms the input js to the specified version and evals in vm

func (Vm) Fetch

func (ss Vm) Fetch(key string) goja.Value

Fetch value from vm

func (Vm) New

func (ss Vm) New(i interface{}) goja.Value

New creates a goja internal type

func (Vm) Register

func (ss Vm) Register(key string, i interface{}) error

Register the value in vm

func (Vm) RegisterFunction

func (ss Vm) RegisterFunction(s string, wrapperFn ...func() string) (f *Fn, err error)

RegisterFunction registers the function to the vm and returns the function that can be used in go

Jump to

Keyboard shortcuts

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