updated jsvm types
This commit is contained in:
@@ -313,7 +313,7 @@ func baseBinds(vm *goja.Runtime) {
|
||||
vm.Set("toBytes", func(raw any, maxReaderBytes int) ([]byte, error) {
|
||||
switch v := raw.(type) {
|
||||
case nil:
|
||||
return nil, nil
|
||||
return []byte{}, nil
|
||||
case string:
|
||||
return []byte(v), nil
|
||||
case []byte:
|
||||
|
||||
@@ -128,7 +128,7 @@ func TestBaseBindsToBytes(t *testing.T) {
|
||||
Value any
|
||||
Expected []byte
|
||||
}{
|
||||
{"null", nil, nil},
|
||||
{"null", nil, []byte{}},
|
||||
{"string", "test", []byte("test")},
|
||||
{"number", -12.4, []byte("-12.4")},
|
||||
{"bool", true, []byte("true")},
|
||||
|
||||
+3020
-3014
File diff suppressed because it is too large
Load Diff
@@ -186,8 +186,11 @@ declare function readerToString(reader: any, maxBytes?: number): string;
|
||||
* // io.Reader
|
||||
* const ex1 = toString(e.request.body)
|
||||
*
|
||||
* // slice of bytes ("hello")
|
||||
* const ex2 = toString([104 101 108 108 111])
|
||||
* // slice of bytes
|
||||
* const ex2 = toString([104 101 108 108 111]) // "hello"
|
||||
*
|
||||
* // null
|
||||
* const ex3 = toString(null) // ""
|
||||
* ` + "```" + `
|
||||
*
|
||||
* @group PocketBase
|
||||
@@ -213,7 +216,10 @@ declare function toString(val: any, maxBytes?: number): string;
|
||||
* const ex2 = toBytes("hello") // [104 101 108 108 111]
|
||||
*
|
||||
* // object (the same as the string '{"test":1}')
|
||||
* const ex2 = toBytes({"test":1}) // [123 34 116 101 115 116 34 58 49 125]
|
||||
* const ex3 = toBytes({"test":1}) // [123 34 116 101 115 116 34 58 49 125]
|
||||
*
|
||||
* // null
|
||||
* const ex4 = toBytes(null) // []
|
||||
* ` + "```" + `
|
||||
*
|
||||
* @group PocketBase
|
||||
|
||||
Reference in New Issue
Block a user