File tree Expand file tree Collapse file tree 5 files changed +43
-1
lines changed Expand file tree Collapse file tree 5 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1
- .idea
1
+ .idea
2
+ dist
Original file line number Diff line number Diff line change
1
+
2
+ SOURCE =$(shell find . -iname "* .go")
3
+
4
+
5
+
6
+ dist/lib.wasm : $(SOURCE )
7
+ mkdir -p dist
8
+ rm -f dist/*
9
+ cp " $( shell go env GOROOT) /misc/wasm/wasm_exec.js" dist/wasm_exec.js
10
+ GOOS=js GOARCH=wasm go build -ldflags=" -s -w" -o ./dist/lib.wasm cmd/wasm/main.go
Original file line number Diff line number Diff line change
1
+ //go:build js && wasm
2
+
3
+ package pkg
4
+
5
+ import (
6
+ "github.com/speakeasy-api/jsonpath/pkg"
7
+ "syscall/js"
8
+ )
9
+
10
+ func jsFuncWrapper () js.Func {
11
+ return js .FuncOf (func (this js.Value , args []js.Value ) interface {} {
12
+ if len (args ) != 2 {
13
+ return `{"err":""}`
14
+ }
15
+ originalYAML := args [0 ].String ()
16
+ jsonpath := args [1 ].String ()
17
+ returnValue := pkg .Entry (originalYAML , jsonpath )
18
+ return returnValue
19
+ })
20
+ }
21
+
22
+ func main () {
23
+ js .Global ().Set ("JSONPath" , jsFuncWrapper ())
24
+ <- make (chan bool )
25
+ }
Original file line number Diff line number Diff line change
1
+ package pkg
2
+
3
+ func Entry (yaml string , jsonpath string ) string {
4
+ return "Hello World"
5
+ }
Original file line number Diff line number Diff line change
1
+ package pkg
You can’t perform that action at this time.
0 commit comments