diff --git a/regr/mod.wasm b/regr/mod.wasm index f0a9636..55a3d54 100755 Binary files a/regr/mod.wasm and b/regr/mod.wasm differ diff --git a/stat/main.go b/stat/main.go index a5066b4..d6679c6 100644 --- a/stat/main.go +++ b/stat/main.go @@ -12,7 +12,7 @@ import ( ) func InitStatExports(this js.Value, args []js.Value) interface{} { - exports := args[0] + exports := js.Global().Get("Object").New() exports.Set("Bhattacharyya", js.FuncOf(src.Bhattacharyya)) exports.Set("BivariateMoment", js.FuncOf(src.BivariateMoment)) exports.Set("ChiSquare", js.FuncOf(src.ChiSquare)) @@ -54,7 +54,7 @@ func InitStatExports(this js.Value, args []js.Value) interface{} { exports.Set("StdScore", js.FuncOf(src.StdScore)) exports.Set("TOC", js.FuncOf(src.TOC)) exports.Set("Variance", js.FuncOf(src.Variance)) - return nil + return exports } func main() { diff --git a/stat/mod.ts b/stat/mod.ts new file mode 100644 index 0000000..011db90 --- /dev/null +++ b/stat/mod.ts @@ -0,0 +1,20 @@ +import "../lib/wasm_tinygo.js"; +import { Stat } from "./types.ts"; + +// @ts-expect-error: no types +const go = new Go(); + +const code = + await (await fetch(import.meta.url.replace("/mod.ts", "/mod.wasm"))) + .arrayBuffer(); + +const wasmMmodule = await WebAssembly.instantiate(code, go.importObject); +const wasm = wasmMmodule.instance; + +go.run(wasm); + +// @ts-ignore: no types +const _exports = __InitStatExports() as Record unknown> & Stat; + + +export default _exports; diff --git a/stat/mod.wasm b/stat/mod.wasm index d4107db..bc03924 100755 Binary files a/stat/mod.wasm and b/stat/mod.wasm differ