MCPcopy Create free account
hub / github.com/buke/quickjs-go / EvalFile

Method EvalFile

context.go:985–992  ·  view source on GitHub ↗

EvalFile returns a js value with given code and filename. Need call Free() `quickjs.Value`'s returned by `Eval()` and `EvalFile()` and `EvalBytecode()`.

(filePath string, opts ...EvalOption)

Source from the content-addressed store, hash-verified

983// EvalFile returns a js value with given code and filename.
984// Need call Free() `quickjs.Value`'s returned by `Eval()` and `EvalFile()` and `EvalBytecode()`.
985func (ctx *Context) EvalFile(filePath string, opts ...EvalOption) *Value {
986 b, err := os.ReadFile(filePath)
987 if err != nil {
988 return ctx.ThrowError(err)
989 }
990 opts = append(opts, EvalFileName(filePath))
991 return ctx.Eval(string(b), opts...)
992}
993
994// LoadModule returns a js value with given code and module name.
995func (ctx *Context) LoadModule(code string, moduleName string, opts ...EvalOption) *Value {

Callers 1

Calls 3

ThrowErrorMethod · 0.95
EvalMethod · 0.95
EvalFileNameFunction · 0.85

Tested by 1