Skip to content

Commit

Permalink
fix: marshal problem for complex128 and float's Inf in json, treat it…
Browse files Browse the repository at this point in the history
… as a string
  • Loading branch information
muktihari committed Aug 9, 2023
1 parent 9974dc2 commit 7477f0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Binary file modified main.wasm
Binary file not shown.
4 changes: 3 additions & 1 deletion wasm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func Evaluate() js.Func {
return encode(&Result{Err: fmt.Sprintf("%s", err)})
}

return encode(&Result{Value: v})
// complex128 and float's Inf can't be marshaled properly without using custom json.Marshaler.
// for this use case, treat it as a string should be sufficient.
return encode(&Result{Value: fmt.Sprintf("%v", v)})
})
}

Expand Down

0 comments on commit 7477f0b

Please sign in to comment.