MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / AddFileReader

Function AddFileReader

jsext/filereader.go:9–23  ·  view source on GitHub ↗
(vm *goja.Runtime)

Source from the content-addressed store, hash-verified

7)
8
9func AddFileReader(vm *goja.Runtime) error {
10 return vm.GlobalObject().Set("readFile", func(call goja.FunctionCall) goja.Value {
11 if len(call.Arguments) != 1 {
12 panic(vm.NewTypeError("readFile expects exactly 1 argument"))
13 }
14
15 filename := call.Argument(0).String()
16 content, err := os.ReadFile(filename)
17 if err != nil {
18 panic(vm.NewGoError(err))
19 }
20
21 return vm.ToValue(string(content))
22 })
23}

Callers

nothing calls this directly

Calls 2

SetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected