Skip to content

Commit 5906b85

Browse files
committed
Marshal arguments
1 parent dd1dead commit 5906b85

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

v8.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,10 @@ func (f V8Function) Call(args ...interface{}) (interface{}, error) {
6464
})
6565
arguments.WriteString("(" + buf.String() + ")")
6666
} else {
67-
if obj, ok := arg.(V8Object); ok {
68-
arguments.WriteString(obj.Name)
69-
} else if num, ok := arg.(float64); ok {
70-
arguments.WriteString(fmt.Sprintf("%v", num))
71-
} else if bln, ok := arg.(bool); ok {
72-
if bln {
73-
arguments.WriteString("true")
74-
} else {
75-
arguments.WriteString("false")
76-
}
77-
} else if str, ok := arg.(string); ok {
78-
arguments.WriteString(str)
67+
if v8obj, ok := arg.(V8Object); ok {
68+
arguments.WriteString(v8obj.Name)
69+
} else {
70+
json.NewEncoder(&arguments).Encode(arg)
7971
}
8072
}
8173
if i != len(args)-1 {

0 commit comments

Comments
 (0)