Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk-wasm
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
xxdk-wasm
Commits
36b27a73
Commit
36b27a73
authored
2 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
fix breakages
parent
271ef43c
No related branches found
No related tags found
2 merge requests
!60
Revert "Fail a test to be sure it works"
,
!4
Xx 4114/index db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
utils/convert.go
+7
-8
7 additions, 8 deletions
utils/convert.go
utils/utils.go
+0
-16
0 additions, 16 deletions
utils/utils.go
with
7 additions
and
24 deletions
utils/convert.go
+
7
−
8
View file @
36b27a73
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
utils/utils.go
+
0
−
16
View file @
36b27a73
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment