github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/examples/wasm/slices/wasm.go (about) 1 package main 2 3 import ( 4 "strings" 5 "syscall/js" 6 ) 7 8 func splitter(this js.Value, args []js.Value) interface{} { 9 values := strings.Split(args[0].String(), ",") 10 11 result := make([]interface{}, 0) 12 for _, each := range values { 13 result = append(result, each) 14 } 15 16 return js.ValueOf(result) 17 } 18 19 func main() { 20 wait := make(chan struct{}, 0) 21 js.Global().Set("splitter", js.FuncOf(splitter)) 22 <-wait 23 }