MCPcopy
hub / github.com/dosco/graphjin / Get

Method Get

wasm/fs.go:19–32  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

17func NewJSFS(fs js.Value, path string) *JSFS { return &JSFS{fs: fs, bp: path} }
18
19func (f *JSFS) Get(path string) (data []byte, err error) {
20 path = filepath.Join(f.bp, path)
21 defer func() {
22 if err1 := recover(); err1 != nil {
23 err = toError(err1)
24 }
25 }()
26 buf := f.fs.Call("readFileSync", path)
27
28 a := js.Global().Get("Uint8Array").New(buf)
29 data = make([]byte, a.Get("length").Int())
30 js.CopyBytesToGo(data, a)
31 return data, nil
32}
33
34func (f *JSFS) Put(path string, data []byte) (err error) {
35 defer func() {

Callers

nothing calls this directly

Calls 3

toErrorFunction · 0.85
CallMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected