Skip to content
Snippets Groups Projects
Commit 36b27a73 authored by Jake Taylor's avatar Jake Taylor
Browse files

fix breakages

parent 271ef43c
No related branches found
No related tags found
2 merge requests!60Revert "Fail a test to be sure it works",!4Xx 4114/index db
...@@ -28,16 +28,15 @@ func CopyBytesToJS(src []byte) js.Value { ...@@ -28,16 +28,15 @@ func CopyBytesToJS(src []byte) js.Value {
return dst return dst
} }
// JsonToJS converts a marshalled JSON bytes to a Javascript object. // JsonToJS is a helper that converts JSON bytes input
func JsonToJS(src []byte) (js.Value, error) { // to a [js.Value] of the object subtype.
var inInterface map[string]interface{} func JsonToJS(inputJson []byte) (js.Value, error) {
err := json.Unmarshal(src, &inInterface) jsObj := make(map[string]interface{})
err := json.Unmarshal(inputJson, &jsObj)
if err != nil { if err != nil {
Throw(TypeError, err) return js.Value{}, err
return js.ValueOf(nil), err
} }
return js.ValueOf(jsObj), nil
return js.ValueOf(inInterface), nil
} }
// JsToJson converts the Javascript value to JSON. // JsToJson converts the Javascript value to JSON.
......
...@@ -38,22 +38,6 @@ func WrapCB(parent js.Value, m string) func(args ...interface{}) js.Value { ...@@ -38,22 +38,6 @@ func WrapCB(parent js.Value, m string) func(args ...interface{}) js.Value {
} }
} }
// JsonToJS is a helper that converts JSON bytes input
// to a [js.Value] of the object subtype.
func JsonToJS(inputJson []byte) (js.Value, error) {
jsObj := make(map[string]interface{})
err := json.Unmarshal(inputJson, &jsObj)
if err != nil {
return js.Value{}, err
}
return js.ValueOf(jsObj), nil
}
// JsToJson converts the Javascript value to JSON.
func JsToJson(value js.Value) string {
return JSON.Call("stringify", value).String()
}
type PromiseFn func(resolve, reject func(args ...interface{}) js.Value) type PromiseFn func(resolve, reject func(args ...interface{}) js.Value)
// CreatePromise creates a Javascript promise to return the value of a blocking // CreatePromise creates a Javascript promise to return the value of a blocking
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment