Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReaderToReadableStream ¶ added in v1.2.0
ReaderToReadableStream converts an io.Reader to a JavaScript ReadableStream.
Types ¶
type ReadableStream ¶
type ReadableStream struct {
// contains filtered or unexported fields
}
ReadableStream implements io.ReadCloser for a JavaScript ReadableStream.
func NewReadableStream ¶
func NewReadableStream(stream js.Value) *ReadableStream
NewReadableStream creates a new ReadableStream from a JavaScript ReadableStream.
func (*ReadableStream) Close ¶
func (r *ReadableStream) Close() (err error)
Close closes the ReadableStream. If the stream is already closed, Close does nothing.
func (*ReadableStream) Read ¶
func (r *ReadableStream) Read(p []byte) (n int, err error)
Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. This implementation of Read does not use scratch space if n < len(p). If some data is available but not len(p) bytes, Read conventionally returns what is available instead of waiting for more. Note: Read will block until data is available, meaning in a WASM environment, you must use a goroutine to call Read.
type WritableStream ¶
type WritableStream struct {
// contains filtered or unexported fields
}
WritableStream implements io.WriteCloser for a JavaScript WritableStream.
func NewWritableStream ¶
func NewWritableStream(stream ...js.Value) *WritableStream
NewWritableStream creates a new WritableStream. If a JavaScript WritableStream is provided, it will be used. Otherwise, a new WritableStream will be created.
func (*WritableStream) Close ¶
func (w *WritableStream) Close() (err error)
Close closes the WritableStream. If the stream is already closed, Close does nothing.
func (*WritableStream) Write ¶
func (w *WritableStream) Write(p []byte) (n int, err error)
Write writes len(p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. Write must return a non-nil error if it returns n < len(p). Write must not modify the slice data, even temporarily.