jsutil

package
v0.0.0-...-4cb4b50 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

View Source
var ConsoleFS fs.FS = &consoleFS{w: new(consoleWriter)}

ConsoleFS is a single virtual file at "." whose Write calls Log with the payload interpreted as a UTF-8 string. Read-only opens read as EOF.

Functions

func AsyncIter

func AsyncIter(iter js.Value, fn func(js.Value) error) (err error)

func Await

func Await(promise js.Value) js.Value

func AwaitErr

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

func FetchToReader

func FetchToReader(url string) (io.ReadCloser, error)

FetchToReader performs a fetch and returns an io.ReadCloser

func Get

func Get(path string) (v js.Value)

func LoadScript

func LoadScript(url string, module bool) js.Value

func LoadStylesheet

func LoadStylesheet(url string)

func Log

func Log(args ...any)

func ToSlice

func ToSlice(v js.Value) []js.Value

Types

type FetchReader

type FetchReader struct {
	// contains filtered or unexported fields
}

FetchReader implements io.ReadCloser for fetch response bodies

func (*FetchReader) Close

func (fr *FetchReader) Close() error

Close implements io.Closer

func (*FetchReader) Read

func (fr *FetchReader) Read(p []byte) (n int, err error)

Read implements io.Reader

type PortReadWriter

type PortReadWriter struct {
	// contains filtered or unexported fields
}

wraps a MessagePort as an io.ReadWriteCloser

func NewPortReadWriter

func NewPortReadWriter(port js.Value) *PortReadWriter

func (*PortReadWriter) Close

func (prw *PortReadWriter) Close() error

func (*PortReadWriter) Read

func (prw *PortReadWriter) Read(p []byte) (int, error)

func (*PortReadWriter) Write

func (prw *PortReadWriter) Write(p []byte) (n int, err error)

type ReadWriter

type ReadWriter struct {
	io.ReadCloser
	io.WriteCloser
}

func (*ReadWriter) Close

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

type ReadableStream

type ReadableStream struct {
	// contains filtered or unexported fields
}

wraps a ReadableStream as an io.ReadCloser

func NewReadableStream

func NewReadableStream(stream js.Value) *ReadableStream

func (*ReadableStream) Close

func (rsr *ReadableStream) Close() error

func (*ReadableStream) Read

func (rsr *ReadableStream) Read(p []byte) (int, error)

type Reader

type Reader struct {
	js.Value
	// contains filtered or unexported fields
}

wraps a Go-style reader in JS to io.ReadCloser NOT for use with ReadableStream

func NewReader

func NewReader(v js.Value, bufSize int) *Reader

NewReader creates a reader with an optional reusable buffer for better performance. Pass bufSize > 0 to enable buffer reuse, or 0 to allocate on each read.

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
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(v js.Value, bufSize int) *Writer

NewWriter creates a writer with an optional reusable buffer for better performance. Pass bufSize > 0 to enable buffer reuse, or 0 to allocate on each write.

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