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

Method CompileFile

context.go:1139–1154  ·  view source on GitHub ↗

Compile returns a compiled bytecode with given filename.

(filePath string, opts ...EvalOption)

Source from the content-addressed store, hash-verified

1137
1138// Compile returns a compiled bytecode with given filename.
1139func (ctx *Context) CompileFile(filePath string, opts ...EvalOption) ([]byte, error) {
1140 b, err := os.ReadFile(filePath)
1141 if err != nil {
1142 return nil, err
1143 }
1144
1145 options := EvalOptions{}
1146 for _, fn := range opts {
1147 fn(&options)
1148 }
1149 if options.filename == "" {
1150 opts = append(opts, EvalFileName(filePath))
1151 }
1152
1153 return ctx.Compile(string(b), opts...)
1154}
1155
1156// Global returns a context's global object.
1157func (ctx *Context) Globals() *Value {

Callers 2

CompileModuleMethod · 0.95

Calls 2

CompileMethod · 0.95
EvalFileNameFunction · 0.85

Tested by 1