jsutil

package
v0.0.0-...-abfce65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Await

func Await(promise js.Value) js.Value

func AwaitErr

func AwaitErr(promise js.Value) (js.Value, error)

func CopyObj

func CopyObj(jsObj js.Value) js.Value

func Err

func Err(args ...any)

func HasProp

func HasProp(jsObj js.Value, prop string) bool

func Log

func Log(args ...any)

func Promise

func Promise(fn func() (any, error)) any

func ToGoMap

func ToGoMap(jsObj js.Value) map[string]any

func ToGoSlice

func ToGoSlice(jsArray js.Value) []any

func ToGoStringMap

func ToGoStringMap(jsObj js.Value) map[string]string

func ToGoStringSlice

func ToGoStringSlice(jsArray js.Value) []string

func ToJSArray

func ToJSArray[S ~[]E, E any](s S) []any

func ToJSError

func ToJSError(err error) js.Value

func ToJSMap

func ToJSMap(m map[string]string) map[string]any

func WanixSyscall

func WanixSyscall(fn string, args ...any) (js.Value, error)

Returns the syscall `response.value`. To access the response itself see `WanixSyscallResp` instead.

func WanixSyscallResp

func WanixSyscallResp(fn string, args ...any) (response js.Value, err error)

Useful for syscalls involving streams (i.e. stdio).

Types

type ReadWriter

type ReadWriter struct {
	io.ReadCloser
	io.WriteCloser
}

func (*ReadWriter) Close

func (rw *ReadWriter) Close() (err error)

type Reader

type Reader struct {
	js.Value
}

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

type Writer

type Writer struct {
	js.Value
}

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL