Skip to content

Commit 5c95fa2

Browse files
committed
nodejs
1 parent 9a5f23a commit 5c95fa2

File tree

24 files changed

+844
-21
lines changed

24 files changed

+844
-21
lines changed

lib/db/db.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func (This *_db) close(call goja.FunctionCall) goja.Value {
4545

4646
func (This *_db) exec(call goja.FunctionCall) goja.Value {
4747
args := lib.GetAllArgs(&call)
48-
retVal := This.runtime.NewObject()
4948

5049
if query, ok := args[0].(string); ok {
5150
var result sql.Result
@@ -56,14 +55,15 @@ func (This *_db) exec(call goja.FunctionCall) goja.Value {
5655
result, err = This.db.Exec(query, args[1:]...)
5756
}
5857
if err != nil {
59-
retVal.Set("err", err.Error())
60-
return retVal
58+
return This.runtime.ToValue(map[string]interface{}{
59+
"err": err.Error(),
60+
})
6161
}
62-
retVal.Set("value", NewResult(This.runtime, result))
63-
} else {
64-
retVal.Set("err", "p0 is not a string")
62+
return This.runtime.ToValue(map[string]interface{}{
63+
"value": NewResult(This.runtime, result),
64+
})
6565
}
66-
return retVal
66+
panic(This.runtime.NewTypeError("p0 is not a string"))
6767
}
6868

6969
func (This *_db) prepare(call goja.FunctionCall) goja.Value {

lib/db/redis/redis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package redis
22

33
import (
44
"github.com/dop251/goja"
5-
"github.com/dop251/goja_nodejs/require"
5+
"github.com/zengming00/go-server-js/nodejs/require"
66
"github.com/garyburd/redigo/redis"
77
"github.com/zengming00/go-server-js/lib"
88
)

lib/db/sql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"database/sql"
55

66
"github.com/dop251/goja"
7-
"github.com/dop251/goja_nodejs/require"
7+
"github.com/zengming00/go-server-js/nodejs/require"
88
)
99

1010
type _sql struct {

lib/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66

77
"github.com/dop251/goja"
8-
"github.com/dop251/goja_nodejs/require"
8+
"github.com/zengming00/go-server-js/nodejs/require"
99
)
1010

1111
type _file struct {

lib/fmt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55

66
"github.com/dop251/goja"
7-
"github.com/dop251/goja_nodejs/require"
7+
"github.com/zengming00/go-server-js/nodejs/require"
88
)
99

1010
type _fmt struct {

lib/image/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"image"
55

66
"github.com/dop251/goja"
7-
"github.com/dop251/goja_nodejs/require"
7+
"github.com/zengming00/go-server-js/nodejs/require"
88
"github.com/zengming00/go-server-js/lib/image/lib"
99
)
1010

lib/image/png/png.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"io"
77

88
"github.com/dop251/goja"
9-
"github.com/dop251/goja_nodejs/require"
9+
"github.com/zengming00/go-server-js/nodejs/require"
1010
)
1111

1212
type _png struct {

lib/io.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"io"
55

66
"github.com/dop251/goja"
7-
"github.com/dop251/goja_nodejs/require"
7+
"github.com/zengming00/go-server-js/nodejs/require"
88
)
99

1010
type _io struct {

lib/net/http/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88

99
"github.com/dop251/goja"
10-
"github.com/dop251/goja_nodejs/require"
10+
"github.com/zengming00/go-server-js/nodejs/require"
1111
)
1212

1313
type _http struct {

lib/net/url/url.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/url"
55

66
"github.com/dop251/goja"
7-
"github.com/dop251/goja_nodejs/require"
7+
"github.com/zengming00/go-server-js/nodejs/require"
88
"github.com/zengming00/go-server-js/lib"
99
)
1010

0 commit comments

Comments
 (0)